Skip to content

Commit afea633

Browse files
authored
Add create-release script + workflow (#1392)
1 parent 0f244f3 commit afea633

2 files changed

Lines changed: 142 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create Versioned Docs Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version number (e.g. 2.0)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
create-release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout trunk
20+
uses: actions/checkout@v4
21+
with:
22+
ref: trunk
23+
24+
- name: Create release branch and run release script
25+
working-directory: website
26+
run: |
27+
git checkout -b "release/docs-v${{ inputs.version }}"
28+
./create-release.sh "${{ inputs.version }}"
29+
30+
- name: Commit and push
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
git add -A
35+
git commit -m "Add versioned docs for v${{ inputs.version }}"
36+
git push origin "release/docs-v${{ inputs.version }}"
37+
38+
- name: Create Pull Request
39+
env:
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
gh pr create \
43+
--base trunk \
44+
--head "release/docs-v${{ inputs.version }}" \
45+
--title "Add versioned docs for v${{ inputs.version }}" \
46+
--body "Creates versioned documentation snapshot for v${{ inputs.version }}." \
47+
--label "area/docs"

website/create-release.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
set -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+
17+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18+
cd "$SCRIPT_DIR"
19+
20+
if [ $# -ne 1 ]; then
21+
echo "Usage: $0 <version>"
22+
echo "Example: $0 2.1"
23+
exit 1
24+
fi
25+
26+
VERSION="$1"
27+
VERSION_LABEL="${VERSION}.x"
28+
VERSIONED_DOCS_DIR="versioned_docs/version-${VERSION_LABEL}"
29+
SIDEBAR_FILE="versioned_sidebars/version-${VERSION_LABEL}-sidebars.json"
30+
31+
# Validate that the version doesn't already exist
32+
if [ -d "$VERSIONED_DOCS_DIR" ]; then
33+
echo "Error: Version ${VERSION_LABEL} already exists at ${VERSIONED_DOCS_DIR}"
34+
exit 1
35+
fi
36+
37+
if grep -q "\"${VERSION_LABEL}\"" versions.json; then
38+
echo "Error: Version ${VERSION_LABEL} already listed in versions.json"
39+
exit 1
40+
fi
41+
42+
# Step 1: Copy docs/ to versioned_docs/version-<version>.x/
43+
echo "Copying docs/ to ${VERSIONED_DOCS_DIR}/"
44+
cp -r docs "$VERSIONED_DOCS_DIR"
45+
46+
# Step 2: Prepend version to versions.json
47+
echo "Adding \"${VERSION_LABEL}\" to versions.json"
48+
EXISTING=$(cat versions.json)
49+
echo "$EXISTING" | python3 -c "
50+
import json, sys
51+
versions = json.load(sys.stdin)
52+
versions.insert(0, '${VERSION_LABEL}')
53+
print(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
58+
echo "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.
61+
LATEST_SIDEBAR=$(ls -1 versioned_sidebars/*.json 2>/dev/null | sort -V | tail -1)
62+
63+
if [ -n "$LATEST_SIDEBAR" ]; then
64+
cp "$LATEST_SIDEBAR" "$SIDEBAR_FILE"
65+
else
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+
}
86+
EOF
87+
fi
88+
89+
echo ""
90+
echo "Release ${VERSION_LABEL} created successfully!"
91+
echo ""
92+
echo "Files created/modified:"
93+
echo " - ${VERSIONED_DOCS_DIR}/ (copied from docs/)"
94+
echo " - versions.json (updated)"
95+
echo " - ${SIDEBAR_FILE} (created)"

0 commit comments

Comments
 (0)