创建仓库Release¶
POST /api/v5/repos/{owner}/{repo}/releases
创建仓库 Release,需要提供 tag 名称、Release 名称与描述等信息。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
owner |
path | string | 是 | 仓库所属空间地址(企业、组织或个人的地址path) |
repo |
path | string | 是 | 仓库路径 |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"tag_name": {
"description": "tag名称",
"type": "string"
},
"name": {
"description": "release名称",
"type": "string"
},
"body": {
"description": "release描述",
"type": "string"
},
"target_commitish": {
"description": "分支名称或者commit SHA,如果tag不存在,需要新建tag则传入该参数,如果不传入该参数,则为默认分支的最新提交",
"type": "string"
},
"release_status": {
"description": "Release状态。pre(预发布版本),latest(最新版本)",
"type": "string",
"enum": ["pre", "latest"]
}
},
"required": ["tag_name", "name", "body"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
tag_name |
string | 是 | 否 | tag名称 |
target_commitish |
string | 是 | 否 | 分支名称或者commit SHA |
prerelease |
boolean | 是 | 否 | 是否为预发布版本 |
name |
string | 是 | 否 | release名称 |
body |
string | 是 | 否 | release描述 |
author |
object | 是 | 否 | Release 作者信息 |
created_at |
string | 是 | 否 | 创建时间 |
assets |
object[] | 是 | 否 | 关联的附件列表 |
release_status |
string | 是 | 否 | Release 状态 |
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 | 是 | 否 | 用户信息地址 |
assets 对象
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
assets.browser_download_url |
string | 是 | 否 | 浏览器下载地址 |
assets.name |
string | 是 | 否 | 附件名称 |
assets.type |
string | 是 | 否 | 附件类型 |
失败响应¶
400 参数错误
401 未认证
错误字段名以后端实际返回为准,示例仅供参考。
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad request) |
401 |
需要认证(Requires authentication) |
404 |
未找到(Not found) |
500 |
系统内部错误(Internal server error) |
请求示例¶
参数说明¶
必填参数包括路径参数 owner、repo,查询参数 access_token,以及请求体字段 tag_name、name、body。target_commitish 与 release_status 为可选参数。
<owner>替换为仓库所属空间地址(企业、组织或个人的地址path);<repo>替换为仓库路径;<token>替换为你的 AtomGit 用户访问令牌。
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"tag_name": "v1.0.0",
"name": "v1.0.0",
"body": "这是 v1.0.0 版本的发布说明",
"target_commitish": "master",
"release_status": "latest"
}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases?access_token=<token>",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({
tag_name: "v1.0.0",
name: "v1.0.0",
body: "这是 v1.0.0 版本的发布说明",
target_commitish: "master",
release_status: "latest"
})
}
);
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/releases",
params={"access_token": "<token>"},
json={
"tag_name": "v1.0.0",
"name": "v1.0.0",
"body": "这是 v1.0.0 版本的发布说明",
"target_commitish": "master",
"release_status": "latest",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
{
"tag_name": "v1.0.0",
"target_commitish": "master",
"prerelease": false,
"name": "v1.0.0",
"body": "这是 v1.0.0 版本的发布说明",
"author": {
"id": "10001",
"login": "octocat",
"name": "octocat",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/octocat",
"type": "User",
"url": "https://api.atomgit.com/octocat"
},
"created_at": "2026-10-13T23:23:39+08:00",
"assets": [
{
"browser_download_url": "https://api.atomgit.com/<owner>/<repo>/releases/download/v1.0.0/release.tar.gz",
"name": "release.tar.gz",
"type": "application/gzip"
}
],
"release_status": "latest"
}
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
404 |
请求路径不存在 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc