Fix Docusaurus versioning error in publish_website workflow#3218
Open
sdaulton wants to merge 1 commit into
Open
Fix Docusaurus versioning error in publish_website workflow#3218sdaulton wants to merge 1 commit into
sdaulton wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3218 +/- ##
==========================================
- Coverage 99.99% 99.98% -0.01%
==========================================
Files 219 219
Lines 21442 21442
==========================================
- Hits 21440 21438 -2
- Misses 2 4 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary:
Fix Docusaurus version deletion not matching 'v' prefixed directories
## Problem
The 'Delete existing similar versions from Docusaurus' step fails to find and delete existing versions when the release workflow is re-run. This causes the subsequent 'Create new docusaurus version' step to fail with:
```
Error: [docs]: this version already exists! Use a version tag that does not already exist.
```
## Root Cause
When Docusaurus creates a version with `yarn docusaurus docs:version v0.17.2`, it creates directories/files with the 'v' prefix:
- `versioned_docs/version-v0.17.2/`
- `versioned_sidebars/version-v0.17.2-sidebars.json`
But the delete step was stripping the 'v' prefix before searching:
```bash
MAJOR_MINOR_VERSION=$(cut -d '.' -f 1-2 <<< v0.17.2) # gives 'v0.17'
MAJOR_MINOR_VERSION=${MAJOR_MINOR_VERSION#v} # strips to '0.17'
for dir in website/versioned_docs/version-$MAJOR_MINOR_VERSION.* # looks for 'version-0.17.*'
```
The glob `version-0.17.*` never matches `version-v0.17.2/`, so nothing gets deleted.
## Solution
Search for both patterns (with and without 'v' prefix):
```bash
for pattern in "version-$MAJOR_MINOR_VERSION.*" "version-${MAJOR_MINOR_VERSION#v}.*"; do
```
Also added `-f` flag to `rm` for sidebars to avoid errors if file doesn't exist.
Reviewed By: saitcakmak
Differential Revision: D95305476
6c502e7 to
2c41d5b
Compare
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 5, 2026
Summary:
Fix Docusaurus version deletion not matching 'v' prefixed directories
## Problem
The 'Delete existing similar versions from Docusaurus' step fails to find and delete existing versions when the release workflow is re-run. This causes the subsequent 'Create new docusaurus version' step to fail with:
```
Error: [docs]: this version already exists! Use a version tag that does not already exist.
```
## Root Cause
When Docusaurus creates a version with `yarn docusaurus docs:version v0.17.2`, it creates directories/files with the 'v' prefix:
- `versioned_docs/version-v0.17.2/`
- `versioned_sidebars/version-v0.17.2-sidebars.json`
But the delete step was stripping the 'v' prefix before searching:
```bash
MAJOR_MINOR_VERSION=$(cut -d '.' -f 1-2 <<< v0.17.2) # gives 'v0.17'
MAJOR_MINOR_VERSION=${MAJOR_MINOR_VERSION#v} # strips to '0.17'
for dir in website/versioned_docs/version-$MAJOR_MINOR_VERSION.* # looks for 'version-0.17.*'
```
The glob `version-0.17.*` never matches `version-v0.17.2/`, so nothing gets deleted.
## Solution
Search for both patterns (with and without 'v' prefix):
```bash
for pattern in "version-$MAJOR_MINOR_VERSION.*" "version-${MAJOR_MINOR_VERSION#v}.*"; do
```
Also added `-f` flag to `rm` for sidebars to avoid errors if file doesn't exist.
Reviewed By: saitcakmak
Differential Revision: D95305476
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fix Docusaurus versioning error when release workflow is re-run
Problem
The 'Create new docusaurus version' step in publish_website.yml fails with:
This occurs when the release workflow is re-run for the same version (e.g., after a partial failure or manual re-trigger), because the version was already created and pushed to gh-pages in a previous run.
Solution
Make the versioning step idempotent by checking if the version already exists in versions.json before attempting to create it:
This allows the workflow to be safely re-run without failing.
Differential Revision: D95305476