Adding target to get the latest mmctl release from GitHub (#13770)
* Updating build and release process to include externally built mmctl * Missed last commit before reset * rename script to align with purpose * Moving get release script to scripts dir
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d7206d2ede
Коммит
acce0da068
34
Makefile
34
Makefile
@@ -1,7 +1,13 @@
|
|||||||
.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins
|
.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests diff-config prepackaged-plugins prepackaged-binaries
|
||||||
|
|
||||||
ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
PLATFORM := Windows
|
||||||
|
else
|
||||||
|
PLATFORM := $(shell uname)
|
||||||
|
endif
|
||||||
|
|
||||||
IS_CI ?= false
|
IS_CI ?= false
|
||||||
MM_NO_DOCKER ?= false
|
MM_NO_DOCKER ?= false
|
||||||
# Build Flags
|
# Build Flags
|
||||||
@@ -94,6 +100,7 @@ PLUGIN_PACKAGES += mattermost-plugin-jira-v2.3.2
|
|||||||
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.0.1
|
PLUGIN_PACKAGES += mattermost-plugin-gitlab-v1.0.1
|
||||||
PLUGIN_PACKAGES += mattermost-plugin-jenkins-v1.0.0
|
PLUGIN_PACKAGES += mattermost-plugin-jenkins-v1.0.0
|
||||||
|
|
||||||
|
|
||||||
# Prepares the enterprise build if exists. The IGNORE stuff is a hack to get the Makefile to execute the commands outside a target
|
# Prepares the enterprise build if exists. The IGNORE stuff is a hack to get the Makefile to execute the commands outside a target
|
||||||
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
||||||
IGNORE:=$(shell echo Enterprise build selected, preparing)
|
IGNORE:=$(shell echo Enterprise build selected, preparing)
|
||||||
@@ -113,9 +120,13 @@ else
|
|||||||
ALL_PACKAGES=$(TE_PACKAGES)
|
ALL_PACKAGES=$(TE_PACKAGES)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
all: run ## Alias for 'run'.
|
all: run ## Alias for 'run'.
|
||||||
|
|
||||||
|
# Decide what version of prebuilt binaries to download. This will use the release-* branch names or change to the latest.
|
||||||
|
# The second sed will look for v<NUM>.<NUM>* and if its not found replace it with the word latest
|
||||||
|
LATEST_RELEASE_MMCTL = $(shell scripts/get_latest_release.sh 'mattermost/mmctl')
|
||||||
|
REL_TO_DOWNLOAD = $(shell git rev-parse --abbrev-ref HEAD | sed 's/release-/v/' | sed '/v\([0-9]\)\./! s/\(.*\)/$(LATEST_RELEASE_MMCTL)/')
|
||||||
|
|
||||||
include build/*.mk
|
include build/*.mk
|
||||||
|
|
||||||
start-docker: ## Starts the docker containers for local development.
|
start-docker: ## Starts the docker containers for local development.
|
||||||
@@ -161,6 +172,23 @@ prepackaged-plugins: ## Populate the prepackaged-plugins directory
|
|||||||
curl -f -O -L https://plugins-store.test.mattermost.com/release/$$plugin_package.tar.gz.sig; \
|
curl -f -O -L https://plugins-store.test.mattermost.com/release/$$plugin_package.tar.gz.sig; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
prepackaged-binaries: ## Populate the prepackaged-binaries to the bin directory
|
||||||
|
# Externally built binaries
|
||||||
|
ifeq ($(shell test -f bin/mmctl && echo -n yes),yes)
|
||||||
|
@echo mmctl installed
|
||||||
|
else ifeq ($(PLATFORM),Darwin)
|
||||||
|
@echo Downloading prepackaged binary: https://github.com/mattermost/mmctl/releases/$(REL_TO_DOWNLOAD)
|
||||||
|
@MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(GOBIN) && rm $$MMCTL_FILE
|
||||||
|
else ifeq ($(PLATFORM),Linux)
|
||||||
|
@echo Downloading prepackaged binary: https://github.com/mattermost/mmctl/releases/$(REL_TO_DOWNLOAD)
|
||||||
|
@MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(GOBIN) && rm $$MMCTL_FILE
|
||||||
|
else ifeq ($(PLATFORM),Windows)
|
||||||
|
@echo Downloading prepackaged binary: https://github.com/mattermost/mmctl/releases/$(REL_TO_DOWNLOAD)
|
||||||
|
@MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && unzip -o $$MMCTL_FILE -d $(DIST_PATH)/bin && rm $$MMCTL_FILE
|
||||||
|
else
|
||||||
|
@echo "mmctl error: can't detect OS"
|
||||||
|
endif
|
||||||
|
|
||||||
golangci-lint: ## Run golangci-lint on codebase
|
golangci-lint: ## Run golangci-lint on codebase
|
||||||
# https://stackoverflow.com/a/677212/1027058 (check if a command exists or not)
|
# https://stackoverflow.com/a/677212/1027058 (check if a command exists or not)
|
||||||
@if ! [ -x "$$(command -v golangci-lint)" ]; then \
|
@if ! [ -x "$$(command -v golangci-lint)" ]; then \
|
||||||
@@ -311,7 +339,7 @@ validate-go-version: ## Validates the installed version of go against Mattermost
|
|||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run-server: validate-go-version start-docker ## Starts the server.
|
run-server: prepackaged-binaries validate-go-version start-docker ## Starts the server.
|
||||||
@echo Running mattermost for development
|
@echo Running mattermost for development
|
||||||
|
|
||||||
mkdir -p $(BUILD_WEBAPP_DIR)/dist/files
|
mkdir -p $(BUILD_WEBAPP_DIR)/dist/files
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ endif
|
|||||||
done; \
|
done; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
@# ----- PLATFORM SPECIFIC -----
|
@# ----- PLATFORM SPECIFIC -----
|
||||||
|
|
||||||
@# Make osx package
|
@# Make osx package
|
||||||
@@ -101,6 +102,7 @@ else
|
|||||||
cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
|
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
|
cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
|
||||||
endif
|
endif
|
||||||
|
MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
|
||||||
@# Prepackage plugins
|
@# Prepackage plugins
|
||||||
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
||||||
ARCH="osx-amd64"; \
|
ARCH="osx-amd64"; \
|
||||||
@@ -122,6 +124,7 @@ endif
|
|||||||
@# Cleanup
|
@# Cleanup
|
||||||
rm -f $(DIST_PATH)/bin/mattermost
|
rm -f $(DIST_PATH)/bin/mattermost
|
||||||
rm -f $(DIST_PATH)/bin/platform
|
rm -f $(DIST_PATH)/bin/platform
|
||||||
|
rm -f $(DIST_PATH)/bin/mmctl
|
||||||
rm -f $(DIST_PATH)/prepackaged_plugins/*
|
rm -f $(DIST_PATH)/prepackaged_plugins/*
|
||||||
|
|
||||||
@# Make windows package
|
@# Make windows package
|
||||||
@@ -133,6 +136,7 @@ else
|
|||||||
cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
|
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
|
cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
|
||||||
endif
|
endif
|
||||||
|
MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && unzip -o $$MMCTL_FILE -d $(DIST_PATH)/bin && rm $$MMCTL_FILE
|
||||||
@# Prepackage plugins
|
@# Prepackage plugins
|
||||||
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
||||||
ARCH="windows-amd64"; \
|
ARCH="windows-amd64"; \
|
||||||
@@ -154,6 +158,7 @@ endif
|
|||||||
@# Cleanup
|
@# Cleanup
|
||||||
rm -f $(DIST_PATH)/bin/mattermost.exe
|
rm -f $(DIST_PATH)/bin/mattermost.exe
|
||||||
rm -f $(DIST_PATH)/bin/platform.exe
|
rm -f $(DIST_PATH)/bin/platform.exe
|
||||||
|
rm -f $(DIST_PATH)/bin/mmctl.exe
|
||||||
rm -f $(DIST_PATH)/prepackaged_plugins/*
|
rm -f $(DIST_PATH)/prepackaged_plugins/*
|
||||||
|
|
||||||
@# Make linux package
|
@# Make linux package
|
||||||
@@ -165,6 +170,7 @@ else
|
|||||||
cp $(GOBIN)/linux_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
|
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
|
cp $(GOBIN)/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
|
||||||
endif
|
endif
|
||||||
|
MMCTL_FILE="linux_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
|
||||||
@# Prepackage plugins
|
@# Prepackage plugins
|
||||||
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
|
||||||
ARCH="linux-amd64"; \
|
ARCH="linux-amd64"; \
|
||||||
|
|||||||
14
scripts/get_latest_release.sh
Исполняемый файл
14
scripts/get_latest_release.sh
Исполняемый файл
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Time: 2020-01-29 14:49:24
|
||||||
|
# Author: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
|
||||||
|
get_latest_release() {
|
||||||
|
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
|
||||||
|
grep '"tag_name":' | # Get tag line
|
||||||
|
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
|
||||||
|
}
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
# $ get_latest_release "creationix/nvm"
|
||||||
|
# v0.31.4
|
||||||
|
# Assume we are in a git dir
|
||||||
|
get_latest_release $1
|
||||||
Ссылка в новой задаче
Block a user