diff --git a/Makefile b/Makefile index af406c1363..c200a5a623 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,7 @@ ALL_PACKAGES=$(TE_PACKAGES) endif # Decide what version of prebuilt binaries to download. This will use the release-* branch names or change to the latest. -MMCTL_REL_TO_DOWNLOAD = $(shell scripts/get_latest_release.sh 'mattermost/mmctl' 'release-') +MMCTL_REL_TO_DOWNLOAD:=$(shell scripts/get_latest_release.sh 'mattermost/mmctl' 'release-') all: run ## Alias for 'run'. diff --git a/scripts/get_latest_release.sh b/scripts/get_latest_release.sh index 25356d1114..b0e5c125ba 100755 --- a/scripts/get_latest_release.sh +++ b/scripts/get_latest_release.sh @@ -12,7 +12,7 @@ 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 != "" ]]; +if [[ ! -z "$GITHUB_USERNAME" && ! -z "$GITHUB_TOKEN" ]]; then BASIC_AUTH="--user $GITHUB_USERNAME:$GITHUB_TOKEN" fi @@ -44,7 +44,7 @@ if [[ "$THIS_BRANCH" =~ $BRANCH_TO_USE || $DRAFT =~ "true" ]]; then 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) elif [[ "$THIS_BRANCH" =~ "master" ]]; then # Get the latest release even if its a pre-release - REL_TO_USE=$(curl --silent $BASIC_AUTH" https://api.github.com/repos/$REPO_TO_USE/releases" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sort -rV | head -n 1) + REL_TO_USE=$(curl --silent $BASIC_AUTH "https://api.github.com/repos/$REPO_TO_USE/releases" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sort -rV | head -n 1) else REL_TO_USE=$LATEST_REL fi