Skip to content

Instantly share code, notes, and snippets.

@chase2981
Forked from lukechilds/get_latest_release.sh
Created September 9, 2021 22:57
Show Gist options
  • Save chase2981/e22a7357b4d8e82e416514684058ce11 to your computer and use it in GitHub Desktop.
Save chase2981/e22a7357b4d8e82e416514684058ce11 to your computer and use it in GitHub Desktop.
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@chase2981
Copy link
Author

git fetch --tags && git tag | tail -1

curl --silent "https://api.github.com/repos/$1/releases/latest" | jq -r .tag_name

curl --silent "https://api.github.com/repos/certbot/certbot/tags" | jq -r '.[0].name'

https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c

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