跳至主要内容
REST API 现在已版本化。 有关更多信息,请参阅“关于 API 版本控制”。

用于发布的 REST API 端点

使用 REST API 创建、修改和删除发布。

注意:这些端点替换了用于管理下载的端点。您可以从这些端点检索下载次数和浏览器下载 URL。

列出发布

这将返回一个发布列表,其中不包括未与发布关联的常规 Git 标签。要获取 Git 标签列表,请使用 仓库标签 API

已发布的发布信息对所有人可见。只有具有推送访问权限的用户才能收到草稿发布的列表。

用于“列出发布”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • “内容”仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

用于“列出发布”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

查询参数
名称、类型、描述
per_page integer

每页结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。

默认: 30

page integer

要获取的结果页码。有关更多信息,请参阅“在 REST API 中使用分页”。

默认: 1

用于“列出发布”的 HTTP 响应状态代码

状态代码描述
200

好的

404

资源未找到

"列出版本"的代码示例

请求示例

get/repos/{owner}/{repo}/releases
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases

响应

状态: 200
[ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] } ]

创建版本

拥有仓库推送权限的用户可以创建版本。

此端点会触发 通知。使用此端点过快地创建内容可能会导致二级速率限制。有关更多信息,请参阅 "API 速率限制" 和 "使用 REST API 的最佳实践"。

用于“创建版本”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须至少具有以下权限集之一

  • "内容" 仓库权限(写入)
  • "内容" 仓库权限(写入)"工作流" 仓库权限(写入)

用于“创建版本”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

主体参数
名称、类型、描述
tag_name 字符串 必需

标签的名称。

target_commitish 字符串

指定确定从何处创建 Git 标签的提交值。可以是任何分支或提交 SHA。如果 Git 标签已存在,则不使用。默认值:仓库的默认分支。

name 字符串

版本的名称。

body 字符串

描述标签内容的文本。

draft 布尔值

true 表示创建草稿(未发布)版本,false 表示创建已发布版本。

默认值: false

prerelease 布尔值

true 表示将版本标识为预发布版本。false 表示将版本标识为完整版本。

默认值: false

discussion_category_name 字符串

如果指定,则会创建一个指定类别的讨论并将其链接到版本。该值必须是仓库中已存在的类别。有关更多信息,请参阅 "管理仓库中讨论的类别"。

generate_release_notes 布尔值

是否自动生成此版本的名称和正文。如果指定了name,则将使用指定的名称;否则,将自动生成名称。如果指定了body,则该正文将被预先添加到自动生成的注释中。

默认值: false

make_latest 字符串

指定此版本是否应设置为存储库的最新版本。草稿和预发布版本不能设置为最新版本。对于新发布的版本,默认值为truelegacy指定应根据版本创建日期和更高的语义版本来确定最新版本。

默认: true

可以是以下之一: true, false, legacy

“创建版本”的 HTTP 响应状态代码

状态代码描述
201

已创建

404

如果讨论类别名称无效,则为未找到

422

验证失败,或端点已被垃圾邮件攻击。

“创建版本”的代码示例

请求示例

post/repos/{owner}/{repo}/releases
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases \ -d '{"tag_name":"v1.0.0","target_commitish":"master","name":"v1.0.0","body":"Description of the release","draft":false,"prerelease":false,"generate_release_notes":false}'

响应

