Created
January 27, 2019 23:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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