Skip to content

Commit 1b2b0c5

Browse files
committed
Improve release scripts for patch releases
1 parent 42f8571 commit 1b2b0c5

3 files changed

Lines changed: 37 additions & 12 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66

7-
VERSION ?= 1.23.0
7+
VERSION ?= 1.22.4
88

99
COMMIT := $(shell git rev-parse --short HEAD)
1010
DATE := $(shell date +%Y%m%d)

scripts/post-release-process.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ KUSTOMIZE=$(pwd)/bin/kustomize
1010
# Add new ## unreleased after the tagging (post-release-process.sh)
1111
gawk -i inplace '/##/ && ++c==1 { print "## unreleased\n"; print; next }1' CHANGELOG.md
1212

13+
CURRENT_BRANCH=$(git branch --show-current)
14+
15+
if [ $CURRENT_BRANCH != "master" ]; then
16+
# This is a release branch, we only bump the patch version
17+
PATCH_RELEASE=true
18+
scripts/update-makefile-version.sh
19+
NEXT_VERSION=$(gawk 'match($0, /^VERSION \?= /) { print substr($0, RLENGTH+1)}' Makefile)
20+
git add Makefile
21+
git add CHANGELOG.md
22+
git commit -m "Prepare for next version $NEXT_VERSION"
23+
return
24+
fi
25+
1326
# Modify Makefile for the next VERSION in line
1427
scripts/update-makefile-version.sh
1528

@@ -27,8 +40,6 @@ yq eval -i '.defaults.cassandra.repository |= sub("cr.k8ssandra.io/", "")' confi
2740
yq eval -i '.images.config-builder |= sub("cr.dtsx.io/", "")' config/manager/image_config.yaml
2841
yq eval -i '.defaults.dse.repository |= sub("cr.dtsx.io/", "")' config/manager/image_config.yaml
2942

30-
31-
3243
# Commit to git
3344
NEXT_VERSION=$(gawk 'match($0, /^VERSION \?= /) { print substr($0, RLENGTH+1)}' Makefile)
3445

scripts/pre-release-process.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ if [[ ! $0 == scripts/* ]]; then
55
fi
66

77
if [ "$#" -le 1 ]; then
8-
echo "Usage: scripts/pre-release-process.sh newTag"
8+
echo "Usage: scripts/pre-release-process.sh newTag [prevTag]"
9+
echo ""
10+
echo "If prevTag is not set, it will default to the latest tag in the repository"
11+
echo "usage of prevTag is required when releasing a patch version from a branch"
912
exit
1013
fi
1114

15+
CURRENT_BRANCH=$(git branch --show-current)
16+
17+
if [[ $CURRENT_BRANCH != "master" && -z "$2" ]]; then
18+
echo "You must provide a prevTag when releasing from a branch"
19+
exit 1
20+
fi
21+
1222
TAG=$1
1323
PREVTAG=$(git describe --abbrev=0 --tags)
1424
IMG=cr.k8ssandra.io/k8ssandra/cass-operator:${TAG}
@@ -32,16 +42,20 @@ sed -i '' -e "s/$PREVTAG/$TAG/g" README.md
3242
cd config/manager && $KUSTOMIZE edit set image controller=$IMG && cd -
3343

3444
# Modify config/manager/image_config.yaml to have proper version for server-system-logger
35-
LOG_IMG=k8ssandra/system-logger:${TAG} yq eval -i '.images.system-logger = env(LOG_IMG)' config/manager/image_config.yaml
45+
LOG_IMG=k8ssandra/system-logger:${TAG} yq eval -i '.images.system-logger = "cr.k8ssandra.io/" + env(LOG_IMG)' config/manager/image_config.yaml
46+
47+
# Add prefixes to image_config if not already set
48+
CLIENT_VALUE=$(yq '.images.k8ssandra-client' config/manager/image_config.yaml)
3649

37-
# Add cr.k8ssandra.io prefixes
38-
yq eval -i '.images.system-logger |= "cr.k8ssandra.io/" + .' config/manager/image_config.yaml
39-
yq eval -i '.images.k8ssandra-client |= "cr.k8ssandra.io/" + .' config/manager/image_config.yaml
40-
yq eval -i '.defaults.cassandra.repository |= "cr.k8ssandra.io/" + .' config/manager/image_config.yaml
50+
if [[ ! $CLIENT_VALUE == cr.k8ssandra.io* ]]; then
51+
# Add cr.k8ssandra.io prefixes
52+
yq eval -i '.images.k8ssandra-client |= "cr.k8ssandra.io/" + .' config/manager/image_config.yaml
53+
yq eval -i '.defaults.cassandra.repository |= "cr.k8ssandra.io/" + .' config/manager/image_config.yaml
4154

42-
# Add cr.dstx.io prefixes
43-
yq eval -i '.images.config-builder |= "cr.dtsx.io/" + .' config/manager/image_config.yaml
44-
yq eval -i '.defaults.dse.repository |= "cr.dtsx.io/" + .' config/manager/image_config.yaml
55+
# Add cr.dstx.io prefixes
56+
yq eval -i '.images.config-builder |= "cr.dtsx.io/" + .' config/manager/image_config.yaml
57+
yq eval -i '.defaults.dse.repository |= "cr.dtsx.io/" + .' config/manager/image_config.yaml
58+
fi
4559

4660
# Modify the controller
4761

0 commit comments

Comments
 (0)