Update to get latest release from S3 (#15952)

* Update to get latest release from S3

* Update mmctl to download to use S3

* Download MMCTL from S3

* Update download_mmctl_release.sh

* Update Makefile

* Update release.mk

* Update the script called, remove call to sub shell and clean up indentation

* Add quotes around THIS_BRANCH var

* Update script to support overriding the OS for packaging

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Jason Paul Deland
2020-10-16 20:27:50 -04:00
committed by GitHub
parent 9b1dee7087
commit e280aa1c63
3 changed files with 34 additions and 17 deletions

View File

@@ -188,14 +188,9 @@ prepackaged-plugins: ## Populate the prepackaged-plugins directory
prepackaged-binaries: ## Populate the prepackaged-binaries to the bin directory
ifeq ($(shell test -f bin/mmctl && printf "yes"),yes)
@echo "mmctl already exists in bin/mmctl not downloading a new version."
@echo "MMCTL already exists in bin/mmctl not downloading a new version."
else
@MMCTL_VERSION=$$(scripts/get_latest_release.sh mattermost/mmctl release-); if [ $$? -eq 0 ]; then \
scripts/download_mmctl_release.sh $$MMCTL_VERSION; \
else \
echo $$MMCTL_VERSION; \
exit 1; \
fi;
@scripts/download_mmctl_release.sh
endif
golangci-lint: ## Run golangci-lint on codebase

View File

@@ -97,8 +97,8 @@ package:
mkdir -p $(DIST_PATH)/client
cp -RL $(BUILD_WEBAPP_DIR)/dist/* $(DIST_PATH)/client
$(eval MMCTL_REL_TO_DOWNLOAD := $(shell scripts/get_latest_release.sh 'mattermost/mmctl' 'release-'))
@echo "Using mmctl version $(MMCTL_REL_TO_DOWNLOAD)"
@#Download MMCTL
scripts/download_mmctl_release.sh
@# Help files
ifeq ($(BUILD_ENTERPRISE_READY),true)
@@ -133,7 +133,8 @@ else
cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
endif
MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
#Download MMCTL for OSX
scripts/download_mmctl_release.sh "Darwin"
@# Prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
ARCH="osx-amd64"; \
@@ -167,7 +168,8 @@ else
cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
endif
MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && unzip -o $$MMCTL_FILE -d $(DIST_PATH)/bin && rm $$MMCTL_FILE
#Download MMCTL for Windows
scripts/download_mmctl_release.sh "Windows"
@# Prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
ARCH="windows-amd64"; \
@@ -201,7 +203,8 @@ else
cp $(GOBIN)/linux_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
endif
MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
#Download MMCTL for Linux
scripts/download_mmctl_release.sh "Linux"
@# Prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
ARCH="linux-amd64"; \

View File

@@ -8,22 +8,41 @@ else
PLATFORM=$(uname)
fi
if [[ ! -z "$1" ]];
then
OVERRIDE_OS=$1
fi
# strip whitespace
RELEASE_TO_DOWNLOAD=$(echo "$1" | xargs echo)
echo "Downloading prepackaged binary: https://github.com/mattermost/mmctl/releases/$RELEASE_TO_DOWNLOAD";
THIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$THIS_BRANCH" =~ 'release-' ]];
then
RELEASE_TO_DOWNLOAD="$THIS_BRANCH"
else
RELEASE_TO_DOWNLOAD=master
fi
echo "Downloading prepackaged binary: https://releases.mattermost.com/mmctl/$RELEASE_TO_DOWNLOAD";
# When packaging we need to download different platforms
# Values need to match the case statement below
if [[ ! -z "$OVERRIDE_OS" ]];
then
PLATFORM="$OVERRIDE_OS"
fi
case "$PLATFORM" in
Linux)
MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C bin && rm "$MMCTL_FILE";
MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C bin && rm "$MMCTL_FILE";
;;
Darwin)
MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C bin && rm "$MMCTL_FILE";
MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && tar -xvf "$MMCTL_FILE" -C bin && rm "$MMCTL_FILE";
;;
Windows)
MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && unzip -o "$MMCTL_FILE" -d bin && rm "$MMCTL_FILE";
MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://releases.mattermost.com/mmctl/"$RELEASE_TO_DOWNLOAD"/"$MMCTL_FILE" && unzip -o "$MMCTL_FILE" -d bin && rm "$MMCTL_FILE";
;;
*)