From 27d4ddacd98518d8bc751026311926cdf156936f Mon Sep 17 00:00:00 2001 From: ajanikow Date: Tue, 24 Sep 2019 19:47:38 +0000 Subject: [PATCH] Prepare release scripts --- Makefile | 4 ++++ scripts/patch_chart.sh | 32 ++++++++++++++++++++++++++++++++ scripts/patch_readme.sh | 5 ++--- tools/release/release.go | 18 ++++++++++++------ 4 files changed, 50 insertions(+), 9 deletions(-) create mode 100755 scripts/patch_chart.sh diff --git a/Makefile b/Makefile index 4acfad2d5..c9227dc1e 100644 --- a/Makefile +++ b/Makefile @@ -366,6 +366,10 @@ endif patch-readme: $(ROOTDIR)/scripts/patch_readme.sh $(VERSION_MAJOR_MINOR_PATCH) +.PHONY: patch-chart +patch-chart: + $(ROOTDIR)/scripts/patch_chart.sh "$(VERSION_MAJOR_MINOR_PATCH)" "$(OPERATORIMAGE)" + .PHONY: changelog changelog: docker run --rm \ diff --git a/scripts/patch_chart.sh b/scripts/patch_chart.sh new file mode 100755 index 000000000..9fa44ebf3 --- /dev/null +++ b/scripts/patch_chart.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Updates the versions in helm charts to reflect the current +# version. + +VERSION=$1 +IMAGE=$2 + +if [ -z $VERSION ]; then + echo "Specify a version argument" + exit 1 +fi + +function replaceInFile { + local EXPR=$1 + local FILE=$2 + case $(uname) in + Darwin) + sed -e "${EXPR}" -i "" ${FILE} + ;; + *) + sed -i --expression "${EXPR}" ${FILE} + ;; + esac +} + +for f in kube-arangodb kube-arangodb-crd kube-arangodb-test; do + replaceInFile "s@^version: .*\$@version: ${VERSION}@g" "chart/${f}/Chart.yaml" + if [[ -f "chart/${f}/values.yaml" ]]; then + replaceInFile "s@^ image: .*\$@ image: ${IMAGE}@g" "chart/${f}/values.yaml" + fi +done \ No newline at end of file diff --git a/scripts/patch_readme.sh b/scripts/patch_readme.sh index 73aaa4228..43a6fc935 100755 --- a/scripts/patch_readme.sh +++ b/scripts/patch_readme.sh @@ -30,6 +30,5 @@ replaceInFile "s@^kubectl apply -f https://raw.githubusercontent.com/arangodb/ku replaceInFile "s@^kubectl apply -f https://raw.githubusercontent.com/arangodb/kube-arangodb/.*/manifests/arango-deployment-replication.yaml\$@kubectl apply -f https://raw.githubusercontent.com/arangodb/kube-arangodb/${VERSION}/manifests/arango-deployment-replication.yaml@g" ${f} replaceInFile "s@^kubectl apply -f https://raw.githubusercontent.com/arangodb/kube-arangodb/.*/manifests/arango-storage.yaml\$@kubectl apply -f https://raw.githubusercontent.com/arangodb/kube-arangodb/${VERSION}/manifests/arango-storage.yaml@g" ${f} -replaceInFile "s@^helm install https://github.com/arangodb/kube-arangodb/releases/download/.*/kube-arangodb-crd.tgz\$@helm install https://github.com/arangodb/kube-arangodb/releases/download/${VERSION}/kube-arangodb-crd.tgz@g" ${f} -replaceInFile "s@^helm install https://github.com/arangodb/kube-arangodb/releases/download/.*/kube-arangodb.tgz\$@helm install https://github.com/arangodb/kube-arangodb/releases/download/${VERSION}/kube-arangodb.tgz@g" ${f} -replaceInFile "s@^helm install https://github.com/arangodb/kube-arangodb/releases/download/.*/kube-arangodb-storage.tgz\$@helm install https://github.com/arangodb/kube-arangodb/releases/download/${VERSION}/kube-arangodb-storage.tgz@g" ${f} +replaceInFile "s@https://github.com/arangodb/kube-arangodb/releases/download/.*/kube-arangodb-crd\(-[0-9]+\.[0-9]+\.[0-9]+\)\?.tgz@https://github.com/arangodb/kube-arangodb/releases/download/${VERSION}/kube-arangodb-crd-${VERSION}.tgz@g" ${f} +replaceInFile "s@https://github.com/arangodb/kube-arangodb/releases/download/.*/kube-arangodb\(-[0-9]+\.[0-9]+\.[0-9]+\)\?.tgz@https://github.com/arangodb/kube-arangodb/releases/download/${VERSION}/kube-arangodb-${VERSION}.tgz@g" ${f} diff --git a/tools/release/release.go b/tools/release/release.go index 9ece3e682..ddd479caa 100644 --- a/tools/release/release.go +++ b/tools/release/release.go @@ -45,11 +45,7 @@ var ( ghRepo string // Github repository name to create release in binFolder string // Folder containing binaries - binaries = map[string]string{ - "kube-arangodb.tgz": "charts/kube-arangodb.tgz", - "kube-arangodb-storage.tgz": "charts/kube-arangodb-storage.tgz", - "kube-arangodb-crd.tgz": "charts/kube-arangodb-crd.tgz", - } + binaries map[string]string ) func init() { @@ -66,14 +62,24 @@ func main() { ensureGithubToken() checkCleanRepo() version := bumpVersion(releaseType) + binaries = map[string]string{ + fmt.Sprintf("kube-arangodb-%s.tgz", version): fmt.Sprintf("charts/kube-arangodb-%s.tgz", version), + fmt.Sprintf("kube-arangodb-crd-%s.tgz", version): fmt.Sprintf("charts/kube-arangodb-crd-%s.tgz", version), + } make("clean", nil) + make("patch-readme", nil) + make("patch-chart", map[string]string{ + "ALLOWCHAOS": "false", + "DOCKERNAMESPACE": "arangodb", + "IMAGETAG": version, + "MANIFESTSUFFIX": "-", + }) make("all", map[string]string{ "ALLOWCHAOS": "false", "DOCKERNAMESPACE": "arangodb", "IMAGETAG": version, "MANIFESTSUFFIX": "-", }) - make("patch-readme", nil) make("build-ghrelease", nil) createSHA256Sums() gitCommitAll(fmt.Sprintf("Updated manifest to %s", version)) // Commit manifest