From 2edfe700eb4df8cb2372fc61b66a5d195325336e Mon Sep 17 00:00:00 2001 From: Felix Hennig Date: Mon, 18 Dec 2023 18:28:34 +0100 Subject: [PATCH 1/2] new scripts --- antora.yml | 13 ++++ gitpod-antora-playbook.yml | 81 ----------------------- scripts/make-release-branch.sh | 100 ++++++++++++++++++++++++++++ scripts/publish-new-version.sh | 115 +++++++++++++++++++++++++++++++++ scripts/version_bump.sh | 48 -------------- 5 files changed, 228 insertions(+), 129 deletions(-) delete mode 100644 gitpod-antora-playbook.yml create mode 100755 scripts/make-release-branch.sh create mode 100755 scripts/publish-new-version.sh delete mode 100755 scripts/version_bump.sh diff --git a/antora.yml b/antora.yml index acba04396..01490ea5d 100644 --- a/antora.yml +++ b/antora.yml @@ -10,4 +10,17 @@ nav: - modules/operators/nav.adoc - modules/contributor/nav.adoc - modules/ROOT/nav2.adoc +# The prerelease setting affects version sorting. +# Set to 'true' for nightly and false otherwise. prerelease: true +# The attributes below are specific to this component and version +# https://docs.antora.org/antora/latest/component-attributes/#hard-set +asciidoc: + attributes: + # Keep this version in line with the 'version' key above + # The versions for the CRD docs are either 'nightly' or + # a full major.minor.patch version like 23.7.1 + crd-docs-version: "nightly" + # use the attributes below to link to the CRD docs + crd-docs-base-url: "https://crds.stackable.tech" + crd-docs: "{crd-docs-base-url}/{crd-docs-version}" diff --git a/gitpod-antora-playbook.yml b/gitpod-antora-playbook.yml deleted file mode 100644 index 106d406de..000000000 --- a/gitpod-antora-playbook.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -site: - title: Stackable Documentation - url: https://docs.stackable.tech - robots: allow - keys: - enable_tracking: false - -urls: - # This replaces the component version in the URL of the latest stable version with 'stable' - # i.e. /commons-operator/stable/index.html instead of /commons-operator/0.3/index.html - latest_version_segment: stable - -content: - branches: [release-*, main] - tags: docs/* - sources: - - url: /workspace/documentation - tags: [] - branches: [HEAD, release/*] - # management tools - - url: https://github.com/stackabletech/stackable-cockpit.git - start_path: docs - # demos - - url: https://github.com/stackabletech/demos.git - start_path: docs - # internal operators - - url: https://github.com/stackabletech/commons-operator.git - start_path: docs - - url: https://github.com/stackabletech/secret-operator.git - start_path: docs - - url: https://github.com/stackabletech/listener-operator.git - start_path: docs - # product operators - - url: https://github.com/stackabletech/airflow-operator.git - start_path: docs - - url: https://github.com/stackabletech/druid-operator.git - start_path: docs - - url: https://github.com/stackabletech/hbase-operator.git - start_path: docs - - url: https://github.com/stackabletech/hdfs-operator.git - start_path: docs - - url: https://github.com/stackabletech/hive-operator.git - start_path: docs - - url: https://github.com/stackabletech/kafka-operator.git - start_path: docs - - url: https://github.com/stackabletech/nifi-operator.git - start_path: docs - - url: https://github.com/stackabletech/opa-operator.git - start_path: docs - - url: https://github.com/stackabletech/spark-k8s-operator.git - start_path: docs - - url: https://github.com/stackabletech/superset-operator.git - start_path: docs - - url: https://github.com/stackabletech/trino-operator.git - start_path: docs - - url: https://github.com/stackabletech/zookeeper-operator.git - start_path: docs - -ui: - bundle: - url: ./ui/build/ui-bundle.zip - supplemental_files: ./node_modules/@antora/lunr-extension/supplemental_ui - -antora: - extensions: - - '@antora/lunr-extension' - - asciidoctor-kroki - -asciidoc: - attributes: - base-repo: https://github.com/stackabletech - plantuml-server-url: http://www.plantuml.com/plantuml - extensions: - - asciidoctor-kroki - -# the default caching directory is ./.cache/antora -# Antora caches the git repos, this can sometimes lead to stale content -# use 'make clean' to remove the build and cache directory -runtime: - cache_dir: ./cache diff --git a/scripts/make-release-branch.sh b/scripts/make-release-branch.sh new file mode 100755 index 000000000..8fb91349b --- /dev/null +++ b/scripts/make-release-branch.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +set -euo pipefail + +# This script takes a major.minor.patch version and +# - updates the antora.yml file accordingly +# - creates a release branch +# - pushes the release branch + +# Check if a version argument is provided +if [ -z "$1" ]; then + echo "Please provide a version as a command-line argument (major.minor.patch)." + exit 1 +fi + +# Validate the version format (major.minor.patch) +if [[ ! "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid version format. Please use the major.minor.patch format." + exit 1 +fi + +docs_dir="$(dirname "$0")/.." +antora_yaml=$docs_dir/antora.yml + +version="$1" + +# Extract major.minor part of the version +docs_version=$(echo "$version" | cut -d. -f1,2) + +# Ask the user if they have written release notes and merged them into main +echo "Release notes for the new version should already be written and commited to the main branch," +echo "so the show up in both the nightly and future versions, as well as the new release branch" +echo "that is about the be created." +read -p "Did you already write release notes and merge them into main? (yes/no): " release_notes_answer + +# Convert the user input to lowercase for case-insensitive comparison +release_notes_answer_lowercase=$(echo "$release_notes_answer" | tr '[:upper:]' '[:lower:]') + +# Check the user's response +if [ "$release_notes_answer_lowercase" != "yes" ]; then + echo "Please write release notes and merge them into main before running this script." + exit 1 +fi + +# Check if on main branch +current_branch=$(git rev-parse --abbrev-ref HEAD) +if [ "$current_branch" != "main" ]; then + echo "Not on the main branch. Please switch to the main branch." + exit 1 +fi + +# Check if the branch is up to date with the origin +git fetch +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then + echo "Your branch is not up to date with the origin main branch. Please pull the latest changes." + exit 1 +fi + +# Check if the working directory is clean +if [ -n "$(git status --porcelain)" ]; then + echo "Working directory is not clean. Please commit or stash your changes." + exit 1 +fi + +echo "All checks passed. You are on the main branch, up to date with the origin, and the working directory is clean." + +# Set version key to docs_version +sed -i "s/^version:.*/version: \"$docs_version\"/" "$antora_yaml" + +# Set prerelease to false +sed -i "s/^prerelease:.*/prerelease: false/" "$antora_yaml" + +# Set crd-docs-version key to the 'version' variable +sed -i "s/^\(\s*\)crd-docs-version:.*/\1crd-docs-version: \"$version\"/" "$antora_yaml" + +# Display changes using git diff +git diff "$antora_yaml" + +# Ask the user whether to proceed +read -p "Do you want to proceed with these changes? (yes/no): " proceed_answer + +# Convert the user input to lowercase for case-insensitive comparison +proceed_answer_lowercase=$(echo "$proceed_answer" | tr '[:upper:]' '[:lower:]') + +# Check the user's response +if [ "$proceed_answer_lowercase" != "yes" ]; then + echo "Aborted. Nothing was commited." + exit 1 +fi + +# User wants to proceed +# Checkout a new branch +branch_name="release/$docs_version" +git checkout -b "$branch_name" + +# Commit the changes +git add "$antora_yaml" +git commit -m "Update version in antora.yml to $version" + +# Push the branch +git push origin "$branch_name" \ No newline at end of file diff --git a/scripts/publish-new-version.sh b/scripts/publish-new-version.sh new file mode 100755 index 000000000..ae986e769 --- /dev/null +++ b/scripts/publish-new-version.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +set -euox pipefail + +# This script updates all the playbook files with the new branches for a given version. +# The version should be given as major.minor + +# Check if yq is installed +if ! command -v yq &> /dev/null; then + echo "Error: 'yq' is not installed. It is needed to update yaml files later in the script." + echo "This script was tested with yq v4.40.5" + echo "Please install 'yq' from https://github.com/mikefarah/yq and then run the script again." + exit 1 +fi + +# Check if a version argument is provided +if [ -z "$1" ]; then + echo "Please provide a version as a command-line argument (major.minor)." + exit 1 +fi + +# Validate the version format (major.minor.patch) +if [[ ! "$1" =~ ^[0-9]+\.[0-9]$ ]]; then + echo "Invalid version format. Please use the major.minor.patch format." + exit 1 +fi + +docs_version="$1" + +# Define the branches to add. The documentation repo uses a '/' while the operators use a '-' +docs_branch="release/$docs_version" +operator_branch="release-$docs_version" + +# Check if the release branch exists upstream +if ! git rev-parse --quiet --verify "$docs_branch" > /dev/null; then + echo "Release branch '$docs_branch' is missing upstream in the documentation repository." + echo "Please create the $docs_branch branch first using the make-release-branch.sh script." + echo "Aborting." + exit 1 +fi + +read -p "Did you create all the release branches in the operators? (yes/no): " operators_branches_answer + +# Convert the user input to lowercase for case-insensitive comparison +operators_branches_answer_lowercase=$(echo "$operators_branches_answer" | tr '[:upper:]' '[:lower:]') + +if [ "$operators_branches_answer_lowercase" != "yes" ]; then + echo "Please create all the branches in the operators before proceeding." + exit 1 +fi + +# Check if on main branch +current_branch=$(git rev-parse --abbrev-ref HEAD) +if [ "$current_branch" != "main" ]; then + echo "Not on the main branch. Please switch to the main branch." + exit 1 +fi + +# Check if the branch is up to date with the origin +git fetch +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then + echo "Your branch is not up to date with the origin main branch. Please pull the latest changes." + exit 1 +fi + +# Check if the working directory is clean +if [ -n "$(git status --porcelain)" ]; then + echo "Working directory is not clean. Please commit or stash your changes." + exit 1 +fi + +echo "All checks passed." +echo "Updating playbooks." + +# Define the branches to add. The documentation repo uses a '/' while the operators use a '-' +docs_branch="release/$docs_version" +operator_branch="release-$docs_version" +insert_position=1 + +playbook_files=("antora-playbook.yml" "local-antora-playbook.yml") + +# Loop through each playbook file +for yaml_file in "${playbook_files[@]}"; do + # Insert the docs_branch + yq ".content.sources[0].branches |= (.[:$insert_position] + [\"$docs_branch\"] + .[$insert_position:])" -i "$yaml_file" + + # Update all the operator sources. + yq "with(.content.sources.[]; select(.url == \"*operator*\") | .branches |= .[:$insert_position] + [\"$operator_branch\"] + .[$insert_position:])" -i "$yaml_file" +done + +# Display changes and ask for user confirmation +git diff +read -p "Do you want to proceed with these changes? (yes/no): " proceed_answer + +# Convert the user input to lowercase for case-insensitive comparison +proceed_answer_lowercase=$(echo "$proceed_answer" | tr '[:upper:]' '[:lower:]') + +# Check the user's response +if [ "$proceed_answer_lowercase" != "yes" ]; then + echo "Aborted. Nothing was commited." + exit 1 +fi + +publish_branch="publish-$docs_version" + +git checkout -b "$publish_branch" + +git add . +git commit -m "Add release branches to the playbooks for release $docs_version." + +# Push the branch upstream +git push -u origin "$publish_branch" + +echo "The changes have been pushed to GitHub!" +echo "Click the link above to create the PR in GitHub, and then verify that the build works with Netlify previews." +echo "Once the branch is merged, the changes are live." \ No newline at end of file diff --git a/scripts/version_bump.sh b/scripts/version_bump.sh deleted file mode 100755 index 4c5ac5a05..000000000 --- a/scripts/version_bump.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Creates two commits: -# - the first commit with the new version and tagged -# - the second commit bumped back to nightly - -if [ ! $# -eq 1 ] -then - echo "Version required. I.e.: ./script.sh 22.06" - exit 1 -fi - -if [ ! -z "$(git status --porcelain)" ]; then - echo "There are uncommitted changes, please resolve before running this script." - exit 1 -fi - -export new_version="$1" - -docs_dir="$(dirname "$0")/.." -antora_file=$docs_dir/antora.yml - -branch_name="version-bump-$new_version" - -git checkout -b "$branch_name" - - -echo "Updating $antora_file to version $new_version" -yq eval --inplace '.version = strenv(new_version)' $antora_file -yq eval --inplace '.prerelease = false' $antora_file - -echo "Committing ..." -git add "$antora_file" -git commit -m "Set version $new_version" -git tag -a "docs/$new_version" -m "Documentation for release $new_version" - -echo "Updating $antora_file to nightly" -yq eval --inplace '.version = "nightly"' $antora_file -yq eval --inplace '.prerelease = true' $antora_file - -echo "Committing..." -git add "$antora_file" -git commit -m "Bumped back to nightly" - -echo "" -echo "Done! Please push manually:" -echo "git push --set-upstream origin $branch_name" From 3ba68e0eb444d330e2879bd753472d3d5fefe7dc Mon Sep 17 00:00:00 2001 From: Felix Hennig Date: Mon, 18 Dec 2023 18:38:07 +0100 Subject: [PATCH 2/2] minor changes --- scripts/publish-new-version.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/publish-new-version.sh b/scripts/publish-new-version.sh index ae986e769..d0f8af4dc 100755 --- a/scripts/publish-new-version.sh +++ b/scripts/publish-new-version.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash -set -euox pipefail +set -euo pipefail # This script updates all the playbook files with the new branches for a given version. -# The version should be given as major.minor +# The version should be given as major.minor. +# All the release branches in the operators as well as the docs release branch should already be there. # Check if yq is installed if ! command -v yq &> /dev/null; then @@ -18,9 +19,9 @@ if [ -z "$1" ]; then exit 1 fi -# Validate the version format (major.minor.patch) +# Validate the version format (major.minor) if [[ ! "$1" =~ ^[0-9]+\.[0-9]$ ]]; then - echo "Invalid version format. Please use the major.minor.patch format." + echo "Invalid version format. Please use the major.minor format." exit 1 fi @@ -76,7 +77,8 @@ docs_branch="release/$docs_version" operator_branch="release-$docs_version" insert_position=1 -playbook_files=("antora-playbook.yml" "local-antora-playbook.yml") +docs_dir="$(dirname "$0")/.." +playbook_files=("$docs_dir/antora-playbook.yml" "$docs_dir/local-antora-playbook.yml") # Loop through each playbook file for yaml_file in "${playbook_files[@]}"; do