How to download the latest GitHub repo release via command line

I just fiddled around a bit to find out how to download the latest GitHub release via the command line. Turns out that GitHub doesn’t provide a universal download URL to release binaries like it does for the release browser page itself. The latest release page can always be reached via, e.g. Unfortunately that is not true for the binaries, which are available under and but not under something generic like and

The issue here is that GitHub only provides the release binaries under their actual release tag, e.g. v1.0.0, but that tag is entirely up to the user to define and changes as more releases are added, of course. It’s therefore hard to guess what the release tag would be and what to download. Nevertheless, thanks to the GitHub developer APIs it’s not that tricky to figure out the release tag for the latest release and instruct a utility like curl to download the binary. I’ve written a little one-liner for the UNIX command line to do exactly that. It took me a bit to get it right and so I thought it might come handy to you, rather than trying to reinvent the wheel. it It’s also available as a public Gist but I thought for visibility purposes it makes sense to blog it here, too.

LOCATION=$(curl -s \
| grep "tag_name" \
| awk '{print "" substr($2, 2, length($2)-3) ".zip"}') \

For example:

LOCATION=$(curl -s \
| grep "tag_name" \
| awk '{print "" substr($2, 2, length($2)-3) ".zip"}') \
; curl -L -o $LOCATION

Here is how it goes:


stores the output of all the commands in the brackets in the variable $LOCATION,

curl -s

gets the latest release from your repository, in my case,

grep "tag_name"

grabs the tag name of the latest release (e.g. v1.0.0),

awk '{print "" substr($2, 2, length($2)-3) ".zip"}'

prints +

Now the $LOCATION environment variable is set to that string. From that point on you can do with that variable whatever you like, in case you have another use than downloading the binary. Or, just like below, you can complete the download process:

curl -L -o $LOCATION

invokes cURL and downloads $LOCATION into The -L parameter is important so that cURL follows the URL, i.e. redirect.

Hope this helps.

Author: Gerald

Developer, Oracle expert, performance enthusiast and genuine technology geek.

One thought on “How to download the latest GitHub repo release via command line”

  1. Thank you so much for sharing this post on how to download the latest Github repo release. I’ve been searching this guide for a while, tried several methods I found, but this method is the most effective. I have tried this already and it is really working. For those who want to try, just read carefully and follow what is being suggested on this post and you can successfully do it too.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.