- Use
curl
to get the JSON response for the latest release - Use
grep
to find the line containing file URL - Use
cut
andtr
to extract the URL - Use
wget
to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
a note (for your repositories)
I advise using consistent file-names. I.E. don't include a versioning in the filename.I know it sounds weird, but bear with me* for a second.
You know the
.../releases/latest
syntax right?did you know you can also use it to download files as well? (and not just to redirect to the latest release on Github?)
Here, try this URL for example:
https://github.com/ytdl-org/youtube-dl/releases/latest/download/youtube-dl.exe.
this reduces the need to walk through Github-Releases API entirely! and simplify stuff for users and also web-services that crawls your repository (in-case you have a somewhat popular product :] ).
You don't to maintain any kind of backend or domain at all and relink to to the latest binaries (for example: http://youtube-dl.org/downloads/latest/youtube-dl.exe). it is handled by github releases!
you can always include the version in a file named
version.txt
,or any meta-data, really. keep a consistent file-name here too.
got the idea from https://github.com/yt-dlp/yt-dlp#update