Created
July 4, 2021 16:34
-
-
Save NickCrew/580488ac0b92190774570f0a2cb0f3d1 to your computer and use it in GitHub Desktop.
Get latest github release
This file contains hidden or 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
#!/usr/bin/env bash | |
set -e | |
if [[ "$#" != "2" ]]; then | |
echo "USAGE:" | |
echo "get-latest-github-release.sh <user> <repo> [file extension] [outfile]" | |
exit 1 | |
fi | |
repo="${1}/${2}" | |
[[ ! -z "$3" ]] && file_type="$3" | |
file_type=tar.gz | |
outfile="/tmp/${2}.${file_type}" | |
[[ ! -z "$4" ]] && outfile="$4" | |
url=`curl -s \ | |
https://api.github.com/repos/${repo}/releases/latest | \ | |
grep "browser_download_url.*.${file_type}" | \ | |
cut -d : -f 2,3 | tr -d \"` | |
wget $url -O $outfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment