我想知道如何使用github-api获取项目的所有当前版本或标签。我见过documentation for tags in github-api,但我没有看到列出所有标签或列出所有版本的方法,但只列出了一个特定的标签:sha。
答案 0 :(得分:19)
这是可能的,但文档可能不在您期望的位置。
http://developer.github.com/v3/git/refs/
您还可以请求子命名空间。例如,获取所有标签 参考,你可以打电话:
GET /repos/:owner/:repo/git/refs/tags
答案 1 :(得分:8)
今天早上我收到了我发给github支持团队的同一个问题的答案。不确定我如何正确归纳答案,但这是他们的回答。
引自Github支持团队的IvanŽužak
您可以使用此API调用获取存储库的所有标记列表:
http://developer.github.com/v3/repos/#list-tags
因此,例如,发出以下cURL请求将返回libgit2 / libgit2存储库的标记列表:
$ curl -v“https://api.github.com/repos/libgit2/libgit2/tags”
答案 2 :(得分:2)
注意:对于GitHub仓库的releases specifically,您现在拥有(since Sept. 25th, 2013),api to list all the releases:
具有拉取权限的用户只会收到已发布的版本。
GET /repos/:owner/:repo/releases
响应
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
[
{
"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}",
"id": 1,
"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"
}
]
GET /repos/:owner/:repo/releases/:id
答案 3 :(得分:2)
在v4,graphQL中,您可以使用此查询https://developer.github.com/v4/reference/object/tag/
query {
repository(owner: "onmyway133", name: "Scale") {
refs(refPrefix: "refs/tags/", last: 2) {
edges {
node {
name
}
}
}
}
}
答案 4 :(得分:0)
这将在Github上列出您的所有发行版(标签)。可能需要根据您的标签命名约定将document()
部分改成一周:
grep
如果要从“克隆存储库”部分中剪切URL,请记住在构建以上URL-HTH-Terrence Houlahan时在地址末尾切掉curl -s 'https://github.com/username/reponame/tags/'|grep -o "$Version v[0-9].[0-9][0-9]"