From ed22373c3069dc4cefb906a0f7d5aefecb9c255f Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 2 Jun 2025 15:02:17 +0200 Subject: [PATCH 1/2] Move versions1.json to versions.json Signed-off-by: Evan Lezar --- README.md | 8 +-- container-toolkit/versions.json | 93 +++++++++++++++++--------------- container-toolkit/versions1.json | 51 ------------------ repo.toml | 4 +- 4 files changed, 57 insertions(+), 99 deletions(-) delete mode 100644 container-toolkit/versions1.json diff --git a/README.md b/README.md index b16cd2ec8..0c9fd524a 100644 --- a/README.md +++ b/README.md @@ -108,13 +108,13 @@ Always update the openshift docset when there is a new gpu-operator docset versi copyright_start = 2020 ``` -1. Update the version in `/versions1.json`: +1. Update the version in `/versions.json`: ```diff - diff --git a/container-toolkit/versions1.json b/container-toolkit/versions1.json + diff --git a/container-toolkit/versions.json b/container-toolkit/versions.json index 95429953..e2738987 100644 - --- a/container-toolkit/versions1.json - +++ b/container-toolkit/versions1.json + --- a/container-toolkit/versions.json + +++ b/container-toolkit/versions.json @@ -1,6 +1,10 @@ [ { diff --git a/container-toolkit/versions.json b/container-toolkit/versions.json index aef68cb71..bed065609 100644 --- a/container-toolkit/versions.json +++ b/container-toolkit/versions.json @@ -1,42 +1,51 @@ -{ - "latest": "1.17.8", - "versions": - [ - { - "version": "1.17.8" - }, - { - "version": "1.17.7" - }, - { - "version": "1.17.6" - }, - { - "version": "1.17.5" - }, - { - "version": "1.17.4" - }, - { - "version": "1.17.3" - }, - { - "version": "1.17.2" - }, - { - "version": "1.17.1" - }, - { - "version": "1.17.0" - }, - { - "version": "1.16.2" - }, - { - "version": "1.16.1" - }, - { - "version": "1.16.0" - } - ] -} +[ + { + "preferred": "true", + "url": "../1.17.8", + "version": "1.17.8" + }, + { + "url": "../1.17.7", + "version": "1.17.7" + }, + { + "url": "../1.17.6", + "version": "1.17.6" + }, + { + "url": "../1.17.5", + "version": "1.17.5" + }, + { + "url": "../1.17.4", + "version": "1.17.4" + }, + { + "url": "../1.17.3", + "version": "1.17.3" + }, + { + "url": "../1.17.2", + "version": "1.17.2" + }, + { + "url": "../1.17.1", + "version": "1.17.1" + }, + { + "url": "../1.17.0", + "version": "1.17.0" + }, + { + "url": "../1.16.2", + "version": "1.16.2" + }, + { + "url": "../1.16.1", + "version": "1.16.1" + }, + { + "url": "../1.16.0", + "version": "1.16.0" + } +] \ No newline at end of file diff --git a/container-toolkit/versions1.json b/container-toolkit/versions1.json deleted file mode 100644 index bed065609..000000000 --- a/container-toolkit/versions1.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "preferred": "true", - "url": "../1.17.8", - "version": "1.17.8" - }, - { - "url": "../1.17.7", - "version": "1.17.7" - }, - { - "url": "../1.17.6", - "version": "1.17.6" - }, - { - "url": "../1.17.5", - "version": "1.17.5" - }, - { - "url": "../1.17.4", - "version": "1.17.4" - }, - { - "url": "../1.17.3", - "version": "1.17.3" - }, - { - "url": "../1.17.2", - "version": "1.17.2" - }, - { - "url": "../1.17.1", - "version": "1.17.1" - }, - { - "url": "../1.17.0", - "version": "1.17.0" - }, - { - "url": "../1.16.2", - "version": "1.16.2" - }, - { - "url": "../1.16.1", - "version": "1.16.1" - }, - { - "url": "../1.16.0", - "version": "1.16.0" - } -] \ No newline at end of file diff --git a/repo.toml b/repo.toml index cfb2a7970..42a55f550 100644 --- a/repo.toml +++ b/repo.toml @@ -42,14 +42,14 @@ sphinx_conf_py_extra = """ html_domain_indices = False html_use_index = False - html_extra_path = ["versions1.json"] + html_extra_path = ["versions.json"] html_static_path = ["${root}/css"] html_css_files = ["custom.css"] html_theme_options = { "icon_links": [], "switcher": { - "json_url": "../versions1.json", + "json_url": "../versions.json", "version_match": release, }, } From 659e4c65b74e998959525c08c0557725a371e914 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 2 Jun 2025 15:15:43 +0200 Subject: [PATCH 2/2] Add script to bump component version Signed-off-by: Evan Lezar --- scripts/bump-version.sh | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 scripts/bump-version.sh diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100755 index 000000000..fc6385004 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Function to print usage +print_usage() { + echo "Usage: $0 " + echo "Example: $0 container-toolkit 1.17.9" + exit 1 +} + +# Check if yq is installed +check_yq() { + if ! command -v yq &> /dev/null; then + echo "Error: yq is not installed" + echo "Please install yq first. On macOS, you can use: brew install yq" + exit 1 + fi +} + +# Validate input parameters +if [[ $# -ne 2 ]]; then + print_usage +fi + +COMPONENT="$1" +NEW_VERSION="$2" + +# Check if yq is available +check_yq + +# Validate component exists both as a directory and in repo.toml +if [[ ! -d "$COMPONENT" ]]; then + echo "Error: Component directory '${COMPONENT}' not found" + exit 1 +fi + +# Check if the version field exists and get current version +CURRENT_VERSION=$(yq ".repo_docs.projects.${COMPONENT}.version" repo.toml) +if [[ "$CURRENT_VERSION" == "null" ]]; then + echo "Error: Component '${COMPONENT}' version field not found in repo.toml" + exit 1 +fi + +# Update versions.json if it exists +VERSIONS_JSON="$COMPONENT/versions.json" +if [[ -f "$VERSIONS_JSON" ]]; then + echo "Updating $VERSIONS_JSON..." + yq -p=json -o=json -i '. = [{"preferred": "true", "url": "../'"${NEW_VERSION}"'", "version": "'"${NEW_VERSION}"'"}] + [(.[0] | del(.preferred))] + .[1:]' "$VERSIONS_JSON" + if [[ $? -ne 0 ]]; then + echo "Error: Failed to update $VERSIONS_JSON" + exit 1 + fi +fi + +# Update version in repo.toml using sed +echo "Updating version in repo.toml..." +# Remove quotes from current version for sed +CURRENT_VERSION=${CURRENT_VERSION//\"/} +if [[ $(uname) == "Darwin" ]]; then + # macOS requires an empty string for -i + sed -i '' "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" repo.toml +else + # Linux version of sed + sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${NEW_VERSION}\"/" repo.toml +fi + +if [[ $? -ne 0 ]]; then + echo "Error: Failed to update repo.toml" + exit 1 +fi + +echo "Successfully updated version to ${NEW_VERSION} for ${COMPONENT}" \ No newline at end of file