GitHub Releases are a great resource for open source projects to expand on the simple git tag concept. You can add release notes in Markdown format, and you can upload finalized assets - such as compiled executables.

As a user I had the question - how do I script "download the latest release, please?"

For example, when Geoff Franks or someone from the team cuts a new spruce version, what can I put in my bash scripts to automatically download that new version, rather than a fixed version number.

curl, jq and the Github API to the rescue:

curl -s | jq -r ".assets[] | select(.name | test(\"${spruce_type}\")) | .browser_download_url"  

The magic is the .../releases/latest API endpoint which automatically figures out which is the latest release.

Will return the download URL for the linux_amd64 version of Spruce:  

The | select(.name | test"<some-filter>") portion of the jq filter would be specific to the release and its files.

The spruce project releases the following files each time:

curl -s | jq -r ".assets[].name"  

Which returns (for the current v1.0.1 release):


So we can find the target file by filtering between darwin_amd64 or linux_386 or linux_amd64.

For another project, the files and how to filter to get the right one might be different.