Using GitHub's Release feature, it is possible to provide a link to download a specific version of the published software. However, every time a release is made, the gh-page also needs to be updated.
Is there a way to get a link to a specific file of whatever the latest version of a software is?
e.g., this would be a static link:
https://github.com/USER/PROJECT/releases/download/v0.0.0/package.zip
What I'd like is something like:
https://github.com/USER/PROJECT/releases/download/latest/package.zip
NOTE: The difference between this question and GitHub latest release is that this question specifically asks for getting access to the file, not the GitHub latest release page
You can do an ajax request to get latest release download URL using the GitHub Releases API. It also shows when it was released and the download count:
It is important for you to set the default button URL to the releases page (like https://github.com/ShareX/ShareX/releases/latest) so if the browser does not support ajax (or javascript) or is too slow to get the URL, the download button will still work.
When the Ajax request completes, the URL of this button will change automatically to a direct download URL.
Edit:
I also made a downloads page that shows multiple releases which you can find here: https://getsharex.com/downloads/
Source code of it: https://github.com/ShareX/sharex.github.io/blob/master/js/downloads.js
As noted previously, jq is useful for this and other REST APIs.
tl;dr - more details below
Assuming you want the macOS release:
Solution for atom releases
Note each repo can have different ways of providing the desired artifact, so I will demonstrate for a well-behaved one like atom.
Get the names of the assets published
Get the download URL for the desired asset
Below atom-mac is my desired asset via jq's
select(.name=="atom-mac.zip")
Download the artifact
jq Playground
jq syntax can be difficult. Here's a playground for experimenting with the
jq
above: https://jqplay.org/s/h6_LfoEHLZSecurity
You should take measures to ensure the validity of the downloaded artifact via sha256sum and gpg, if at all possible.
Not possible according to GitHub support as of 2018-05-23
Contacted support@github.com on 2018-05-23 with message:
and they replied:
I will also keep tracking this at: https://github.com/isaacs/github/issues/658
Python solution without any dependencies
Robust and portable:
See also:
Also consider pre-releases
/latest
does not see pre-releases, but it is easy to do since/releases
shows the latest one first:If you want to use just
curl
you can try with-w '%{url_effective}'
that prints the URL after a redirect chain (followed by curl if you invoke it with-L
). So, for exampleoutputs
https://github.com/github-tools/github/releases/tag/v3.1.0
.in PHP - redirect to the latest release download. Simply put on your webspace
A solution using (an inner) wget to get the HTML content, filter it for the zip file (with egrep) and then download the zip file (with the outer wget).