[英]How to use Github Release API to make a release without source code?
I am using blow command to publish a release on Github repo: 我正在使用打击命令在Github存储库上发布发行版:
curl -X POST -H "Authorization: token xxxxxxxxx" -d '{"tag_name": "test", "name":"release-0.0.1","body":"this is a test release"}' https://api.github.com/repos/xxxxxx
I can see that a new release is created. 我可以看到创建了一个新版本。 But there are two download buttons under it:
但是下面有两个下载按钮:
Source code (zip)
Source code (tar.gz)
How can I make a release without source code? 没有源代码如何发布?
If I can't remove the source code attachment, how can I upload additional binary files? 如果无法删除源代码附件,如何上传其他二进制文件? I tried to use the API
Upload a release asset
like this: POST https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip
, it returns successfully but I couldn't find the binaries on Github release tab. 我试图使用API
Upload a release asset
: POST https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip
,它成功返回但我无法返回在Github发行标签上找到二进制文件。
To create a new release and upload additional binaries, you can : 要创建新版本并上传其他二进制文件,您可以:
POST /repos/:username/:repo/releases
and store the upload_url
field from the response POST /repos/:username/:repo/releases
并存储响应中的upload_url
字段 POST $upload_url
with additional parameters name
and optional label
(refer to this ) POST $upload_url
与其他参数name
和可选label
(参见本 ) A quick example using bash
, curl
and jq
(JSON parser) : 一个使用
bash
, curl
和jq
(JSON解析器)的简单示例:
#!/bin/bash
token=YOUR_TOKEN
repo=username/your-repo
upload_url=$(curl -s -H "Authorization: token $token" \
-d '{"tag_name": "test", "name":"release-0.0.1","body":"this is a test release"}' \
"https://api.github.com/repos/$repo/releases" | jq -r '.upload_url')
upload_url="${upload_url%\{*}"
echo "uploading asset to release to url : $upload_url"
curl -s -H "Authorization: token $token" \
-H "Content-Type: application/zip" \
--data-binary @test.zip \
"$upload_url?name=test.zip&label=some-binary.zip"
I don't think you can on the community version. 我认为您不能使用社区版本。 You can attach small binaries to the release though.
您可以将小型二进制文件附加到发行版中。 I believe this is the way that GitHub works, as it is oriented around browsing the code, and providing the source is the important part.
我认为这是GitHub的工作方式,因为GitHub是围绕着浏览代码的方向而来的,提供源代码是重要的部分。
You can control the contents of sorcecode archive within automatic generation using the .gitattributes file (and make it part of your repository). 您可以使用.gitattributes文件控制sorcecode档案的内容,以使其自动生成(并将其作为存储库的一部分)。
Add lines like: 添加如下行:
src export-ignore
to exclude the directory "src" from being part of the generated source package. 从生成的源包中排除目录“ src”。 Internally github uses "git archive" to create packages based on the tags - and "git archive" can be controlled via ".gitattributes".
github内部使用“ git archive”基于标签创建软件包-“ git archive”可以通过“ .gitattributes”进行控制。
Don't know whether you can avoid generating the source package completely - but this is at least a workaround to control the contents of the source code package 不知道是否可以避免完全生成源程序包-但这至少是一种控制源代码包内容的解决方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.