更新仓库Release¶
PATCH /api/v5/repos/{owner}/{repo}/releases/{tag}
用户调用此接口,进行更新仓库 Release 操作。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址 path) |
repo |
path | string | 是 | 仓库路径(path) |
tag |
path | string | 是 | Tag 名称 |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "Release 名称",
"type": "string"
},
"body": {
"description": "Release 描述",
"type": "string"
},
"release_status": {
"description": "Release 状态:`pre`(预发布版本)、`latest`(最新版本)",
"type": "string",
"enum": ["pre", "latest"]
}
},
"required": ["name", "body"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
tag_name |
string | 是 | — | Release 对应的 Tag 名称 |
target_commitish |
string | 是 | — | 目标提交(commit)标识 |
prerelease |
boolean | 是 | — | 是否为预发布版本 |
name |
string | 是 | — | Release 名称 |
body |
string | 是 | — | Release 描述 |
author |
object | 是 | — | Release 作者信息 |
created_at |
string | 是 | — | Release 创建时间 |
assets |
array | 是 | — | Release 附件列表 |
release_status |
string | 是 | — | Release 状态(pre / latest) |
author 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
author.id |
string | 是 | — | 用户 ID |
author.login |
string | 是 | — | 用户名 |
author.name |
string | 是 | — | 用户名称 |
author.avatar_url |
string | 是 | — | 用户头像地址 |
author.html_url |
string | 是 | — | 用户主页地址 |
author.type |
string | 是 | — | 用户类型 |
author.url |
string | 是 | — | 用户 API 地址 |
assets 元素对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
assets.browser_download_url |
string | 是 | — | 附件浏览器下载地址 |
assets.name |
string | 是 | — | 附件名称 |
assets.type |
string | 是 | — | 附件类型 |
失败响应¶
该接口无业务失败响应。错误响应结构以后端实际返回为准。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
401 |
需要认证(Requires authentication) |
403 |
禁止访问(Forbidden) |
404 |
资源不存在(Not found) |
请求示例¶
参数说明¶
<owner>替换为仓库所属空间地址(企业、组织或个人的地址 path);<repo>替换为仓库路径(path);<tag>替换为 Tag 名称。
cURL¶
curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"name": "release1 名称",
"body": "release1 描述",
"release_status": "latest"
}'
JavaScript¶
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({
name: "release1 名称",
body: "release1 描述",
release_status: "latest"
})
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.patch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases/<tag>",
json={
"name": "release1 名称",
"body": "release1 描述",
"release_status": "latest",
},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"tag_name": "v1.0.217",
"target_commitish": "930401b0dd58a809fce34da091b8aa3d6083cb33",
"prerelease": false,
"name": "release1 名称",
"body": "release1 描述",
"author": {
"id": "26593",
"login": "fenglonghui",
"name": "龙辉",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/fenglonghui",
"type": "User",
"url": "https://api.atomgit.com/api/v5/users/fenglonghui"
},
"created_at": "2025-01-16T19:58:07+08:00",
"assets": [
{
"browser_download_url": "https://api.atomgit.com/rust-learning/serde/-/archive/v1.0.217/serde-v1.0.217.zip",
"name": "serde-v1.0.217.zip"
},
{
"browser_download_url": "https://api.atomgit.com/rust-learning/serde/-/archive/v1.0.217/serde-v1.0.217.tar.gz",
"name": "serde-v1.0.217.tar.gz"
}
],
"release_status": "latest"
}
错误码¶
| 错误码 | 说明 |
|---|---|
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
400 |
参数错误或请求无法解析 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc