Skip to content

Commit 465115e

Browse files
vdusekclaude
andcommitted
refactor: Use defensive version lookup instead of glob-based deletion
Query versions.json for the specific existing version for a given major instead of aggressively globbing version-${MAJOR}.*. This means: - Major release (e.g. 3.0.0): nothing is deleted (new major, no prior minor) - Minor release (e.g. 3.1.0): only the exact old minor (3.0) is removed - Patch release (e.g. 3.1.1): only the exact current minor (3.1) is removed and recreated Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9577f24 commit 465115e

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

.github/workflows/manual_version_docs.yaml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,24 @@ jobs:
8787
MAJOR="$(echo "$VERSION" | cut -d. -f1)"
8888
echo "Version: $VERSION, Major.Minor: $MAJOR_MINOR, Major: $MAJOR"
8989
90-
# Remove ALL existing versions for this major (not just exact major.minor match).
91-
for dir in "versioned_docs/version-${MAJOR}."*; do
92-
if [[ -d "$dir" ]]; then
93-
echo "Removing $dir"
94-
rm -rf "$dir"
95-
fi
96-
done
97-
for file in "versioned_sidebars/version-${MAJOR}."*-sidebars.json; do
98-
if [[ -f "$file" ]]; then
99-
echo "Removing $file"
100-
rm -f "$file"
101-
fi
102-
done
103-
104-
# Update versions.json to remove entries for this major version.
90+
# Find the existing version for this major in versions.json (if any).
10591
if [[ -f versions.json ]]; then
106-
jq --arg major "$MAJOR" '[.[] | select((split(".")[0]) != $major)]' versions.json > tmp.json && mv tmp.json versions.json
92+
OLD_VERSION="$(jq -r --arg major "$MAJOR" '.[] | select(startswith($major + "."))' versions.json | head -1)"
10793
else
94+
OLD_VERSION=""
10895
echo "[]" > versions.json
10996
fi
11097
98+
# Remove only the specific old version for this major (if found).
99+
if [[ -n "$OLD_VERSION" ]]; then
100+
echo "Removing old version $OLD_VERSION for major $MAJOR"
101+
rm -rf "versioned_docs/version-${OLD_VERSION}"
102+
rm -f "versioned_sidebars/version-${OLD_VERSION}-sidebars.json"
103+
jq --arg old "$OLD_VERSION" '[.[] | select(. != $old)]' versions.json > tmp.json && mv tmp.json versions.json
104+
else
105+
echo "No existing version found for major $MAJOR, nothing to remove"
106+
fi
107+
111108
# Build API reference and create Docusaurus version snapshots.
112109
bash build_api_reference.sh
113110
uv run npx docusaurus docs:version "$MAJOR_MINOR"

0 commit comments

Comments
 (0)