update scripts folder
Change steamcmd recommended to debian-buster-slim Update release grabber with curly braces on variables (readability). Add script for validating that download links actually exist with no errors. update gitignore.
This commit is contained in:
@@ -3,26 +3,25 @@
|
||||
## this supports using oauth/personal access tokens via GITHUB_USER and GITHUB_OAUTH_TOKEN (both are required.)
|
||||
## if you are getting hit with GitHub API limit issues then you need to have the user and token set.
|
||||
|
||||
|
||||
if [ -z "$GITHUB_USER" ] && [ -z "$GITHUB_OAUTH_TOKEN" ] ; then
|
||||
if [ -z "${GITHUB_USER}" ] && [ -z "${GITHUB_OAUTH_TOKEN}" ] ; then
|
||||
echo -e "using anon api call"
|
||||
else
|
||||
echo -e "user and oauth token set"
|
||||
alias curl='curl -u $GITHUB_USER:$GITHUB_OAUTH_TOKEN '
|
||||
alias curl='curl -u ${GITHUB_USER}:${GITHUB_OAUTH_TOKEN} '
|
||||
fi
|
||||
|
||||
## get release info and download links
|
||||
LATEST_JSON=$(curl --silent "https://api.github.com/repos/$GITHUB_PACKAGE/releases/latest")
|
||||
RELEASES=$(curl --silent "https://api.github.com/repos/$GITHUB_PACKAGE/releases")
|
||||
LATEST_JSON=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases/latest")
|
||||
RELEASES=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases")
|
||||
|
||||
if [ -z "$VERSION" ] || [ "$VERSION" == "latest" ]; then
|
||||
DOWNLOAD_LINK=$(echo $LATEST_JSON | jq .assets | jq -r .[].browser_download_url | grep -i ${MATCH})
|
||||
if [ -z "${VERSION}" ] || [ "${VERSION}" == "latest" ]; then
|
||||
DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url | grep -i ${MATCH})
|
||||
else
|
||||
VERSION_CHECK=$(echo $RELEASES | jq -r --arg VERSION "$VERSION" '.[] | select(.tag_name==$VERSION) | .tag_name')
|
||||
if [ "$VERSION" == "$VERSION_CHECK" ]; then
|
||||
DOWNLOAD_LINK=$(echo $RELEASES | jq -r --arg VERSION "$VERSION" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -i ${MATCH})
|
||||
VERSION_CHECK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .tag_name')
|
||||
if [ "${VERSION}" == "${VERSION_CHECK}" ]; then
|
||||
DOWNLOAD_LINK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -i ${MATCH})
|
||||
else
|
||||
echo -e "defaulting to latest release"
|
||||
DOWNLOAD_LINK=$(echo $LATEST_JSON | jq .assets | jq -r .[].browser_download_url)
|
||||
DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url)
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user