Created
May 20, 2017 21:33
-
-
Save mnewt/b076b6fa05f80eb7ac64684fc943ee7d to your computer and use it in GitHub Desktop.
Shell script to download a github project's latest release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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