Skip to content

Commit c5fcae2

Browse files
adwk67razvan
andauthored
Refactoring to update release scripts (#53)
* refactor version in line with workspace changes, add release tag to products changelog * revert temporary change used for testing * wip: replace version script * try simplifying version update * WIP: revert due to reformatting * add folder check * Use set-version cargo plugin --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
1 parent b55a581 commit c5fcae2

File tree

6 files changed

+40
-215
lines changed

6 files changed

+40
-215
lines changed

release/README.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ image::images/rb-utils.png[]
2929

3030
## Install requirements
3131

32-
### Python 3
32+
### cargo-edit plugin
3333

34-
A working python 3 installation is required by the `cargo-version.py` script.
3534

36-
Install required packages:
35+
The `cargo-edit` plugin is used to update operator versions in `cargo` workspaces.
3736

38-
[source]
37+
Install it like this:
38+
39+
[source,bash]
3940
----
40-
pip install -r release/requirements.txt
41+
cargo install cargo-edit --version 0.11.11
4142
----
4243

4344
### yq (yaml parser)

release/cargo-version.py

Lines changed: 0 additions & 179 deletions
This file was deleted.

release/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ operators:
66
- druid-operator
77
- hbase-operator
88
- hdfs-operator
9+
- hello-world-operator
910
- hive-operator
1011
- kafka-operator
1112
- listener-operator

release/create-bugfix-tag.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ tag_operators() {
3030
fi
3131

3232
# set tag version where relevant
33-
CARGO_VERSION="$INITIAL_DIR"/release/cargo-version.py
34-
$CARGO_VERSION --set "$RELEASE_TAG"
33+
cargo set-version --offline --workspace "$RELEASE_TAG"
34+
3535
cargo update --workspace
3636
make regenerate-charts
3737

release/create-release-tag.sh

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tag_products() {
2121
update_product_images_changelogs
2222

2323
git commit -am "release $RELEASE_TAG"
24-
git tag "$RELEASE_TAG"
24+
git tag "$RELEASE_TAG" -m "release $RELEASE_TAG"
2525
push_branch
2626
}
2727

@@ -36,8 +36,7 @@ tag_operators() {
3636
git submodule update --recursive --init
3737
fi
3838

39-
CARGO_VERSION="$INITIAL_DIR"/release/cargo-version.py
40-
$CARGO_VERSION --set "$RELEASE_TAG"
39+
cargo set-version --offline --workspace "$RELEASE_TAG"
4140
cargo update --workspace
4241
make regenerate-charts
4342

@@ -52,7 +51,7 @@ tag_operators() {
5251
update_changelog "$TEMP_RELEASE_FOLDER/${operator}"
5352

5453
git commit -am "release $RELEASE_TAG"
55-
git tag "$RELEASE_TAG"
54+
git tag "$RELEASE_TAG" -m "release $RELEASE_TAG"
5655
push_branch
5756
done < <(yq '... comments="" | .operators[] ' "$INITIAL_DIR"/release/config.yaml)
5857
}
@@ -125,34 +124,39 @@ checks() {
125124
}
126125

127126
update_code() {
128-
echo "Updating antora docs for $1"
129-
# antora version should be major.minor, not patch level
130-
yq -i ".version = \"${RELEASE}\"" "$1/docs/antora.yml"
131-
yq -i '.prerelease = false' "$1/docs/antora.yml"
132-
133-
# Not all operators have a getting started guide
134-
# that's why we verify if templating_vars.yaml exists.
135-
if [ -f "$1/docs/templating_vars.yaml" ]; then
136-
yq -i "(.versions.[] | select(. == \"*dev\")) |= \"${RELEASE_TAG}\"" "$1/docs/templating_vars.yaml"
137-
yq -i ".helm.repo_name |= sub(\"stackable-dev\", \"stackable-stable\")" "$1/docs/templating_vars.yaml"
138-
yq -i ".helm.repo_url |= sub(\"helm-dev\", \"helm-stable\")" "$1/docs/templating_vars.yaml"
127+
if [ -d "$1/docs" ]; then
128+
echo "Updating antora docs for $1"
129+
# antora version should be major.minor, not patch level
130+
yq -i ".version = \"${RELEASE}\"" "$1/docs/antora.yml"
131+
yq -i '.prerelease = false' "$1/docs/antora.yml"
132+
133+
# Not all operators have a getting started guide
134+
# that's why we verify if templating_vars.yaml exists.
135+
if [ -f "$1/docs/templating_vars.yaml" ]; then
136+
yq -i "(.versions.[] | select(. == \"*dev\")) |= \"${RELEASE_TAG}\"" "$1/docs/templating_vars.yaml"
137+
yq -i ".helm.repo_name |= sub(\"stackable-dev\", \"stackable-stable\")" "$1/docs/templating_vars.yaml"
138+
yq -i ".helm.repo_url |= sub(\"helm-dev\", \"helm-stable\")" "$1/docs/templating_vars.yaml"
139+
fi
140+
141+
#--------------------------------------------------------------------------
142+
# Replace "nightly" link so the documentation refers to the current version
143+
#--------------------------------------------------------------------------
144+
for file in $(find "$1/docs" -name "*.adoc"); do
145+
sed -i "s/nightly@home/home/g" "$file"
146+
done
147+
else
148+
echo "No docs found under $1."
139149
fi
140150

141151
#--------------------------------------------------------------------------
142152
# Replace .spec.image.stackableVersion for kuttl tests.
143153
# Use sed as yq does not process .j2 file syntax properly.
154+
# N.B. commented out as the tests assume same stackable version as operator
144155
#--------------------------------------------------------------------------
145-
if [ -f "$1/tests/test-definition.yaml" ]; then
146-
# e.g. 2.2.4-stackable0.5.0 -> 2.2.4-stackable23.1
147-
sed -i "s/-stackable.*/-stackable${RELEASE}/" "$1/tests/test-definition.yaml"
148-
fi
149-
150-
#--------------------------------------------------------------------------
151-
# Replace "nightly" link so the documentation refers to the current version
152-
#--------------------------------------------------------------------------
153-
for file in $(find "$1/docs" -name "*.adoc"); do
154-
sed -i "s/nightly@home/home/g" "$file"
155-
done
156+
#if [ -f "$1/tests/test-definition.yaml" ]; then
157+
# # e.g. 2.2.4-stackable0.5.0 -> 2.2.4-stackable23.1
158+
# sed -i "s/-stackable.*/-stackable${RELEASE}/" "$1/tests/test-definition.yaml"
159+
#fi
156160
}
157161

158162
push_branch() {
@@ -180,7 +184,7 @@ update_changelog() {
180184

181185
update_product_images_changelogs() {
182186
TODAY=$(date +'%Y-%m-%d')
183-
sed -i "s/^.*unreleased.*/## [Unreleased]\n\n## [$RELEASE_TAG] - $TODAY/I" ./**/CHANGELOG.md
187+
sed -i "s/^.*unreleased.*/## [Unreleased]\n\n## [$RELEASE_TAG] - $TODAY/I" ./CHANGELOG.md
184188
}
185189

186190
parse_inputs() {

release/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)