Downloading the latest release of a project from GitHub
#!/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