Update mmtcl download to account for Drat releases (#14363)

This commit is contained in:
Jason Paul Deland
2020-08-31 13:13:51 -04:00
committed by GitHub
parent 9b688ae971
commit 0da164f70e

View File

@@ -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)