Skip to content

Commit 0d26276

Browse files
vdusekclaude
andauthored
ci: Extract docs versioning into reusable manual_version_docs.yaml workflow (#857)
## Summary - Extract the inline `version_docs` job from `manual_release_stable.yaml` into a standalone `manual_version_docs.yaml` workflow - The new workflow can be triggered manually (for docs fixes) or called from the release pipeline - Fix `api:version` ENOENT bug by running docusaurus commands through `uv run` (Python deps not available to bare `npx`) - Clean up ALL versions for the same major version, not just exact major.minor match - Remove non-docs artifacts (pyproject.toml, .gitignore, caches) from versioned doc snapshots --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fbbf06e commit 0d26276

File tree

3 files changed

+137
-60
lines changed

3 files changed

+137
-60
lines changed

.github/workflows/manual_release_stable.yaml

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

171115
doc_release:
172116
name: Doc release
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
env:
33+
NODE_VERSION: "22"
34+
PYTHON_VERSION: "3.14"
35+
36+
jobs:
37+
version_docs:
38+
name: Version docs
39+
runs-on: ubuntu-latest
40+
outputs:
41+
version_docs_commitish: ${{ steps.resolve_commitish.outputs.commitish }}
42+
permissions:
43+
contents: write
44+
45+
steps:
46+
- name: Determine checkout ref
47+
id: resolve_ref
48+
env:
49+
INPUT_REF: ${{ inputs.ref }}
50+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
51+
run: |
52+
REF="${INPUT_REF:-$DEFAULT_BRANCH}"
53+
echo "ref=$REF" >> "$GITHUB_OUTPUT"
54+
55+
- name: Checkout repository
56+
uses: actions/checkout@v6
57+
with:
58+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
59+
ref: ${{ steps.resolve_ref.outputs.ref }}
60+
61+
- name: Set up Node
62+
uses: actions/setup-node@v6
63+
with:
64+
node-version: ${{ env.NODE_VERSION }}
65+
66+
- name: Set up Python
67+
uses: actions/setup-python@v6
68+
with:
69+
python-version: ${{ env.PYTHON_VERSION }}
70+
71+
- name: Set up uv package manager
72+
uses: astral-sh/setup-uv@v7
73+
with:
74+
python-version: ${{ env.PYTHON_VERSION }}
75+
76+
- name: Install Python dependencies
77+
run: uv run poe install-dev
78+
79+
- name: Snapshot the current version
80+
id: snapshot
81+
run: |
82+
cd website
83+
corepack enable
84+
yarn install
85+
86+
# Extract version from pyproject.toml.
87+
FULL_VERSION="$(uv version --short)"
88+
MAJOR_MINOR_VERSION="$(echo "$FULL_VERSION" | cut -d. -f1-2)"
89+
MAJOR_VERSION="$(echo "$FULL_VERSION" | cut -d. -f1)"
90+
echo "version=$FULL_VERSION" >> "$GITHUB_OUTPUT"
91+
echo "Version: $FULL_VERSION, Major.Minor: $MAJOR_MINOR_VERSION, Major: $MAJOR_VERSION"
92+
93+
# Find the existing versions for this major in versions.json (if any).
94+
if [[ -f versions.json ]]; then
95+
OLD_VERSIONS="$(jq -r --arg major "$MAJOR_VERSION" '.[] | select(startswith($major + "."))' versions.json)"
96+
else
97+
OLD_VERSIONS=""
98+
echo "[]" > versions.json
99+
fi
100+
101+
# Remove all old versions for this major (if found).
102+
if [[ -n "$OLD_VERSIONS" ]]; then
103+
while IFS= read -r OLD_VERSION; do
104+
[[ -z "$OLD_VERSION" ]] && continue
105+
echo "Removing old version $OLD_VERSION for major $MAJOR_VERSION"
106+
rm -rf "versioned_docs/version-${OLD_VERSION}"
107+
rm -f "versioned_sidebars/version-${OLD_VERSION}-sidebars.json"
108+
done <<< "$OLD_VERSIONS"
109+
jq --arg major "$MAJOR_VERSION" 'map(select(startswith($major + ".") | not))' versions.json > tmp.json && mv tmp.json versions.json
110+
else
111+
echo "No existing versions found for major $MAJOR_VERSION, nothing to remove"
112+
fi
113+
114+
# Build API reference and create Docusaurus version snapshots.
115+
bash build_api_reference.sh
116+
uv run npx docusaurus docs:version "$MAJOR_MINOR_VERSION"
117+
uv run npx docusaurus api:version "$MAJOR_MINOR_VERSION"
118+
119+
- name: Commit and push versioned docs
120+
id: commit_versioned_docs
121+
uses: EndBug/add-and-commit@v10
122+
with:
123+
add: website/versioned_docs website/versioned_sidebars website/versions.json
124+
message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
125+
default_author: github_actions
126+
127+
- name: Resolve output commitish
128+
id: resolve_commitish
129+
env:
130+
COMMIT_SHA: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
131+
run: |
132+
echo "commitish=${COMMIT_SHA:-$(git rev-parse HEAD)}" >> "$GITHUB_OUTPUT"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Session.vim
6464
# Docs
6565
docs/changelog.md
6666
website/versioned_docs/*/changelog.md
67+
website/versioned_docs/*/pyproject.toml
6768

6869
# Website build artifacts, node dependencies
6970
website/build

0 commit comments

Comments
 (0)