Skip to content

Fix Docusaurus versioning error in publish_website workflow#3218

Open
sdaulton wants to merge 1 commit into
meta-pytorch:mainfrom
sdaulton:export-D95305476
Open

Fix Docusaurus versioning error in publish_website workflow#3218
sdaulton wants to merge 1 commit into
meta-pytorch:mainfrom
sdaulton:export-D95305476

Conversation

@sdaulton
Copy link
Copy Markdown
Contributor

@sdaulton sdaulton commented Mar 5, 2026

Summary:
Fix Docusaurus versioning error when release workflow is re-run

Problem

The 'Create new docusaurus version' step in publish_website.yml fails with:

Error: [docs]: this version already exists! Use a version tag that does not already exist.

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:

  1. Extract the version tag and remove the optional 'v' prefix
  2. Check if versions.json exists and contains the version
  3. Skip versioning if the version already exists, otherwise proceed normally

This allows the workflow to be safely re-run without failing.

Differential Revision: D95305476

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 5, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 5, 2026

@sdaulton has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95305476.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.98%. Comparing base (ee72a65) to head (2c41d5b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant