Skip to content

Instantly share code, notes, and snippets.

@mnewt
Created May 20, 2017 21:33
Show Gist options
  • Save mnewt/b076b6fa05f80eb7ac64684fc943ee7d to your computer and use it in GitHub Desktop.
Save mnewt/b076b6fa05f80eb7ac64684fc943ee7d to your computer and use it in GitHub Desktop.
Shell script to download a github project's latest release
#!/bin/sh
# Download a github project's latest release
# $1: username/repo
# $2: regex to match download file
# example: ./gh-download-latest atom/atom gz
repo=$1
regex=${2:-gz}
wget -qO- https://api.github.com/repos/$repo/releases/latest | \
awk -v regex="$regex" -F '"' '/browser_download_url/ && match($4, regex) { print $4 }' | \
xargs wget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment