Skip to content

Commit 2edfe70

Browse files
committed
new scripts
1 parent bc0b08e commit 2edfe70

File tree

5 files changed

+228
-129
lines changed

5 files changed

+228
-129
lines changed

antora.yml

Lines changed: 13 additions & 0 deletions
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

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

scripts/make-release-branch.sh

Lines changed: 100 additions & 0 deletions
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

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

scripts/version_bump.sh

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

0 commit comments

Comments
 (0)