Skip to content

Instantly share code, notes, and snippets.

@saitonakamura
Created January 15, 2021 19:28
Show Gist options
  • Save saitonakamura/e418757fbcba3dde637fbfad11d2dba6 to your computer and use it in GitHub Desktop.
Save saitonakamura/e418757fbcba3dde637fbfad11d2dba6 to your computer and use it in GitHub Desktop.
Will return url of latest asset in given repository filtering asset by 2 substring patterns
# Will return url of latest asset in given repository filtering asset by 2 substring patterns
# e.g. get-github-latest-release ogham/exa exa-linux x86_64
# will returns https://github.com/ogham/exa/releases/download/v0.9.0/exa-linux-x86_64-0.9.0.zip
get-github-latest-release() {
curl -s -L "https://api.github.com/repos/$1/releases/latest" | \
jq ".assets[] | select(.name | contains(\"$2\") and contains(\"$3\")) | .browser_download_url" --raw-output
}
# Example of usage by installing exa
# curl -L "$(get-github-latest-release ogham/exa exa-linux x86_64)" -o /tmp/exa.zip
# unzip -d ~/.local/bin /tmp/exa.zip
# mv ~/.local/bin/exa-linux-x86_64 ~/.local/bin/exa
# rm /tmp/exa.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment