1#!/usr/bin/env bash
2set -euo pipefail
3
4# Creates a new versioned documentation release.
5#
6# Usage:
7# ./create-release.sh <version>
8#
9# Example:
10# ./create-release.sh 2.1
11#
12# This will:
13# 1. Copy docs/ to versioned_docs/version-2.1.x/
14# 2. Prepend "2.1.x" to versions.json
15# 3. Create versioned_sidebars/version-2.1.x-sidebars.json from sidebars.ts
16
17SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18cd "$SCRIPT_DIR"
19
20if [ $# -ne 1 ]; then
21 echo "Usage: $0 <version>"
22 echo "Example: $0 2.1"
23 exit 1
24fi
25
26VERSION="$1"
27VERSION_LABEL="${VERSION}.x"
28VERSIONED_DOCS_DIR="versioned_docs/version-${VERSION_LABEL}"
29SIDEBAR_FILE="versioned_sidebars/version-${VERSION_LABEL}-sidebars.json"
30
31# Validate that the version doesn't already exist
32if [ -d "$VERSIONED_DOCS_DIR" ]; then
33 echo "Error: Version ${VERSION_LABEL} already exists at ${VERSIONED_DOCS_DIR}"
34 exit 1
35fi
36
37if grep -q "\"${VERSION_LABEL}\"" versions.json; then
38 echo "Error: Version ${VERSION_LABEL} already listed in versions.json"
39 exit 1
40fi
41
42# Step 1: Copy docs/ to versioned_docs/version-<version>.x/
43echo "Copying docs/ to ${VERSIONED_DOCS_DIR}/"
44cp -r docs "$VERSIONED_DOCS_DIR"
45
46# Step 2: Prepend version to versions.json
47echo "Adding \"${VERSION_LABEL}\" to versions.json"
48EXISTING=$(cat versions.json)
49echo "$EXISTING" | python3 -c "
50import json, sys
51versions = json.load(sys.stdin)
52versions.insert(0, '${VERSION_LABEL}')
53print(json.dumps(versions, indent=4))
54" > versions.json
55
56# Step 3: Create sidebar file by converting sidebars.ts to JSON
57# Use the same structure as existing versioned sidebar files
58echo "Creating ${SIDEBAR_FILE}"
59# Extract the sidebar JSON from the most recent versioned sidebar as a template,
60# since all versioned sidebars match the current sidebars.ts structure.
61LATEST_SIDEBAR=$(ls -1 versioned_sidebars/*.json 2>/dev/null | sort -V | tail -1)
62
63if [ -n "$LATEST_SIDEBAR" ]; then
64 cp "$LATEST_SIDEBAR" "$SIDEBAR_FILE"
65else
66 # Fallback: generate from the known structure in sidebars.ts
67 cat > "$SIDEBAR_FILE" << 'EOF'
68{
69 "docs": [{ "type": "autogenerated", "dirName": "." }],
70 "api": [
71 "api/overview",
72 "api/arrow-flight-sql/index",
73 "api/jdbc/index",
74 "api/odbc/index",
75 "api/auth/index",
76 "api/tls/index",
77 {
78 "type": "category",
79 "label": "HTTP",
80 "collapsible": true,
81 "collapsed": false,
82 "items": [{ "type": "autogenerated", "dirName": "api/HTTP" }]
83 }
84 ]
85}
86EOF
87fi
88
89echo ""
90echo "Release ${VERSION_LABEL} created successfully!"
91echo ""
92echo "Files created/modified:"
93echo " - ${VERSIONED_DOCS_DIR}/ (copied from docs/)"
94echo " - versions.json (updated)"
95echo " - ${SIDEBAR_FILE} (created)"
96
1#!/usr/bin/env bash
2set -euo pipefail
3
4# Creates a new versioned documentation release.
5#
6# Usage:
7# ./create-release.sh <version>
8#
9# Example:
10# ./create-release.sh 2.1
11#
12# This will:
13# 1. Copy docs/ to versioned_docs/version-2.1.x/
14# 2. Prepend "2.1.x" to versions.json
15# 3. Create versioned_sidebars/version-2.1.x-sidebars.json from sidebars.ts
16
17SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18cd "$SCRIPT_DIR"
19
20if [ $# -ne 1 ]; then
21 echo "Usage: $0 <version>"
22 echo "Example: $0 2.1"
23 exit 1
24fi
25
26VERSION="$1"
27VERSION_LABEL="${VERSION}.x"
28VERSIONED_DOCS_DIR="versioned_docs/version-${VERSION_LABEL}"
29SIDEBAR_FILE="versioned_sidebars/version-${VERSION_LABEL}-sidebars.json"
30
31# Validate that the version doesn't already exist
32if [ -d "$VERSIONED_DOCS_DIR" ]; then
33 echo "Error: Version ${VERSION_LABEL} already exists at ${VERSIONED_DOCS_DIR}"
34 exit 1
35fi
36
37if grep -q "\"${VERSION_LABEL}\"" versions.json; then
38 echo "Error: Version ${VERSION_LABEL} already listed in versions.json"
39 exit 1
40fi
41
42# Step 1: Copy docs/ to versioned_docs/version-<version>.x/
43echo "Copying docs/ to ${VERSIONED_DOCS_DIR}/"
44cp -r docs "$VERSIONED_DOCS_DIR"
45
46# Step 2: Prepend version to versions.json
47echo "Adding \"${VERSION_LABEL}\" to versions.json"
48EXISTING=$(cat versions.json)
49echo "$EXISTING" | python3 -c "
50import json, sys
51versions = json.load(sys.stdin)
52versions.insert(0, '${VERSION_LABEL}')
53print(json.dumps(versions, indent=4))
54" > versions.json
55
56# Step 3: Create sidebar file by converting sidebars.ts to JSON
57# Use the same structure as existing versioned sidebar files
58echo "Creating ${SIDEBAR_FILE}"
59# Extract the sidebar JSON from the most recent versioned sidebar as a template,
60# since all versioned sidebars match the current sidebars.ts structure.
61LATEST_SIDEBAR=$(ls -1 versioned_sidebars/*.json 2>/dev/null | sort -V | tail -1)
62
63if [ -n "$LATEST_SIDEBAR" ]; then
64 cp "$LATEST_SIDEBAR" "$SIDEBAR_FILE"
65else
66 # Fallback: generate from the known structure in sidebars.ts
67 cat > "$SIDEBAR_FILE" << 'EOF'
68{
69 "docs": [{ "type": "autogenerated", "dirName": "." }],
70 "api": [
71 "api/overview",
72 "api/arrow-flight-sql/index",
73 "api/jdbc/index",
74 "api/odbc/index",
75 "api/auth/index",
76 "api/tls/index",
77 {
78 "type": "category",
79 "label": "HTTP",
80 "collapsible": true,
81 "collapsed": false,
82 "items": [{ "type": "autogenerated", "dirName": "api/HTTP" }]
83 }
84 ]
85}
86EOF
87fi
88
89echo ""
90echo "Release ${VERSION_LABEL} created successfully!"
91echo ""
92echo "Files created/modified:"
93echo " - ${VERSIONED_DOCS_DIR}/ (copied from docs/)"
94echo " - versions.json (updated)"
95echo " - ${SIDEBAR_FILE} (created)"
96