Skip to content

Commit 8492a2e

Browse files
adwk67razvan
andauthored
Changes made during release 23.4 (#42)
Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent cca58a3 commit 8492a2e

File tree

4 files changed

+174
-8
lines changed

4 files changed

+174
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
olm/catalog.Dockerfile
33
olm/catalog/
44
olm/subscriptions/
5-
olm/catalog-source.yaml
5+
olm/catalog-source.yaml
6+
stackable-bcrypt/target

release/README.adoc

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release scripts
22

3-
A set of scripts that automates some release steps. The release process has three steps:
3+
A set of scripts that automates some release steps. The release process has multiple steps:
44

55
1. Call `create-release-branch.sh`- This will:
66
@@ -20,9 +20,10 @@ A set of scripts that automates some release steps. The release process has thre
2020
- commit and tag these changes
2121
- push the resulting commits and tags, triggering github actions to build the product images and operators
2222
23-
These steps are summarised in the two diagrams below:
23+
4. Call `post-release.sh`- This will:
2424
25-
image::images/rb-flow.png[]
25+
- update the operator CHANGELOG.md in `main` with changes from the release tag
26+
- create PRs for all operators
2627
2728
image::images/rb-utils.png[]
2829

@@ -128,6 +129,29 @@ e.g.
128129
** pushes the commit and tag (if requested with "-p")
129130
** deletes the temporary folder (if requested with "-c")
130131

132+
### Post-release steps
133+
134+
Some post release steps are performed with `release/post-release.sh` script, called from the repository root folder. The syntax is given below:
135+
136+
[source]
137+
----
138+
./release/post-release.sh -t <release-tag> [-p]
139+
----
140+
141+
- `-t <release-tag>`: the release tag (mandatory). This must be a semver-compatible value (i.e. major/minor/path, without leading zeros) such as `23.1.0`, `23.10.3` etc. and will be used to create a tag with the name
142+
- `-p`: push flag (optional, default is "false"). If provided, the created commits and tags made as part of this process will be pushed to the origin.
143+
144+
[source]
145+
----
146+
./release/create-release-tag.sh -t 23.1.0 -p -c
147+
----
148+
149+
#### What this script does
150+
151+
* checks that the release tag exists and that the all operator repositories have a clean working copy
152+
* merges the CHANGELOG.md from the release tag into main
153+
* creates PRs for all operators
154+
131155
#### Build actions
132156

133157
When a tag is pushed, the images for products and operators are built via github actions. The following points should be noted:

release/create-release-tag.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ tag_products() {
1818
# the release branch should already exist
1919
#-----------------------------------------------------------
2020
git switch "$RELEASE_BRANCH"
21-
# TODO where to conduct the tag-not-already-exists check?
21+
update_product_images_changelogs
22+
23+
git commit -am "release $RELEASE_TAG"
2224
git tag "$RELEASE_TAG"
2325
push_branch
2426
}
@@ -72,16 +74,19 @@ check_products() {
7274
cd "$TEMP_RELEASE_FOLDER/$DOCKER_IMAGES_REPO"
7375
#-----------------------------------------------------------
7476
# the up-to-date release branch has already been pulled
77+
# N.B. look for exact match (no -rcXXX)
7578
#-----------------------------------------------------------
76-
BRANCH_EXISTS=$(git branch -r | grep "$RELEASE_BRANCH")
79+
BRANCH_EXISTS=$(git branch -r | grep -E "$RELEASE_BRANCH$")
7780

7881
if [ -z "${BRANCH_EXISTS}" ]; then
7982
echo "Expected release branch is missing: $RELEASE_BRANCH"
8083
exit 1
8184
fi
8285

8386
git fetch --tags
84-
TAG_EXISTS=$(git tag -l | grep "$RELEASE_TAG")
87+
88+
# N.B. look for exact match (no -rcXXX)
89+
TAG_EXISTS=$(git tag -l | grep -E "$RELEASE_TAG&")
8590
if [ -n "$TAG_EXISTS" ]; then
8691
echo "Tag $RELEASE_TAG already exists in $DOCKER_IMAGES_REPO"
8792
exit 1
@@ -129,7 +134,7 @@ update_code() {
129134
# Not all operators have a getting started guide
130135
# that's why we verify if templating_vars.yaml exists.
131136
if [ -f "$1/docs/templating_vars.yaml" ]; then
132-
yq -i "(.versions.[] | select(. == \"*nightly\")) |= \"${RELEASE_TAG}\"" "$1/docs/templating_vars.yaml"
137+
yq -i "(.versions.[] | select(. == \"*dev\")) |= \"${RELEASE_TAG}\"" "$1/docs/templating_vars.yaml"
133138
yq -i ".helm.repo_name |= sub(\"stackable-dev\", \"stackable-stable\")" "$1/docs/templating_vars.yaml"
134139
yq -i ".helm.repo_url |= sub(\"helm-dev\", \"helm-stable\")" "$1/docs/templating_vars.yaml"
135140
fi
@@ -185,6 +190,11 @@ update_changelog() {
185190
sed -i "s/^.*unreleased.*/## [Unreleased]\n\n## [$RELEASE_TAG] - $TODAY/I" "$1"/CHANGELOG.md
186191
}
187192

193+
update_product_images_changelogs() {
194+
TODAY=$(date +'%Y-%m-%d')
195+
sed -i "s/^.*unreleased.*/## [Unreleased]\n\n## [$RELEASE_TAG] - $TODAY/I" ./**/CHANGELOG.md
196+
}
197+
188198
parse_inputs() {
189199
RELEASE_TAG=""
190200
PUSH=false

release/post-release.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env bash
2+
#
3+
# See README.adoc
4+
#
5+
set -euo pipefail
6+
set -x
7+
#-----------------------------------------------------------
8+
# tags should be semver-compatible e.g. 23.1.1 not 23.01.1
9+
# this is needed for cargo commands to work properly
10+
#-----------------------------------------------------------
11+
TAG_REGEX="^[0-9][0-9]\.([1-9]|[1][0-2])\.[0-9]+$"
12+
REPOSITORY="origin"
13+
14+
parse_inputs() {
15+
RELEASE_TAG=""
16+
PUSH=false
17+
18+
while [[ "$#" -gt 0 ]]; do
19+
case $1 in
20+
-t|--tag) RELEASE_TAG="$2"; shift ;;
21+
-p|--push) PUSH=true ;;
22+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
23+
esac
24+
shift
25+
done
26+
#-----------------------------------------------------------
27+
# remove leading and trailing quotes
28+
#-----------------------------------------------------------
29+
RELEASE_TAG="${RELEASE_TAG%\"}"
30+
RELEASE_TAG="${RELEASE_TAG#\"}"
31+
#----------------------------------------------------------------------------------------------------
32+
# for a tag of e.g. 23.1.1, the release branch (already created) will be 23.1
33+
#----------------------------------------------------------------------------------------------------
34+
RELEASE="$(cut -d'.' -f1,2 <<< "$RELEASE_TAG")"
35+
RELEASE_BRANCH="release-$RELEASE"
36+
37+
INITIAL_DIR="$PWD"
38+
TEMP_RELEASE_FOLDER="/tmp/stackable-$RELEASE_BRANCH"
39+
40+
echo "Settings: ${RELEASE_BRANCH}: Push: $PUSH"
41+
}
42+
43+
check_operators() {
44+
while IFS="" read -r operator || [ -n "$operator" ]
45+
do
46+
echo "Operator: $operator"
47+
if [ ! -d "$TEMP_RELEASE_FOLDER/${operator}" ]; then
48+
echo "Expected folder is missing: $TEMP_RELEASE_FOLDER/${operator}"
49+
exit 1
50+
fi
51+
52+
cd "$TEMP_RELEASE_FOLDER/${operator}"
53+
54+
DIRTY_WORKING_COPY=$(git status --short)
55+
if [ -n "${DIRTY_WORKING_COPY}" ]; then
56+
echo "Dirty working copy found for operator ${operator}"
57+
exit 1
58+
fi
59+
TAG_EXISTS=$(git tag | grep "$RELEASE_TAG")
60+
if [ -z "${BRANCH_EXISTS}" ]; then
61+
echo "Expected release branch is missing: ${operator}/$RELEASE_BRANCH"
62+
exit 1
63+
fi
64+
git fetch --tags
65+
TAG_EXISTS=$(git tag | grep "$RELEASE_TAG")
66+
if [ -z "${TAG_EXISTS}" ]; then
67+
echo "Expected tag $RELEASE_TAG missing for operator ${operator}"
68+
exit 1
69+
fi
70+
done < <(yq '... comments="" | .operators[] ' "$INITIAL_DIR"/release/config.yaml)
71+
}
72+
73+
update_main_changelog() {
74+
while IFS="" read -r operator || [ -n "$operator" ]
75+
do
76+
cd "$TEMP_RELEASE_FOLDER/${operator}"
77+
# New branch that updates the CHANGELOG
78+
CHANGELOG_BRANCH="update-changelog-from-release-$RELEASE_TAG"
79+
# Branch out from main
80+
git switch -c "$CHANGELOG_BRANCH" main
81+
# Checkout CHANGELOG changes from the release tag
82+
git checkout "$RELEASE_TAG" -- CHANGELOG.md
83+
# Ensure only the CHANGELOG has been modified and there
84+
# are no conflicts.
85+
CHANGELOG_MODIFIED=$(git status --short)
86+
if [ "M CHANGELOG.md" != "$CHANGELOG_MODIFIED" ]; then
87+
echo "Failed to update CHANGELOG.md in main for operator ${operator}"
88+
exit 1
89+
fi
90+
# Commit the updated CHANGELOG.
91+
git add CHANGELOG.md
92+
git commit -m "Update CHANGELOG.md from release $RELEASE_TAG"
93+
# Maybe push and create pull request
94+
if "$PUSH"; then
95+
git push -u "$REPOSITORY" "$CHANGELOG_BRANCH"
96+
gh pr create --fill --reviewer stackable/developers
97+
fi
98+
done < <(yq '... comments="" | .operators[] ' "$INITIAL_DIR"/release/config.yaml)
99+
}
100+
101+
102+
main() {
103+
parse_inputs "$@"
104+
#-----------------------------------------------------------
105+
# check if tag argument provided
106+
#-----------------------------------------------------------
107+
if [ -z "${RELEASE_TAG}" ]; then
108+
echo "Usage: post-release.sh [options]"
109+
echo "-t <tag>"
110+
echo "-p Push changes. Default: false"
111+
exit 1
112+
fi
113+
#-----------------------------------------------------------
114+
# check if argument matches our tag regex
115+
#-----------------------------------------------------------
116+
if [[ ! $RELEASE_TAG =~ $TAG_REGEX ]]; then
117+
echo "Provided tag [$RELEASE_TAG] does not match the required tag regex pattern [$TAG_REGEX]"
118+
exit 1
119+
fi
120+
121+
# sanity checks before we start: folder, branches etc.
122+
# deactivate -e so that piped commands can be used
123+
set +e
124+
checks_operators
125+
set -e
126+
127+
echo "Update main changelog from release $RELEASE_TAG"
128+
update_main_changelog
129+
}
130+
131+
main "$@"

0 commit comments

Comments
 (0)