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