Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save steinwaywhw/a4cd19cda655b8249d908261a62687f8 to your computer and use it in GitHub Desktop.
Save steinwaywhw/a4cd19cda655b8249d908261a62687f8 to your computer and use it in GitHub Desktop.
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr 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 -
@maxadamo
Copy link

Actual 'one-liner'; you don't need tools:

https://github.com/$OWNER/$REPO/releases/latest/download/$FILENAME

do you really think hundreds of people are completely dumb and did not figure out something so simple? 😸
The whole point is to guess $FILENAME, becuse you don't know in advance what the latest version is.

@Mr-Bossman
Copy link

I mean in his particular case it does work bc the maintainers decided to keep the filename the same for every release. Not a portable option IMO but if you are the repo owner it works.

@aristotaloss
Copy link

@maxadamo bro pipe the fuck down

@maxadamo
Copy link

maxadamo commented Jun 22, 2025

I mean in his particular case it does work bc the maintainers decided to keep the filename the same for every release. Not a portable option IMO but if you are the repo owner it works.

That would be another topic, on another thread: "how do I download an artifact if the filename doesn't change."
The case we are discussing is very clear and it's pretty different.
And it's really unimportant if you use sed, grep, jq, because everything woks. Maybe one pipe should be enough, but if you are not seeking for extreme optimization, it's purely stylistic.

For instance I rather like the AWK approach:

REPO='jgraph/drawio-desktop'
curl -s https://api.github.com/repos/${REPO}/releases/latest | awk -F\" '/browser_download_url.*.deb/{print $(NF-1)}'

again, we are hundreds of people, not having much else todo, and playing to find different solutions, but we're not hundreds of idiots. This thread is 8 year old and if there was a simpler solution someone else would have found it in 8 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment