Instantly share code, notes, and snippets.

What would you like to do?
One Liner to download the latest release from your GitHub repo
LOCATION=$(curl -s<YOUR ORGANIZTION>/<YOUR REPO>/releases/latest \
| grep "tag_name" \
| awk '{print "<YOUR ORGANIZATION>/<YOUR REPO>/archive/" 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 "" v1.0.0 ".zip" --> ""

Now the $LOCATION is set to that string.

curl -L -o $LOCATION

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

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