From 0da164f70e401f1a1073c5ff06e20872056d019a Mon Sep 17 00:00:00 2001 From: Jason Paul Deland <9366595+jaydeland@users.noreply.github.com> Date: Mon, 31 Aug 2020 13:13:51 -0400 Subject: [PATCH] Update mmtcl download to account for Drat releases (#14363) --- scripts/get_latest_release.sh | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/scripts/get_latest_release.sh b/scripts/get_latest_release.sh index b77be0e5bd..fb33c8e040 100755 --- a/scripts/get_latest_release.sh +++ b/scripts/get_latest_release.sh @@ -7,26 +7,13 @@ REPO_TO_USE=$1 BRANCH_TO_USE=$2 -BASIC_AUTH="" - -# If we find a github username and token, we use that. -# In CI, these variables are available and useful to avoid rate limits which is -# much more strict for unauthenticated requests. -if [[ $GITHUB_USERNAME != "" && $GITHUB_TOKEN != "" ]]; -then - BASIC_AUTH="--user $GITHUB_USERNAME:$GITHUB_TOKEN" -fi - -LATEST_REL=$(curl \ - --silent \ - $BASIC_AUTH \ - "https://api.github.com/repos/$REPO_TO_USE/releases/latest" \ - | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +LATEST_REL=$(curl --silent "https://api.github.com/repos/$REPO_TO_USE/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') +DRAFT=$(curl --silent "https://api.github.com/repos/$REPO_TO_USE/releases/latest" | grep '"draft":' | sed -E 's/.*: ([^,]+).*/\1/') # Check if this is a release branch THIS_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ $(echo "$THIS_BRANCH" | grep -c ^"$BRANCH_TO_USE") == 1 ]]; +if [[ "$THIS_BRANCH" =~ $BRANCH_TO_USE || $DRAFT =~ "true" ]]; then VERSION_REL=${THIS_BRANCH//$BRANCH_TO_USE/v} REL_TO_USE=$(curl --silent $BASIC_AUTH "https://api.github.com/repos/$REPO_TO_USE/releases" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed -n "/$VERSION_REL/p" | sort -rV | head -n 1)