状态:201
{ "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "discussion_url": "https://github.com/octocat/Hello-World/discussions/90", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] }

为版本生成版本说明内容

生成一个描述版本的名称和正文。正文内容将采用 Markdown 格式,并包含自上次版本以来的更改以及贡献者的信息。生成的版本说明不会保存在任何地方。它们旨在生成并在创建新版本时使用。

“生成版本说明内容”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • "内容" 仓库权限(写入)

“生成版本说明内容”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

主体参数
名称、类型、描述
tag_name 字符串 必需

版本的标签名称。这可以是现有标签或新标签。

target_commitish 字符串

指定将作为版本标签目标的 commitish 值。如果提供的 tag_name 不引用现有标签,则需要此值。如果 tag_name 已经存在,则忽略此值。

previous_tag_name 字符串

用于作为发布说明的起点的前一个标签的名称。用于手动指定作为本次发布的一部分的更改集的范围。

configuration_file_path 字符串

指定存储库中包含用于生成发布说明的配置设置的文件的路径。如果未指定,将使用存储库中位于 '.github/release.yml' 或 '.github/release.yaml' 的配置文件。如果不存在,将使用默认配置。

“为发布生成发布说明内容”的 HTTP 响应状态码

状态代码描述
200

生成的发布说明的名称和正文

404

资源未找到

“为发布生成发布说明内容”的代码示例

请求示例

post/repos/{owner}/{repo}/releases/generate-notes
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/generate-notes \ -d '{"tag_name":"v1.0.0","target_commitish":"main","previous_tag_name":"v0.9.2","configuration_file_path":".github/custom_release_config.yml"}'

生成的发布说明的名称和正文

状态: 200
{ "name": "Release v1.0.0 is now available!", "body": "##Changes in Release v1.0.0 ... ##Contributors @monalisa" }

获取最新发布

查看存储库的最新发布的完整发布。

最新发布是最近的非预发布、非草稿发布,按 created_at 属性排序。created_at 属性是用于发布的提交日期,而不是发布草稿或发布的日期。

“获取最新发布”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • “内容”仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取最新发布”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

“获取最新发布”的 HTTP 响应状态码

状态代码描述
200

好的

“获取最新发布”的代码示例

请求示例

get/repos/{owner}/{repo}/releases/latest
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/latest

响应

状态: 200
{ "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "discussion_url": "https://github.com/octocat/Hello-World/discussions/90", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] }

按标签名称获取发布

获取指定标签的已发布版本。

“按标签名称获取版本”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • “内容”仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“按标签名称获取版本”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

tag 字符串 必需

tag 参数

“按标签名称获取版本”的 HTTP 响应状态代码

状态代码描述
200

好的

404

资源未找到

“按标签名称获取版本”的代码示例

请求示例

get/repos/{owner}/{repo}/releases/tags/{tag}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/tags/TAG

响应

状态: 200
{ "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "discussion_url": "https://github.com/octocat/Hello-World/discussions/90", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] }

获取版本

获取指定版本 ID 的公共版本。

注意: 这将返回一个 upload_url 键,对应于上传版本资产的端点。此键是超媒体资源。有关更多信息,请参阅“REST API 入门”。

“获取版本”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • “内容”仓库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取版本”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

release_id 整数 必需

版本的唯一标识符。

“获取版本”的 HTTP 响应状态代码

状态代码描述
200

注意: 这将返回一个 upload_url 键,对应于上传版本资产的端点。此键是超媒体资源。有关更多信息,请参阅“REST API 入门”。

401

未经授权

“获取版本”的代码示例

请求示例

get/repos/{owner}/{repo}/releases/{release_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID

注意: 这将返回一个 upload_url 键,对应于上传版本资产的端点。此键是超媒体资源。有关更多信息,请参阅“REST API 入门”。

状态: 200
{ "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "discussion_url": "https://github.com/octocat/Hello-World/discussions/90", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] }

更新版本

具有仓库推送权限的用户可以编辑版本。

“更新版本”的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • "内容" 仓库权限(写入)

“更新版本”的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

release_id 整数 必需

版本的唯一标识符。

主体参数
名称、类型、描述
tag_name 字符串

标签的名称。

target_commitish 字符串

指定确定从何处创建 Git 标签的提交值。可以是任何分支或提交 SHA。如果 Git 标签已存在,则不使用。默认值:仓库的默认分支。

name 字符串

版本的名称。

body 字符串

描述标签内容的文本。

draft 布尔值

true 使版本成为草稿,false 发布版本。

prerelease 布尔值

true 表示将版本标识为预发布版本,false 表示将版本标识为完整版本。

make_latest 字符串

指定此版本是否应设置为存储库的最新版本。草稿和预发布版本不能设置为最新版本。对于新发布的版本,默认值为truelegacy指定应根据版本创建日期和更高的语义版本来确定最新版本。

默认: true

可以是以下之一: true, false, legacy

discussion_category_name 字符串

如果指定,则会创建指定类别的讨论并将其链接到版本。该值必须是仓库中已存在的类别。如果版本已链接到讨论,则忽略此参数。有关更多信息,请参阅“管理仓库中的讨论类别”。

更新发布的 HTTP 响应状态码

状态代码描述
200

好的

404

如果讨论类别名称无效,则为未找到

更新发布的代码示例

请求示例

patch/repos/{owner}/{repo}/releases/{release_id}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID \ -d '{"tag_name":"v1.0.0","target_commitish":"master","name":"v1.0.0","body":"发布说明","draft":false,"prerelease":false}'

响应

状态: 200
{ "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", "discussion_url": "https://github.com/octocat/Hello-World/discussions/90", "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v1.0.0", "target_commitish": "master", "name": "v1.0.0", "body": "Description of the release", "draft": false, "prerelease": false, "created_at": "2013-02-27T19:35:32Z", "published_at": "2013-02-27T19:35:32Z", "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "assets": [ { "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1", "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip", "id": 1, "node_id": "MDEyOlJlbGVhc2VBc3NldDE=", "name": "example.zip", "label": "short description", "state": "uploaded", "content_type": "application/zip", "size": 1024, "download_count": 42, "created_at": "2013-02-27T19:35:32Z", "updated_at": "2013-02-27T19:35:32Z", "uploader": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ] }

删除发布

拥有仓库推送权限的用户可以删除发布。

删除发布的细粒度访问令牌

此端点与以下细粒度令牌类型一起使用

细粒度令牌必须具有以下权限集

  • "内容" 仓库权限(写入)

删除发布的参数

标头
名称、类型、描述
accept string

建议设置为 application/vnd.github+json

路径参数
名称、类型、描述
owner string 必需

仓库的帐户所有者。名称不区分大小写。

repo string 必需

仓库的名称,不包括 .git 扩展名。名称不区分大小写。

release_id 整数 必需

版本的唯一标识符。

删除发布的 HTTP 响应状态码

状态代码描述
204

无内容

删除发布的代码示例

请求示例

delete/repos/{owner}/{repo}/releases/{release_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/releases/RELEASE_ID

响应

状态:204