[英]Github api tag is not created
I tried to create a tag using Github API .我尝试使用Github API创建标签。 I made a POST request to
/repos/:owner/:repo/git/tags
, and I get this result:我向
/repos/:owner/:repo/git/tags
发出了一个 POST 请求,我得到了这个结果:
HTTP/1.1 201 Created
But unfortunately no tag was created.但不幸的是没有创建标签。 The new tag simply does not exist.
新标签根本不存在。 What do I wrong?
我做错了什么?
The tagging didn't work for me.标记对我不起作用。 It shows created, but nothing appears on github.
它显示已创建,但 github 上没有出现任何内容。 However, I managed to achieve tagging by creating pre-release.
但是,我设法通过创建预发布来实现标记。 Which is not ideal, but still better than nothing:
这并不理想,但总比没有好:
curl --location --request POST
'https://<giturl>/repos/{owner}/{repo}/releases' \
--header 'Authorization: Basic xxx' \
--header 'Content-Type: application/vnd.github.v3+json' \
--data-raw '{
"tag_name": "v0.0.1",
"target_commitish": "master",
"name": "v0.0.1",
"body": "This is for Release v0.0.1 of the product",
"draft": false,
"prerelease": true}'
There are two types of tags -- annotated and lightweight, you can check the difference here .有两种类型的标签——带注释的和轻量级的,你可以在这里查看区别。
As Github API puts, /repos/:owner/:repo/git/tags
only created an annotated tag object, and then you should manually create a refrence with the sha of this tag object by calling create refrence api :正如Github API所说,
/repos/:owner/:repo/git/tags
只创建了一个带注释的标签 object,然后您应该通过调用create refrence api手动创建带有此标签 object 的 sha 的引用:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/git/refs \
-d '{"ref":"refs/tags/tagName","sha":"the sha of tag object"}'
In another case, if you only want to add a lightweight tag to one commit, you should directly call create refrence api without the first step:还有一种情况,如果你只想给一个commit添加一个轻量级的标签,你应该直接调用create refrence api而不用第一步:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/git/refs \
-d '{"ref":"refs/tags/tagName","sha":"the sha of the commit that you want to tag"}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.