Skip to content

Commit 4fa3e39

Browse files
vdusekclaude
andcommitted
ci: Extract docs versioning into reusable manual_version_docs.yaml workflow
Extract the inline `version_docs` job from `manual_release_stable.yaml` into a standalone workflow that can be triggered manually or called from the release pipeline. Key improvements: - Fix `api:version` ENOENT bug by running docusaurus commands through `uv run` - Clean up ALL versions for the same major (not just exact major.minor match) - Remove non-docs artifacts (pyproject.toml, .gitignore, caches) from snapshots Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f241ead commit 4fa3e39

6 files changed

Lines changed: 146 additions & 83 deletions

File tree

.github/workflows/manual_release_stable.yaml

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -107,71 +107,12 @@ jobs:
107107
version_docs:
108108
name: Version docs
109109
needs: [release_prepare, changelog_update, pypi_publish]
110-
runs-on: ubuntu-latest
111-
outputs:
112-
version_docs_commitish: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
113110
permissions:
114111
contents: write
115-
env:
116-
NODE_VERSION: 22
117-
PYTHON_VERSION: 3.14
118-
119-
steps:
120-
- name: Checkout repository
121-
uses: actions/checkout@v6
122-
with:
123-
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
124-
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
125-
126-
- name: Set up Node
127-
uses: actions/setup-node@v6
128-
with:
129-
node-version: ${{ env.NODE_VERSION }}
130-
131-
- name: Set up Python
132-
uses: actions/setup-python@v6
133-
with:
134-
python-version: ${{ env.PYTHON_VERSION }}
135-
136-
- name: Set up uv package manager
137-
uses: astral-sh/setup-uv@v7
138-
with:
139-
python-version: ${{ env.PYTHON_VERSION }}
140-
141-
- name: Install Python dependencies
142-
run: uv run poe install-dev
143-
144-
- name: Install website dependencies
145-
run: |
146-
cd website
147-
corepack enable
148-
yarn install
149-
150-
- name: Snapshot the current version
151-
run: |
152-
cd website
153-
VERSION="$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('../pyproject.toml').read_text())['project']['version'])")"
154-
MAJOR_MINOR="$(echo "$VERSION" | cut -d. -f1-2)"
155-
export MAJOR_MINOR
156-
# Remove existing version if present (patch releases override)
157-
rm -rf "versioned_docs/version-${MAJOR_MINOR}"
158-
rm -rf "versioned_sidebars/version-${MAJOR_MINOR}-sidebars.json"
159-
jq 'map(select(. != env.MAJOR_MINOR))' versions.json > tmp.json && mv tmp.json versions.json
160-
# Build API reference and create version snapshots
161-
bash build_api_reference.sh
162-
npx docusaurus docs:version "$MAJOR_MINOR"
163-
npx docusaurus api:version "$MAJOR_MINOR"
164-
# Changelog is not versioned - it is copied from root at build time
165-
rm -f "versioned_docs/version-${MAJOR_MINOR}/changelog.md"
166-
echo "changelog.md" > "versioned_docs/version-${MAJOR_MINOR}/.gitignore"
167-
168-
- name: Commit and push versioned docs
169-
id: commit_versioned_docs
170-
uses: EndBug/add-and-commit@v10
171-
with:
172-
add: "website/versioned_docs website/versioned_sidebars website/versions.json"
173-
message: "docs: version ${{ needs.release_prepare.outputs.version_number }} docs [skip ci]"
174-
default_author: github_actions
112+
uses: ./.github/workflows/manual_version_docs.yaml
113+
with:
114+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
115+
secrets: inherit
175116

