Skip to content

Instantly share code, notes, and snippets.

@lukechilds
Created August 9, 2016 19:43
Show Gist options
  • Save lukechilds/a83e1d7127b78fef38c2914c4ececc3c to your computer and use it in GitHub Desktop.
Save lukechilds/a83e1d7127b78fef38c2914c4ececc3c 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
@roryabraham
Copy link

roryabraham commented Aug 30, 2024

For the gh-cli inclined:

gh release list --exclude-pre-releases --json tagName,isLatest --jq '.[] | select(.isLatest) | .tagName'

@rvdsteege
Copy link

@roryabraham also gh CLI, but even shorter:

gh repo view --json latestRelease --jq '.[] | .tagName'

https://cli.github.com/manual/gh_repo_view

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