如何使用Github发布API在没有源代码的情况下发布一个版本? [英] How to use Github Release API to make a release without source code?
问题描述
curl -X POST -H授权:令牌xxxxxxxxx-d{tag_name:test,name:release-0.0.1,body:这是一个测试版本}'https://api.github.com/repos / xxxxxx
我可以看到新版本已创建。但是它下面有两个下载按钮:
源代码(zip)
源代码(tar.gz)
如何在没有源代码的情况下发布一个版本?
如果我无法删除源代码附件,我怎样才能上传其他二进制文件?我尝试使用API 上传发布资产
,例如: POST https://< upload_url> / repos /:owner /:repo /发布/:id / assets?name = foo.zip
,它会成功返回,但我无法在Github发布选项卡上找到二进制文件。
要创建新版本并上传其他二进制文件,您可以: POST / repos /:username /:repo / releases
并存储响应中的 upload_url
字段
POST $ upload_url
以及其他参数名称
和可选的上传您的资产>标签
(请参阅此 )
使用 bash
, curl
和 jq
(JSON解析器):
#!/ bin / bash
token = YOUR_TOKEN
repo = username / your-repo
$ b upload_url = $(curl -s -H)授权:令牌$ token\
-d'{tag_name:test,name:ease-0.0 .1,body:这是一个测试版本}'\
https://api.github.com/repos/$repo/releases| jq -r'.upload_url')
$ b $ upload_url =$ {upload_url%\ {*}
echo将资源上传到网址:$ upload_url
curl -s -HAuthorization:token $ token\
-HContent-Type:application / zip\
--data-binary @test。 zip \
$ upload_url?name = test.zip& label = some-binary.zip
I am using blow command to publish a release on Github repo:
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.
To create a new release and upload additional binaries, you can :
- create the release using
POST /repos/:username/:repo/releases
and store theupload_url
field from the response - upload your asset using
POST $upload_url
with additional parametersname
and optionallabel
(refer to this)
A quick example using bash
, curl
and jq
(JSON parser) :
#!/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"
这篇关于如何使用Github发布API在没有源代码的情况下发布一个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!