This took way too long to work out, so I figure it’s worth a post-
You want to script getting the latest version of ‘product x’ from Github, but don’t want to deal with version numbers etc. I saw loads of posts that used awk, sed, regex and various JSON extractors but nothing did what I wanted (and could understand) simply
A lot of docs tell you to use
then you can ask for the ‘browser_download_url’ for your code, specify an output file and you’re golden
But that only works if the repo has only a single bit of code in that repo. If it contains loads, you’ll get… loads. Taking, for example the netclient.app from Gravitl- I wanted a binary called ‘netclient-darwin’ but if you look in the repo, there’s builds for all sorts of architectures. Add in the complication of version numbers, and we have a problem. for instance, the current version URL would be
But the trick is- don’t just substitute ‘latest’ for version number in the URL, it goes like this-
So in a more generic notation, you can express it as-
This may not last forever, or even be good practise, but hey – it works for now!