Last active
April 9, 2020 23:03
-
-
Save rtrouton/11bc3f21f47e1a79d099 to your computer and use it in GitHub Desktop.
Downloading the latest release of a project from GitHub
This file contains hidden or 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
#!/bin/bash | |
# How to set these variables: | |
# | |
# GitHub_Owner | |
# GitHub_Repo | |
# | |
# Example use: | |
# | |
# The Linde Group has repos on GitHub available | |
# via https://github.com/lindegroup | |
# To set the Linde Group as the owner, | |
# set the following: | |
# GitHub_Owner="lindegroup" | |
# | |
# If you want to get the latest release of | |
# the Linde Group's AutoPkgr software, the | |
# repo which has AutoPkgr is named "autopkgr". | |
# The Linde Group has set up releases for AutoPkgr, | |
# so set the following: | |
# GitHub_Repo="autopkgr" | |
# | |
GitHub_Owner="repo_owner_goes_here" | |
GitHub_Repo="repo_name_goes_here" | |
# Specify a directory in /tmp to store the downloaded file | |
download_location=`/usr/bin/mktemp -d /tmp/$GitHub_Repo.XXXX` | |
GitHubProjectLatestRelease=$(/usr/bin/curl --silent https://api.github.com/repos/$GitHub_Owner/$GitHub_Repo/releases/latest | /usr/bin/awk '/browser_download_url/ { print $2 }' | /usr/bin/sed 's/"//g') | |
# Download latest release to the specified location in /tmp | |
cd $download_location;/usr/bin/curl -LOk "$GitHubProjectLatestRelease" | |
echo "Downloaded file is stored in $download_location." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment