Skip to content

Commit b58f7ec

Browse files
committed
Merge branch 'master' into remove-sidebar-changelog
2 parents 13fcfa5 + 656aa03 commit b58f7ec

34 files changed

Lines changed: 1008 additions & 851 deletions

.github/workflows/manual_regenerate_models.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow regenerates Pydantic models (src/apify_client/_models.py) from the OpenAPI spec.
22
#
33
# It can be triggered in two ways:
4-
# 1. Automatically via workflow_dispatch from the apify-docs CI pipeline (with docs_pr_number and docs_workflow_run_id).
4+
# 1. Automatically via workflow_dispatch from the apify-docs CI pipeline.
55
# 2. Manually from the GitHub UI (without any inputs) to regenerate from the live published spec.
66

77
name: Regenerate models
@@ -46,13 +46,15 @@ jobs:
4646
steps:
4747
- name: Validate inputs
4848
if: inputs.docs_pr_number || inputs.docs_workflow_run_id
49+
env:
50+
DOCS_WORKFLOW_RUN_ID: ${{ inputs.docs_workflow_run_id }}
4951
run: |
5052
if [[ -n "$DOCS_PR_NUMBER" ]] && ! [[ "$DOCS_PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
5153
echo "::error::docs_pr_number must be a positive integer, got: $DOCS_PR_NUMBER"
5254
exit 1
5355
fi
54-
if [[ -n "${{ inputs.docs_workflow_run_id }}" ]] && ! [[ "${{ inputs.docs_workflow_run_id }}" =~ ^[0-9]+$ ]]; then
55-
echo "::error::docs_workflow_run_id must be a numeric run ID, got: ${{ inputs.docs_workflow_run_id }}"
56+
if [[ -n "$DOCS_WORKFLOW_RUN_ID" ]] && ! [[ "$DOCS_WORKFLOW_RUN_ID" =~ ^[0-9]+$ ]]; then
57+
echo "::error::docs_workflow_run_id must be a numeric run ID, got: $DOCS_WORKFLOW_RUN_ID"
5658
exit 1
5759
fi
5860
@@ -61,8 +63,8 @@ jobs:
6163
with:
6264
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
6365

64-
# If the branch already exists on the remote (e.g. from a previous run, possibly with
65-
# reviewer commits), check it out to build on top of it instead of starting fresh.
66+
# If the branch already exists on the remote (e.g. from a previous run, possibly with reviewer commits),
67+
# check it out to build on top of it instead of starting fresh.
6668
- name: Switch to existing branch or create a new one
6769
run: |
6870
if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then
@@ -76,7 +78,7 @@ jobs:
7678
# Skipped for manual runs — datamodel-codegen will fetch from the published spec URL instead.
7779
- name: Download OpenAPI spec artifact
7880
if: inputs.docs_workflow_run_id
79-
uses: actions/download-artifact@v4
81+
uses: actions/download-artifact@v8
8082
with:
8183
name: openapi-bundles
8284
path: openapi-spec
@@ -153,15 +155,30 @@ jobs:
153155
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
154156
PR_CREATED: ${{ steps.pr.outputs.created }}
155157
PR_URL: ${{ steps.pr.outputs.pr_url }}
158+
DOCS_PR_AUTHOR: ${{ inputs.docs_pr_author }}
156159
run: |
157-
if [[ "$PR_CREATED" = "true" ]]; then
158-
COMMENT="A PR to update the Python client models has been created: ${PR_URL}
160+
MENTION=""
161+
if [[ -n "$DOCS_PR_AUTHOR" ]]; then
162+
MENTION="@${DOCS_PR_AUTHOR} "
163+
fi
159164
160-
This was automatically triggered by OpenAPI specification changes in this PR."
165+
if [[ "$PR_CREATED" = "true" ]]; then
166+
HEADLINE="A companion PR has been opened in \`apify-client-python\` with the regenerated models: ${PR_URL}"
161167
else
162-
COMMENT="The Python client model PR has been updated with the latest OpenAPI spec changes: ${PR_URL}"
168+
HEADLINE="The companion \`apify-client-python\` PR has been updated with the latest spec changes: ${PR_URL}"
163169
fi
164170
171+
COMMENT=$(printf '%s\n' \
172+
"> [!IMPORTANT]" \
173+
"> **Action required** — ${MENTION}please coordinate this docs PR with the Python API client PR linked below." \
174+
">" \
175+
"> Because this PR modifies the OpenAPI specification, the generated models in \`apify-client-python\` must be regenerated to stay in sync. This has already been done automatically:" \
176+
">" \
177+
"> ${HEADLINE}" \
178+
">" \
179+
"> - Please make sure to review and merge both PRs together to keep the OpenAPI spec and API clients in sync." \
180+
"> - You can ask for review and help from the Tooling team if needed.")
181+
165182
gh pr comment "$DOCS_PR_NUMBER" \
166183
--repo apify/apify-docs \
167184
--body "$COMMENT"
@@ -173,5 +190,5 @@ jobs:
173190
run: |
174191
gh pr comment "$DOCS_PR_NUMBER" \
175192
--repo apify/apify-docs \
176-
--body "Python client model regeneration failed. [See workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})." \
193+
--body "Python client model regeneration failed. [See workflow run](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})." \
177194
|| echo "Warning: Failed to post failure comment to apify/apify-docs PR #$DOCS_PR_NUMBER."

.github/workflows/_release_docs.yaml renamed to .github/workflows/manual_release_docs.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Doc release
1+
name: Release docs
22

33
on:
44
# Runs when manually triggered from the GitHub UI.
@@ -8,17 +8,17 @@ on:
88
workflow_call:
99
inputs:
1010
ref:
11+
description: Git ref to checkout.
1112
required: true
1213
type: string
1314

1415
env:
1516
NODE_VERSION: 22
1617
PYTHON_VERSION: 3.14
17-
CHECKOUT_REF: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
1818

1919
jobs:
2020
release_docs:
21-
name: Doc release
21+
name: Release docs
2222
environment:
2323
name: github-pages
2424
permissions:
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@v6
3333
with:
3434
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
35-
ref: ${{ env.CHECKOUT_REF }}
35+
ref: ${{ inputs.ref || github.event.repository.default_branch }}
3636

3737
- name: Set up Node
3838
uses: actions/setup-node@v6
@@ -56,13 +56,13 @@ jobs:
5656
run: uv run poe update-docs-theme
5757

5858
- name: Commit the updated package.json and lockfile
59-
run: |
60-
git config user.name 'GitHub Actions'
61-
git config user.email 'github-actions[bot]@users.noreply.github.com'
62-
git add website/package.json
63-
git add website/yarn.lock
64-
git diff-index --quiet HEAD || git commit -m 'chore: Automatic docs theme update [skip ci]' || true
65-
git push
59+
uses: EndBug/add-and-commit@v10
60+
with:
61+
add: website/package.json website/yarn.lock
62+
message: "chore: Automatic docs theme update [skip ci]"
63+
default_author: github_actions
64+
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
65+
new_branch: ${{ github.event.repository.default_branch }}
6666

6767
- name: Build docs
6868
run: uv run poe build-docs

.github/workflows/manual_release_stable.yaml

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,69 +98,20 @@ jobs:
9898
version_number: ${{ needs.release_prepare.outputs.version_number }}
9999
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
100100

101-
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
101+
# Publish the package to PyPI using PyPA official GitHub action with OIDC authentication.
102102
- name: Publish package to PyPI
103103
uses: pypa/gh-action-pypi-publish@release/v1
104104

105105
version_docs:
106106
name: Version docs
107107
needs: [release_prepare, changelog_update, pypi_publish]
108-
runs-on: ubuntu-latest
109108
permissions:
110109
contents: write
111-
env:
112-
NODE_VERSION: 22
113-
PYTHON_VERSION: 3.14
114-
115-
steps:
116-
- name: Checkout repository
117-
uses: actions/checkout@v6
118-
with:
119-
ref: ${{ github.event.repository.default_branch }}
120-
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
121-
122-
- name: Set up Node
123-
uses: actions/setup-node@v6
124-
with:
125-
node-version: ${{ env.NODE_VERSION }}
126-
127-
- name: Set up Python
128-
uses: actions/setup-python@v6
129-
with:
130-
python-version: ${{ env.PYTHON_VERSION }}
131-
132-
- name: Set up uv package manager
133-
uses: astral-sh/setup-uv@v7
134-
with:
135-
python-version: ${{ env.PYTHON_VERSION }}
136-
137-
- name: Install Python dependencies
138-
run: uv run poe install-dev
139-
140-
- name: Install website dependencies
141-
run: |
142-
cd website
143-
yarn install
144-
145-
- name: Snapshot the current version
146-
run: |
147-
cd website
148-
VERSION="$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('../pyproject.toml').read_text())['project']['version'])")"
149-
MAJOR_MINOR="$(echo "$VERSION" | cut -d. -f1-2)"
150-
export MAJOR_MINOR
151-
rm -rf "versioned_docs/version-${MAJOR_MINOR}"
152-
rm -rf "versioned_sidebars/version-${MAJOR_MINOR}-sidebars.json"
153-
jq 'map(select(. != env.MAJOR_MINOR))' versions.json > tmp.json && mv tmp.json versions.json
154-
bash build_api_reference.sh
155-
npx docusaurus docs:version "$MAJOR_MINOR"
156-
npx docusaurus api:version "$MAJOR_MINOR"
157-
158-
- name: Commit and push the version snapshot
159-
uses: EndBug/add-and-commit@v10
160-
with:
161-
author_name: Apify Release Bot
162-
author_email: noreply@apify.com
163-
message: "docs: update versioned docs for ${{ needs.release_prepare.outputs.version_number }}"
110+
uses: ./.github/workflows/manual_version_docs.yaml
111+
with:
112+
# Commit the version docs changes on top of the changelog commit.
113+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
114+
secrets: inherit
164115

165116
doc_release:
166117
name: Doc release
@@ -169,8 +120,8 @@ jobs:
169120
contents: write
170121
pages: write
171122
id-token: write
172-
uses: ./.github/workflows/_release_docs.yaml
123+
uses: ./.github/workflows/manual_release_docs.yaml
173124
with:
174-
# Use the default branch to include both the changelog update and the versioned docs snapshot.
175-
ref: ${{ github.event.repository.default_branch }}
125+
# Commit the docs release changes on top of the version docs commit.
126+
ref: ${{ needs.version_docs.outputs.version_docs_commitish }}
176127
secrets: inherit
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Version docs
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
inputs:
10+
ref:
11+
description: Git ref to checkout.
12+
required: true
13+
type: string
14+
outputs:
15+
version_docs_commitish:
16+
description: The commit SHA of the versioned docs commit.
17+
value: ${{ jobs.version_docs.outputs.version_docs_commitish }}
18+
19+
concurrency:
20+
group: version-docs
21+
cancel-in-progress: false
22+
23+
permissions:
24+
contents: read
25+
26+
env:
27+
NODE_VERSION: "22"
28+
PYTHON_VERSION: "3.14"
29+
30+
jobs:
31+
version_docs:
32+
name: Version docs
33+
runs-on: ubuntu-latest
34+
outputs:
35+
version_docs_commitish: ${{ steps.resolve_commitish.outputs.commitish }}
36+
permissions:
37+
contents: write
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v6
42+
with:
43+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
44+
ref: ${{ inputs.ref || github.event.repository.default_branch }}
45+
46+
- name: Set up Node
47+
uses: actions/setup-node@v6
48+
with:
49+
node-version: ${{ env.NODE_VERSION }}
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v6
53+
with:
54+
python-version: ${{ env.PYTHON_VERSION }}
55+
56+
- name: Set up uv package manager
57+
uses: astral-sh/setup-uv@v7
58+
with:
59+
python-version: ${{ env.PYTHON_VERSION }}
60+
61+
- name: Install Python dependencies
62+
run: uv run poe install-dev
63+
64+
- name: Snapshot the current version
65+
id: snapshot
66+
run: |
67+
cd website
68+
corepack enable
69+
yarn install
70+
71+
# Extract version from pyproject.toml.
72+
FULL_VERSION="$(uv version --short)"
73+
MAJOR_MINOR_VERSION="$(echo "$FULL_VERSION" | cut -d. -f1-2)"
74+
MAJOR_VERSION="$(echo "$FULL_VERSION" | cut -d. -f1)"
75+
echo "version=$FULL_VERSION" >> "$GITHUB_OUTPUT"
76+
echo "Version: $FULL_VERSION, Major.Minor: $MAJOR_MINOR_VERSION, Major: $MAJOR_VERSION"
77+
78+
# Find the existing versions for this major in versions.json (if any).
79+
if [[ -f versions.json ]]; then
80+
OLD_VERSIONS="$(jq -r --arg major "$MAJOR_VERSION" '.[] | select(startswith($major + "."))' versions.json)"
81+
else
82+
OLD_VERSIONS=""
83+
echo "[]" > versions.json
84+
fi
85+
86+
# Remove all old versions for this major (if found).
87+
if [[ -n "$OLD_VERSIONS" ]]; then
88+
while IFS= read -r OLD_VERSION; do
89+
[[ -z "$OLD_VERSION" ]] && continue
90+
echo "Removing old version $OLD_VERSION for major $MAJOR_VERSION"
91+
rm -rf "versioned_docs/version-${OLD_VERSION}"
92+
rm -f "versioned_sidebars/version-${OLD_VERSION}-sidebars.json"
93+
done <<< "$OLD_VERSIONS"
94+
jq --arg major "$MAJOR_VERSION" 'map(select(startswith($major + ".") | not))' versions.json > tmp.json && mv tmp.json versions.json
95+
else
96+
echo "No existing versions found for major $MAJOR_VERSION, nothing to remove"
97+
fi
98+
99+
# Build API reference and create Docusaurus version snapshots.
100+
bash build_api_reference.sh
101+
uv run npx docusaurus docs:version "$MAJOR_MINOR_VERSION"
102+
uv run npx docusaurus api:version "$MAJOR_MINOR_VERSION"
103+
104+
- name: Commit and push versioned docs
105+
id: commit_versioned_docs
106+
uses: EndBug/add-and-commit@v10
107+
with:
108+
add: website/versioned_docs website/versioned_sidebars website/versions.json
109+
message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
110+
default_author: github_actions
111+
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
112+
new_branch: ${{ github.event.repository.default_branch }}
113+
114+
- name: Resolve output commitish
115+
id: resolve_commitish
116+
env:
117+
COMMIT_SHA: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
118+
run: |
119+
echo "commitish=${COMMIT_SHA:-$(git rev-parse HEAD)}" >> "$GITHUB_OUTPUT"

.github/workflows/on_master.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
contents: write
2929
pages: write
3030
id-token: write
31-
uses: ./.github/workflows/_release_docs.yaml
31+
uses: ./.github/workflows/manual_release_docs.yaml
3232
with:
3333
# Use the same ref as the one that triggered the workflow.
3434
ref: ${{ github.ref }}
@@ -112,7 +112,7 @@ jobs:
112112
contents: write
113113
pages: write
114114
id-token: write
115-
uses: ./.github/workflows/_release_docs.yaml
115+
uses: ./.github/workflows/manual_release_docs.yaml
116116
with:
117117
# Use the ref from the changelog update to include the updated changelog.
118118
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}

.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)