Skip to content

Commit dcaa3f8

Browse files
authored
Feat: new release scripts, component attribute for CRD docs links (#511)
* new scripts * minor changes
1 parent bc0b08e commit dcaa3f8

File tree

5 files changed

+230
-129
lines changed

5 files changed

+230
-129
lines changed

antora.yml

+13
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@ nav:
1010
- modules/operators/nav.adoc
1111
- modules/contributor/nav.adoc
1212
- modules/ROOT/nav2.adoc
13+
# The prerelease setting affects version sorting.
14+
# Set to 'true' for nightly and false otherwise.
1315
prerelease: true
16+
# The attributes below are specific to this component and version
17+
# https://docs.antora.org/antora/latest/component-attributes/#hard-set
18+
asciidoc:
19+
attributes:
20+
# Keep this version in line with the 'version' key above
21+
# The versions for the CRD docs are either 'nightly' or
22+
# a full major.minor.patch version like 23.7.1
23+
crd-docs-version: "nightly"
24+
# use the attributes below to link to the CRD docs
25+
crd-docs-base-url: "https://crds.stackable.tech"
26+
crd-docs: "{crd-docs-base-url}/{crd-docs-version}"

gitpod-antora-playbook.yml

-81
This file was deleted.

scripts/make-release-branch.sh

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script takes a major.minor.patch version and
5+
# - updates the antora.yml file accordingly
6+
# - creates a release branch
7+
# - pushes the release branch
8+
9+
# Check if a version argument is provided
10+
if [ -z "$1" ]; then
11+
echo "Please provide a version as a command-line argument (major.minor.patch)."
12+
exit 1
13+
fi
14+
15+
# Validate the version format (major.minor.patch)
16+
if [[ ! "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
17+
echo "Invalid version format. Please use the major.minor.patch format."
18+
exit 1
19+
fi
20+
21+
docs_dir="$(dirname "$0")/.."
22+
antora_yaml=$docs_dir/antora.yml
23+
24+
version="$1"
25+
26+
# Extract major.minor part of the version
27+
docs_version=$(echo "$version" | cut -d. -f1,2)
28+
29+
# Ask the user if they have written release notes and merged them into main
30+
echo "Release notes for the new version should already be written and commited to the main branch,"
31+
echo "so the show up in both the nightly and future versions, as well as the new release branch"
32+
echo "that is about the be created."
33+
read -p "Did you already write release notes and merge them into main? (yes/no): " release_notes_answer
34+
35+
# Convert the user input to lowercase for case-insensitive comparison
36+
release_notes_answer_lowercase=$(echo "$release_notes_answer" | tr '[:upper:]' '[:lower:]')
37+
38+
# Check the user's response
39+
if [ "$release_notes_answer_lowercase" != "yes" ]; then
40+
echo "Please write release notes and merge them into main before running this script."
41+
exit 1
42+
fi
43+
44+
# Check if on main branch
45+
current_branch=$(git rev-parse --abbrev-ref HEAD)
46+
if [ "$current_branch" != "main" ]; then
47+
echo "Not on the main branch. Please switch to the main branch."
48+
exit 1
49+
fi
50+
51+
# Check if the branch is up to date with the origin
52+
git fetch
53+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
54+
echo "Your branch is not up to date with the origin main branch. Please pull the latest changes."
55+
exit 1
56+
fi
57+
58+
# Check if the working directory is clean
59+
if [ -n "$(git status --porcelain)" ]; then
60+
echo "Working directory is not clean. Please commit or stash your changes."
61+
exit 1
62+
fi
63+
64+
echo "All checks passed. You are on the main branch, up to date with the origin, and the working directory is clean."
65+
66+
# Set version key to docs_version
67+
sed -i "s/^version:.*/version: \"$docs_version\"/" "$antora_yaml"
68+
69+
# Set prerelease to false
70+
sed -i "s/^prerelease:.*/prerelease: false/" "$antora_yaml"
71+
72+
# Set crd-docs-version key to the 'version' variable
73+
sed -i "s/^\(\s*\)crd-docs-version:.*/\1crd-docs-version: \"$version\"/" "$antora_yaml"
74+
75+
# Display changes using git diff
76+
git diff "$antora_yaml"
77+
78+
# Ask the user whether to proceed
79+
read -p "Do you want to proceed with these changes? (yes/no): " proceed_answer
80+
81+
# Convert the user input to lowercase for case-insensitive comparison
82+
proceed_answer_lowercase=$(echo "$proceed_answer" | tr '[:upper:]' '[:lower:]')
83+
84+
# Check the user's response
85+
if [ "$proceed_answer_lowercase" != "yes" ]; then
86+
echo "Aborted. Nothing was commited."
87+
exit 1
88+
fi
89+
90+
# User wants to proceed
91+
# Checkout a new branch
92+
branch_name="release/$docs_version"
93+
git checkout -b "$branch_name"
94+
95+
# Commit the changes
96+
git add "$antora_yaml"
97+
git commit -m "Update version in antora.yml to $version"
98+
99+
# Push the branch
100+
git push origin "$branch_name"

scripts/publish-new-version.sh

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script updates all the playbook files with the new branches for a given version.
5+
# The version should be given as major.minor.
6+
# All the release branches in the operators as well as the docs release branch should already be there.
7+
8+
# Check if yq is installed
9+
if ! command -v yq &> /dev/null; then
10+
echo "Error: 'yq' is not installed. It is needed to update yaml files later in the script."
11+
echo "This script was tested with yq v4.40.5"
12+
echo "Please install 'yq' from https://github.com/mikefarah/yq and then run the script again."
13+
exit 1
14+
fi
15+
16+
# Check if a version argument is provided
17+
if [ -z "$1" ]; then
18+
echo "Please provide a version as a command-line argument (major.minor)."
19+
exit 1
20+
fi
21+
22+
# Validate the version format (major.minor)
23+
if [[ ! "$1" =~ ^[0-9]+\.[0-9]$ ]]; then
24+
echo "Invalid version format. Please use the major.minor format."
25+
exit 1
26+
fi
27+
28+
docs_version="$1"
29+
30+
# Define the branches to add. The documentation repo uses a '/' while the operators use a '-'
31+
docs_branch="release/$docs_version"
32+
operator_branch="release-$docs_version"
33+
34+
# Check if the release branch exists upstream
35+
if ! git rev-parse --quiet --verify "$docs_branch" > /dev/null; then
36+
echo "Release branch '$docs_branch' is missing upstream in the documentation repository."
37+
echo "Please create the $docs_branch branch first using the make-release-branch.sh script."
38+
echo "Aborting."
39+
exit 1
40+
fi
41+
42+
read -p "Did you create all the release branches in the operators? (yes/no): " operators_branches_answer
43+
44+
# Convert the user input to lowercase for case-insensitive comparison
45+
operators_branches_answer_lowercase=$(echo "$operators_branches_answer" | tr '[:upper:]' '[:lower:]')
46+
47+
if [ "$operators_branches_answer_lowercase" != "yes" ]; then
48+
echo "Please create all the branches in the operators before proceeding."
49+
exit 1
50+
fi
51+
52+
# Check if on main branch
53+
current_branch=$(git rev-parse --abbrev-ref HEAD)
54+
if [ "$current_branch" != "main" ]; then
55+
echo "Not on the main branch. Please switch to the main branch."
56+
exit 1
57+
fi
58+
59+
# Check if the branch is up to date with the origin
60+
git fetch
61+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
62+
echo "Your branch is not up to date with the origin main branch. Please pull the latest changes."
63+
exit 1
64+
fi
65+
66+
# Check if the working directory is clean
67+
if [ -n "$(git status --porcelain)" ]; then
68+
echo "Working directory is not clean. Please commit or stash your changes."
69+
exit 1
70+
fi
71+
72+
echo "All checks passed."
73+
echo "Updating playbooks."
74+
75+
# Define the branches to add. The documentation repo uses a '/' while the operators use a '-'
76+
docs_branch="release/$docs_version"
77+
operator_branch="release-$docs_version"
78+
insert_position=1
79+
80+
docs_dir="$(dirname "$0")/.."
81+
playbook_files=("$docs_dir/antora-playbook.yml" "$docs_dir/local-antora-playbook.yml")
82+
83+
# Loop through each playbook file
84+
for yaml_file in "${playbook_files[@]}"; do
85+
# Insert the docs_branch
86+
yq ".content.sources[0].branches |= (.[:$insert_position] + [\"$docs_branch\"] + .[$insert_position:])" -i "$yaml_file"
87+
88+
# Update all the operator sources.
89+
yq "with(.content.sources.[]; select(.url == \"*operator*\") | .branches |= .[:$insert_position] + [\"$operator_branch\"] + .[$insert_position:])" -i "$yaml_file"
90+
done
91+
92+
# Display changes and ask for user confirmation
93+
git diff
94+
read -p "Do you want to proceed with these changes? (yes/no): " proceed_answer
95+
96+
# Convert the user input to lowercase for case-insensitive comparison
97+
proceed_answer_lowercase=$(echo "$proceed_answer" | tr '[:upper:]' '[:lower:]')
98+
99+
# Check the user's response
100+
if [ "$proceed_answer_lowercase" != "yes" ]; then
101+
echo "Aborted. Nothing was commited."
102+
exit 1
103+
fi
104+
105+
publish_branch="publish-$docs_version"
106+
107+
git checkout -b "$publish_branch"
108+
109+
git add .
110+
git commit -m "Add release branches to the playbooks for release $docs_version."
111+
112+
# Push the branch upstream
113+
git push -u origin "$publish_branch"
114+
115+
echo "The changes have been pushed to GitHub!"
116+
echo "Click the link above to create the PR in GitHub, and then verify that the build works with Netlify previews."
117+
echo "Once the branch is merged, the changes are live."

scripts/version_bump.sh

-48
This file was deleted.

0 commit comments

Comments
 (0)