简体   繁体   English

有没有办法从GitHub的最新版本中下载工件?

[英]Is there a way to download an artifact from the latest release on GitHub?

On GitHub I can access a release with particular version with a link like https://github.com/markvincze/golang-build-test/releases/tag/hello-v6 . 在GitHub上,我可以通过链接https://github.com/markvincze/golang-build-test/releases/tag/hello-v6访问具有特定版本的发行版。

I can download its artifacts from that release with https://github.com/markvincze/golang-build-test/releases/download/hello-v6/filename . 我可以使用https://github.com/markvincze/golang-build-test/releases/download/hello-v6/filename从该版本下载其工件。

I can also access the latest release with https://github.com/markvincze/golang-build-test/releases/latest 我还可以通过https://github.com/markvincze/golang-build-test/releases/latest访问最新版本

Question : Is there a way to directly download an artifact from the latest release? 问题 :是否可以直接从最新版本下载工件?
I tried https://github.com/markvincze/golang-build-test/releases/download/latest/filename , but it doesn't work, and I couldn't find anything in the docs. 我尝试了https://github.com/markvincze/golang-build-test/releases/download/latest/filename ,但是它不起作用,并且我在文档中找不到任何内容。

You could determine the latest tag using, for example, the HTTP HEAD request method : 您可以使用例如HTTP HEAD request方法确定最新标签:

HEAD https://github.com/markvincze/golang-build-test/releases/latest

At the time of writing this returns a response including the following two headers: 在撰写本文时,它返回包含以下两个标头的响应:

Status: 302 Found
Location: https://github.com/markvincze/golang-build-test/releases/tag/hello-v6

Using this you should now be able to submit a second request using the appropriate tag. 现在,您应该可以使用相应的标签提交第二个请求。

See Wikipedia's writeup of HTTP 302 for details . 有关详细信息,请参见Wikipedia对HTTP 302的撰写

Another option would be to use the Get the latest release endpoint provided by the GitHub API, and then similarly follow up with a second request. 另一个选择是使用获取 GitHub API提供的最新版本的终结点,然后类似地跟进第二个请求。 In this case the tag_name key from the response will be helpful. 在这种情况下,响应中的tag_name键将很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM