In principle, every project should have a pointer as an URL to the latest version of their published software but this is frequently not the case and the "tags" section of most projects either contain version numbers of milestones. Downloading the latest release of software is often needed for automating upgrades, especially when building applications that run within isolation containers like Docker.
The github REST API alleviates some of the trouble with locating the very latest release but it is still a matter of using multiple commands.
Here is an example command-call to download the latest xidel TAR bundle to the local directory:
curl \ -s \ -L 'https://api.github.com/repos/benibela/xidel/releases/latest' | \ jq '.assets[].browser_download_url' | \ grep linux64 | \ xargs curl -s -L -o - | \ tar -zxvf -
where:
benibela
is the vendor or project owner,xidel
is the project nme
The command contains a matcher, namely linux64
because there is no canonical order to a release such that the specific file that is wanted must be matched. In this case, xidel is distributed both as source and binary, and for the sake of the command only the x64 Linux binary is desired. The rest of the command retrieves and unpacks the files to the local directory.
The following is another variant when the name of the bundle to be downloaded contains the name of the platform or architecture:
curl -sL "https://api.github.com/repos/bcicen/ctop/releases/latest" | \ jq -r '.assets[] | select (.name | contains("linux-amd64")) | .browser_download_url' && \ xargs curl -sLo file && \ mv file /usr/local/bin/ctop
Doing things this way will result in a file named file
being downloaded to the current directory that can then be moved to its final destination and its final name. The command is very useful when creating build files for Docker because it will ensure that, assuming that the developer maintains the naming convention, in particular including the platform and architecture name, the command will always be able to not only retrieve the latest version but will also be able to move the file to its final destination by normalizing the name of the downloaded file.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.