From 920c1f00eb6164b25f79b42c1c8aa9ec5ce9515e Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com> Date: Tue, 16 May 2023 10:01:39 +0800 Subject: [PATCH] feat: provide the function and design scheme of release Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- script/make-rules/golang.mk | 1 + script/make-rules/release.mk | 41 ++++++++++++++++++++++++++++++++++++ script/make-rules/tools.mk | 15 ++++++++++++- script/push_start.sh | 1 + script/release.sh | 22 +++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 script/make-rules/release.mk create mode 100644 script/release.sh diff --git a/script/make-rules/golang.mk b/script/make-rules/golang.mk index 0ba807342..50be587d2 100644 --- a/script/make-rules/golang.mk +++ b/script/make-rules/golang.mk @@ -18,6 +18,7 @@ + ## copyright.help: Show copyright help .PHONY: go.help go.help: script/make-rules/golang.mk diff --git a/script/make-rules/release.mk b/script/make-rules/release.mk new file mode 100644 index 000000000..55cb0f416 --- /dev/null +++ b/script/make-rules/release.mk @@ -0,0 +1,41 @@ +# Copyright © 2023 OpenIMSDK. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ============================================================================== +# Makefile helper functions for release +# + +## release: release the project +.PHONY: release.run +release.run: release.verify release.ensure-tag + @scripts/release.sh + +## release.verify: Check if a tool is installed and install it +.PHONY: release.verify +release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd + +## release.tag: release the project +.PHONY: release.tag +release.tag: tools.verify.gsemver release.ensure-tag + @git push origin `git describe --tags --abbrev=0` + +## release.ensure-tag: ensure tag +.PHONY: release.ensure-tag +release.ensure-tag: tools.verify.gsemver + @scripts/ensure_tag.sh + +## release.help: Display help information about the release package +.PHONY: release.help +release.help: script/make-rules/release.mk + $(call smallhelp) \ No newline at end of file diff --git a/script/make-rules/tools.mk b/script/make-rules/tools.mk index 7bed9c178..2c6689668 100644 --- a/script/make-rules/tools.mk +++ b/script/make-rules/tools.mk @@ -25,12 +25,14 @@ ANALYSIS_TOOLS = golangci-lint goimports golines go-callvis kube-score GENERATION_TOOLS = deepcopy-gen conversion-gen protoc-gen-go cfssl rts codegen # Testing tools TEST_TOOLS = ginkgo go-junit-report gotests +# cos tools +COS_TOOLS = coscli coscmd # Version control tools VERSION_CONTROL_TOOLS = addlicense go-gitlint git-chglog github-release gsemver # Utility tools UTILITY_TOOLS = go-mod-outdated mockgen gothanks richgo kubeconform # All tools -ALL_TOOLS ?= $(ANALYSIS_TOOLS) $(GENERATION_TOOLS) $(TEST_TOOLS) $(VERSION_CONTROL_TOOLS) $(UTILITY_TOOLS) +ALL_TOOLS ?= $(ANALYSIS_TOOLS) $(GENERATION_TOOLS) $(TEST_TOOLS) $(VERSION_CONTROL_TOOLS) $(UTILITY_TOOLS) $(COS_TOOLS) ## tools.install: Install a must tools .PHONY: tools.install @@ -129,6 +131,17 @@ install.git-chglog: install.github-release: @$(GO) install github.com/github-release/github-release@latest +## install.coscli: Install coscli, used to upload files to cos +.PHONY: install.coscli +install.coscli: + @wget -q https://github.com/tencentyun/coscli/releases/download/v0.10.2-beta/coscli-linux -O ${HOME}/bin/coscli + @chmod +x ${HOME}/bin/coscli + +## install.coscmd: Install coscmd, used to upload files to cos +.PHONY: install.coscmd +install.coscmd: + @if which pip &>/dev/null; then pip install coscmd; else pip3 install coscmd; fi + ## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool. .PHONY: install.gvm install.gvm: diff --git a/script/push_start.sh b/script/push_start.sh index cbaffe7be..be34903ec 100755 --- a/script/push_start.sh +++ b/script/push_start.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + #Include shell font styles and some basic information source ./style_info.cfg source ./path_info.cfg diff --git a/script/release.sh b/script/release.sh new file mode 100644 index 000000000..bd6ef0ec4 --- /dev/null +++ b/script/release.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Copyright © 2023 OpenIMSDK. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ============================================================================== +# Makefile helper functions for release +# +# Build a OpenIM release. This will build the binaries, create the Docker +# images and other build artifacts. +