如何下载 GitHub 版本的二进制文件? [英] How do I download binary files of a GitHub release?
问题描述
我有一个包含我需要的二进制文件的存储库.
I have a repo with binary files in it that I need.
我可以
git checkout tags/thetagoftherelease
这似乎检查了正确的标签,但没有拉下二进制文件.如何下拉添加到版本中的二进制文件(版本中的绿色框)?
which seems to checkout the correct tag, but does not pull down the binary files. How can I pull down the binary files that were added to the release (the green boxes on the release)?
在版本中添加了二进制文件的图片.
Added picture of binary files in a release.
推荐答案
我已经尝试了几天试图找到正确的答案,最后我通过 curl 命令弄清楚了如何做到这一点.这是一个 3 步过程.
I've tried for days trying to find the proper answer to this, and finally I figured out how to do this via the curl command. It's a 3-step process.
首先,获取最新版本的资产列表:
First, to get a list of the assets for the latest release:
curl -H "Authorization: token YOURGITHUBTOKEN"
https://api.github.com/repos/NAME/REPO/releases/latest
然后在 JSON 中,查找所需资产的 url.例如,它看起来像:
Then in the JSON, look up the url of the asset you want. For example it would look like:
"url": "https://api.github.com/repos/NAME/REPO/releases/assets/1275759"
然后您将其传递给另一个 curl 命令以检索实际 URL,该 URL 实际上是指向 Amazon S3 文件的链接.
Then you pass this to another curl command to retrieve the actual URL, which is actually a link to an Amazon S3 file.
curl -H "Authorization: token YOURGITHUBTOKEN"
-H "Accept:application/octet-stream"
-i https://api.github.com/repos/NAME/REPO/releases/assets/1275759
URL 将在 HTTP 响应的位置"字段中,然后使用 curl 获取文件,如下所示:
The URL will be in the "location" field of the HTTP response, and then use curl to get the file like this:
curl "https://github-cloud.s3.amazonaws.com...." -i -o FILENAME
这篇关于如何下载 GitHub 版本的二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!