简体   繁体   中英

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 .

I can download its artifacts from that release with 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

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.

You could determine the latest tag using, for example, the HTTP HEAD request method :

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 .

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. In this case the tag_name key from the response will be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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