Linking to Zip or Tar.gz File in Version-Tagged GitHub Release

In the two preceding posts of this blog, I wanted to provide a direct link for a reader to download the latest version of the software discussed, regardless of how many changes had been made to the software since the posts were published. I also wanted to have my releases in GitHub tagged with the version number for the release.

The best GitHub seems to offer in this situation is a link to the page for the latest release from which one has to download the correct file, as discussed on the GitHub Docs page Linking to releases. Given that this is a version-tagged release, directly downloading a particular file requires a link to include the version number of the release. Such a link would no longer point to a file in the latest release after a new release was created, but rather to a nonexistent file in the new release.

Lrfg, for Latest Release Files Generator, is a proof-of-concept bash script I put together for working around this problem (and for editing the releases a bit in the process). Lrfg uses GitHub’s REST API to download information about the latest release, download the zip file from the release, create two files named <repo>-release.zip and <repo>-release.tar.gz from it, and upload them as new assets to the latest release.

In use over multiple releases, each release will have like-named zip and tar.gz files. Consequently, the latest release zip file, for example, may be accessed without reference to the version number using the address github.com/<user>/<repo>/releases/latest/download/<repo>-release.zip. By running lrfg against each new release, a <repo>-release.zip file would be provided for each release, and that URL would always point to the latest of those files. The tar.gz file can be accessed via a similar URL if desired.

As currently implemented, Lrfg modifies the zip file contents as desired before creating the new files, although this isn’t necessary to provide the linking discussed above.

Lrfg is available for cloning, forking, and download at https://github.com/dfyockey/Lrfg.