Skip to content

Instantly share code, notes, and snippets.

@NickCrew
Created July 4, 2021 16:34
Show Gist options
  • Save NickCrew/580488ac0b92190774570f0a2cb0f3d1 to your computer and use it in GitHub Desktop.
Save NickCrew/580488ac0b92190774570f0a2cb0f3d1 to your computer and use it in GitHub Desktop.
Get latest github release
#!/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