176117
doc_release:
177118
name: Doc release
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Version docs
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
inputs:
7+
ref:
8+
description: "Git ref to checkout (branch, tag, or SHA). Defaults to the default branch."
9+
required: false
10+
type: string
11+
default: ""
12+
13+
# Runs when invoked by another workflow.
14+
workflow_call:
15+
inputs:
16+
ref:
17+
description: "Git ref to checkout (branch, tag, or SHA)"
18+
required: true
19+
type: string
20+
outputs:
21+
version_docs_commitish:
22+
description: "The commit SHA of the versioned docs commit"
23+
value: ${{ jobs.version_docs.outputs.version_docs_commitish }}
24+
25+
concurrency:
26+
group: version-docs
27+
cancel-in-progress: false
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
version_docs:
34+
name: Version docs
35+
runs-on: ubuntu-latest
36+
outputs:
37+
version_docs_commitish: ${{ steps.resolve_commitish.outputs.commitish }}
38+
permissions:
39+
contents: write
40+
env:
41+
NODE_VERSION: 22
42+
PYTHON_VERSION: "3.14"
43+
44+
steps:
45+
- name: Determine checkout ref
46+
id: resolve_ref
47+
run: |
48+
REF="${{ inputs.ref }}"
49+
if [ -z "$REF" ]; then
50+
REF="${{ github.event.repository.default_branch }}"
51+
fi
52+
echo "ref=$REF" >> "$GITHUB_OUTPUT"
53+
54+
- name: Checkout repository
55+
uses: actions/checkout@v6
56+
with:
57+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
58+
ref: ${{ steps.resolve_ref.outputs.ref }}
59+
60+
- name: Set up Node
61+
uses: actions/setup-node@v6
62+
with:
63+
node-version: ${{ env.NODE_VERSION }}
64+
65+
- name: Set up Python
66+
uses: actions/setup-python@v6
67+
with:
68+
python-version: ${{ env.PYTHON_VERSION }}
69+
70+
- name: Set up uv package manager
71+
uses: astral-sh/setup-uv@v7
72+
with:
73+
python-version: ${{ env.PYTHON_VERSION }}
74+
75+
- name: Install Python dependencies
76+
run: uv run poe install-dev
77+
78+
- name: Install website dependencies
79+
run: |
80+
cd website
81+
corepack enable
82+
yarn install
83+
84+
- name: Snapshot the current version
85+
run: |
86+
cd website
87+
88+
# Extract version from pyproject.toml.
89+
VERSION="$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('../pyproject.toml').read_text())['project']['version'])")"
90+
MAJOR_MINOR="$(echo "$VERSION" | cut -d. -f1-2)"
91+
MAJOR="$(echo "$VERSION" | cut -d. -f1)"
92+
echo "Version: $VERSION, Major.Minor: $MAJOR_MINOR, Major: $MAJOR"
93+
94+
# Remove ALL existing versions for this major (not just exact major.minor match).
95+
for dir in versioned_docs/version-${MAJOR}.*; do
96+
if [ -d "$dir" ]; then
97+
echo "Removing $dir"
98+
rm -rf "$dir"
99+
fi
100+
done
101+
for file in versioned_sidebars/version-${MAJOR}.*-sidebars.json; do
102+
if [ -f "$file" ]; then
103+
echo "Removing $file"
104+
rm -f "$file"
105+
fi
106+
done
107+
108+
# Update versions.json to remove entries for this major version.
109+
if [ -f versions.json ]; then
110+
jq --arg major "$MAJOR" '[.[] | select((split(".")[0]) != $major)]' versions.json > tmp.json && mv tmp.json versions.json
111+
else
112+
echo "[]" > versions.json
113+
fi
114+
115+
# Build API reference and create Docusaurus version snapshots.
116+
bash build_api_reference.sh
117+
uv run npx docusaurus docs:version "$MAJOR_MINOR"
118+
uv run npx docusaurus api:version "$MAJOR_MINOR"
119+
120+
# Clean up non-docs artifacts from the snapshot.
121+
rm -f "versioned_docs/version-${MAJOR_MINOR}/changelog.md"
122+
rm -f "versioned_docs/version-${MAJOR_MINOR}/pyproject.toml"
123+
rm -f "versioned_docs/version-${MAJOR_MINOR}/.gitignore"
124+
rm -rf "versioned_docs/version-${MAJOR_MINOR}/.ruff_cache"
125+
rm -rf "versioned_docs/version-${MAJOR_MINOR}/.ty_cache"
126+
127+
- name: Commit and push versioned docs
128+
id: commit_versioned_docs
129+
uses: EndBug/add-and-commit@v10
130+
with:
131+
add: "website/versioned_docs website/versioned_sidebars website/versions.json"
132+
message: "docs: version docs [skip ci]"
133+
default_author: github_actions
134+
135+
- name: Resolve output commitish
136+
id: resolve_commitish
137+
run: |
138+
SHA="${{ steps.commit_versioned_docs.outputs.commit_long_sha }}"
139+
if [ -z "$SHA" ]; then
140+
SHA="$(git rev-parse HEAD)"
141+
fi
142+
echo "commitish=$SHA" >> "$GITHUB_OUTPUT"

website/versioned_docs/version-0.6/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

website/versioned_docs/version-0.6/pyproject.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

website/versioned_docs/version-1.6/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

website/versioned_docs/version-1.6/pyproject.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)