Skip to content

Instantly share code, notes, and snippets.

@schuerg
Created January 27, 2019 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schuerg/1f6ff64ec6d52728884cc56a9a08d95f to your computer and use it in GitHub Desktop.
Save schuerg/1f6ff64ec6d52728884cc56a9a08d95f to your computer and use it in GitHub Desktop.
[Get latest GitHub release] Echo the release assets of a given GitHub repo to stdout #github #bash #linux
#!/usr/bin/env bash
#
# Echo the release assets of a given GitHub repo to stdout.
# First parameter is the repo in the form neovim/neovim
# It uses the latest release by default.
# An other release can be selected by the release id as second parameter.
#
# Example usage:
# github-latest-release neovim/neovim | grep "linux"
#
# Simon Schürg
# Use GitHub REST API to get the release
# This only works for GitHub Apps
if [ -n "${2}" ]; then
URL="https://api.github.com/repos/${1}/releases"
# echo ${URL}
curl --silent --location "${URL}" | grep "browser_download_url" | awk '{ print $2 }' | tr -d '"' | grep "${2}"
else
URL="https://api.github.com/repos/${1}/releases/latest"
# echo ${URL}
curl --silent --location "${URL}" | grep "browser_download_url" | awk '{ print $2 }' | tr -d '"'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment