Skip to content

Commit 95628bc

Browse files
Copilotm-aciek
andauthored
Add daily schedule for docs generation across all supported Python versions (#15)
* Initial plan * Add daily schedule for docs generation across all supported Python versions Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/b0e718c1-2b7d-4374-9b3a-4d0e1dbff966 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Add workflow_dispatch trigger to schedule.yaml * Add push trigger to schedule workflow * Fix artifact name conflicts when building multiple Python versions Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/b711ead3-289d-44de-9c08-8c968aab9f71 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Add fail-fast: false to matrix strategy to not cancel other versions on failure Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/86dcc8d5-bc72-43ad-ad6b-64e168f986dc Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Fix artifact upload paths to use glob pattern for full patch version Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/f9555a17-c3d6-438e-be52-d7dfebc83362 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Pin Python version for 3.10 docs generation to Python 3.12 Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/3105de3a-da49-4857-92a8-751f23be01e7 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Bump actions/checkout from v4 to v5 to fix Node.js 20 deprecation warning Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/a51b39f3-45b2-4f1e-a9a0-4dc19d28b22a Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Fix fatal pathspec error in publish step by using git add 3/ instead of glob Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/e6511990-d118-4b63-89b8-f3aa03407544 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Fix publish step: use wildcard to copy artifact files regardless of full version in filename Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/7983fca3-745a-45ef-8934-9f02793d9a5f Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Fix concurrent gh-pages push race condition Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/ff727508-556a-4819-97bb-8302a5fffc95 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Skip versions with status 'planned' in schedule workflow Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/25d71400-c634-4b08-b01f-1e9ed73c4a2f Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> * Move git pull --rebase before copying artifacts in publish job Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/120a6d47-878f-4829-acb8-f27b85ecbfc2 Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com> Co-authored-by: Maciej Olko <maciej.olko@gmail.com>
1 parent c735098 commit 95628bc

File tree

2 files changed

+113
-50
lines changed

2 files changed

+113
-50
lines changed

.github/workflows/build.yaml

Lines changed: 81 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
run-name: build ${{ github.event.inputs.repository }}:${{ github.event.inputs.reference }}
1+
run-name: build ${{ inputs.repository }}:${{ inputs.reference }}
22
on:
33
workflow_dispatch:
44
inputs:
@@ -18,6 +18,32 @@ on:
1818
description: 'Publish to GitHub Pages'
1919
required: false
2020
default: false
21+
python_version:
22+
description: 'Python version used to generate docs'
23+
required: false
24+
default: '3'
25+
workflow_call:
26+
inputs:
27+
reference:
28+
description: 'Commit reference from CPython repository'
29+
default: '3.14'
30+
type: string
31+
dist_version:
32+
description: 'Dist version (compatible with patchlevel.py output)'
33+
default: '3.14'
34+
type: string
35+
repository:
36+
description: 'Repository to checkout'
37+
default: 'python/cpython'
38+
type: string
39+
publish:
40+
description: 'Publish to GitHub Pages'
41+
default: 'false'
42+
type: string
43+
python_version:
44+
description: 'Python version used to generate docs'
45+
default: '3'
46+
type: string
2147
permissions:
2248
contents: write
2349
jobs:
@@ -26,63 +52,63 @@ jobs:
2652
steps:
2753
- uses: actions/setup-python@master
2854
with:
29-
python-version: 3
55+
python-version: ${{ inputs.python_version }}
3056
- uses: actions/checkout@master
3157
with:
32-
repository: ${{ github.event.inputs.repository }}
33-
ref: ${{ github.event.inputs.reference }}
58+
repository: ${{ inputs.repository }}
59+
ref: ${{ inputs.reference }}
3460
- run: make venv
3561
working-directory: ./Doc
3662
- run: make dist-html
3763
working-directory: ./Doc
3864
- uses: actions/upload-artifact@master
3965
if: always()
4066
with:
41-
name: docs-html.zip
42-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-html.zip
67+
name: python-${{ inputs.dist_version }}-docs-html.zip
68+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-html.zip
4369
if-no-files-found: ignore
4470
- uses: actions/upload-artifact@master
4571
if: always()
4672
with:
47-
name: docs-html.tar.bz2
48-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-html.tar.bz2
73+
name: python-${{ inputs.dist_version }}-docs-html.tar.bz2
74+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-html.tar.bz2
4975
if-no-files-found: ignore
5076
build-text:
5177
runs-on: ubuntu-latest
5278
steps:
5379
- uses: actions/setup-python@master
5480
with:
55-
python-version: 3
81+
python-version: ${{ inputs.python_version }}
5682
- uses: actions/checkout@master
5783
with:
58-
repository: ${{ github.event.inputs.repository }}
59-
ref: ${{ github.event.inputs.reference }}
84+
repository: ${{ inputs.repository }}
85+
ref: ${{ inputs.reference }}
6086
- run: make venv
6187
working-directory: ./Doc
6288
- run: make dist-text
6389
working-directory: ./Doc
6490
- uses: actions/upload-artifact@master
6591
if: always()
6692
with:
67-
name: docs-text.zip
68-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-text.zip
93+
name: python-${{ inputs.dist_version }}-docs-text.zip
94+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-text.zip
6995
if-no-files-found: ignore
7096
- uses: actions/upload-artifact@master
7197
if: always()
7298
with:
73-
name: docs-text.tar.bz2
74-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-text.tar.bz2
99+
name: python-${{ inputs.dist_version }}-docs-text.tar.bz2
100+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-text.tar.bz2
75101
if-no-files-found: ignore
76102
build-texinfo:
77103
runs-on: ubuntu-latest
78104
steps:
79105
- uses: actions/setup-python@master
80106
with:
81-
python-version: 3
107+
python-version: ${{ inputs.python_version }}
82108
- uses: actions/checkout@master
83109
with:
84-
repository: ${{ github.event.inputs.repository }}
85-
ref: ${{ github.event.inputs.reference }}
110+
repository: ${{ inputs.repository }}
111+
ref: ${{ inputs.reference }}
86112
- run: make venv
87113
working-directory: ./Doc
88114
- run: sudo apt-get update && sudo apt-get install -y texinfo
@@ -91,45 +117,45 @@ jobs:
91117
- uses: actions/upload-artifact@master
92118
if: always()
93119
with:
94-
name: docs-texinfo.zip
95-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-texinfo.zip
120+
name: python-${{ inputs.dist_version }}-docs-texinfo.zip
121+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-texinfo.zip
96122
if-no-files-found: ignore
97123
- uses: actions/upload-artifact@master
98124
if: always()
99125
with:
100-
name: docs-texinfo.tar.bz2
101-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-texinfo.tar.bz2
126+
name: python-${{ inputs.dist_version }}-docs-texinfo.tar.bz2
127+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-texinfo.tar.bz2
102128
if-no-files-found: ignore
103129
build-epub:
104130
runs-on: ubuntu-latest
105131
steps:
106132
- uses: actions/setup-python@master
107133
with:
108-
python-version: 3
134+
python-version: ${{ inputs.python_version }}
109135
- uses: actions/checkout@master
110136
with:
111-
repository: ${{ github.event.inputs.repository }}
112-
ref: ${{ github.event.inputs.reference }}
137+
repository: ${{ inputs.repository }}
138+
ref: ${{ inputs.reference }}
113139
- run: make venv
114140
working-directory: ./Doc
115141
- run: make dist-epub
116142
working-directory: ./Doc
117143
- uses: actions/upload-artifact@master
118144
if: always()
119145
with:
120-
name: docs.epub
121-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs.epub
146+
name: python-${{ inputs.dist_version }}-docs.epub
147+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs.epub
122148
if-no-files-found: ignore
123149
build-pdf:
124150
runs-on: ubuntu-latest
125151
steps:
126152
- uses: actions/setup-python@master
127153
with:
128-
python-version: 3
154+
python-version: ${{ inputs.python_version }}
129155
- uses: actions/checkout@master
130156
with:
131-
repository: ${{ github.event.inputs.repository }}
132-
ref: ${{ github.event.inputs.reference }}
157+
repository: ${{ inputs.repository }}
158+
ref: ${{ inputs.reference }}
133159
- run: make venv
134160
working-directory: ./Doc
135161
- run: sudo apt-get update && sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy librsvg2-bin
@@ -138,32 +164,37 @@ jobs:
138164
- uses: actions/upload-artifact@master
139165
if: always()
140166
with:
141-
name: pdf-logs.zip
167+
name: python-${{ inputs.dist_version }}-pdf-logs.zip
142168
path: |
143169
./Doc/build/latex/*.log
144170
./Doc/build/latex/*.tex
145171
- uses: actions/upload-artifact@master
146172
if: always()
147173
with:
148-
name: docs-pdf-a4.zip
149-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-pdf-a4.zip
174+
name: python-${{ inputs.dist_version }}-docs-pdf-a4.zip
175+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-pdf-a4.zip
150176
if-no-files-found: ignore
151177
- uses: actions/upload-artifact@master
152178
if: always()
153179
with:
154-
name: docs-pdf-a4.tar.bz2
155-
path: ./Doc/dist/python-${{ github.event.inputs.dist_version }}-docs-pdf-a4.tar.bz2
180+
name: python-${{ inputs.dist_version }}-docs-pdf-a4.tar.bz2
181+
path: ./Doc/dist/python-${{ inputs.dist_version }}*-docs-pdf-a4.tar.bz2
156182
if-no-files-found: ignore
157183
publish:
158184
needs: [build-html, build-text, build-texinfo, build-epub, build-pdf]
159-
if: ${{ !cancelled() && github.event.inputs.publish == 'true' }}
185+
if: ${{ !cancelled() && inputs.publish == 'true' }}
160186
runs-on: ubuntu-latest
187+
concurrency:
188+
group: gh-pages-publish
189+
cancel-in-progress: false
161190
steps:
162191
- name: Checkout gh-pages branch
163-
uses: actions/checkout@v4
192+
uses: actions/checkout@v5
164193
with:
165194
ref: gh-pages
166195
path: gh-pages
196+
- name: Pull latest gh-pages
197+
run: git -C gh-pages pull --rebase origin gh-pages
167198
- name: Download all artifacts
168199
uses: actions/download-artifact@master
169200
with:
@@ -172,32 +203,32 @@ jobs:
172203
run: |
173204
mkdir -p gh-pages/3
174205
# PDF
175-
cp artifacts/docs-pdf-a4.zip/python-${{ github.event.inputs.dist_version }}-docs-pdf-a4.zip gh-pages/3/ 2>/dev/null || true
176-
cp artifacts/docs-pdf-a4.tar.bz2/python-${{ github.event.inputs.dist_version }}-docs-pdf-a4.tar.bz2 gh-pages/3/ 2>/dev/null || true
206+
cp artifacts/python-${{ inputs.dist_version }}-docs-pdf-a4.zip/* gh-pages/3/ 2>/dev/null || true
207+
cp artifacts/python-${{ inputs.dist_version }}-docs-pdf-a4.tar.bz2/* gh-pages/3/ 2>/dev/null || true
177208
# HTML
178-
cp artifacts/docs-html.zip/python-${{ github.event.inputs.dist_version }}-docs-html.zip gh-pages/3/ 2>/dev/null || true
179-
cp artifacts/docs-html.tar.bz2/python-${{ github.event.inputs.dist_version }}-docs-html.tar.bz2 gh-pages/3/ 2>/dev/null || true
209+
cp artifacts/python-${{ inputs.dist_version }}-docs-html.zip/* gh-pages/3/ 2>/dev/null || true
210+
cp artifacts/python-${{ inputs.dist_version }}-docs-html.tar.bz2/* gh-pages/3/ 2>/dev/null || true
180211
# Text
181-
cp artifacts/docs-text.zip/python-${{ github.event.inputs.dist_version }}-docs-text.zip gh-pages/3/ 2>/dev/null || true
182-
cp artifacts/docs-text.tar.bz2/python-${{ github.event.inputs.dist_version }}-docs-text.tar.bz2 gh-pages/3/ 2>/dev/null || true
212+
cp artifacts/python-${{ inputs.dist_version }}-docs-text.zip/* gh-pages/3/ 2>/dev/null || true
213+
cp artifacts/python-${{ inputs.dist_version }}-docs-text.tar.bz2/* gh-pages/3/ 2>/dev/null || true
183214
# Texinfo
184-
cp artifacts/docs-texinfo.zip/python-${{ github.event.inputs.dist_version }}-docs-texinfo.zip gh-pages/3/ 2>/dev/null || true
185-
cp artifacts/docs-texinfo.tar.bz2/python-${{ github.event.inputs.dist_version }}-docs-texinfo.tar.bz2 gh-pages/3/ 2>/dev/null || true
215+
cp artifacts/python-${{ inputs.dist_version }}-docs-texinfo.zip/* gh-pages/3/ 2>/dev/null || true
216+
cp artifacts/python-${{ inputs.dist_version }}-docs-texinfo.tar.bz2/* gh-pages/3/ 2>/dev/null || true
186217
# EPUB
187-
cp artifacts/docs.epub/python-${{ github.event.inputs.dist_version }}-docs.epub gh-pages/3/ 2>/dev/null || true
218+
cp artifacts/python-${{ inputs.dist_version }}-docs.epub/* gh-pages/3/ 2>/dev/null || true
188219
- name: Commit generated archives
189220
id: commit
190221
run: |
191222
cd gh-pages
192223
git config user.name github-actions
193224
git config user.email github-actions@github.com
194-
git add 3/python-${{ github.event.inputs.dist_version }}-docs-* || true
225+
git add 3/
195226
if git diff --cached --quiet; then
196227
echo "No documentation archives to commit"
197-
echo "has_changes=false" >> $GITHUB_OUTPUT
228+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
198229
else
199-
git commit -m "Update documentation archives for ${{ github.event.inputs.dist_version }}"
200-
echo "has_changes=true" >> $GITHUB_OUTPUT
230+
git commit -m "Update documentation archives for ${{ inputs.dist_version }}"
231+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
201232
fi
202233
- name: Push commit
203234
if: steps.commit.outputs.has_changes == 'true'

.github/workflows/schedule.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: scheduled docs generation
2+
on:
3+
schedule:
4+
- cron: '0 5 * * *'
5+
workflow_dispatch:
6+
push:
7+
permissions:
8+
contents: write
9+
jobs:
10+
get-versions:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
versions: ${{ steps.get-versions.outputs.versions }}
14+
steps:
15+
- name: Get supported Python versions
16+
id: get-versions
17+
run: |
18+
versions=$(curl -sf https://peps.python.org/api/release-cycle.json | \
19+
jq -c '[to_entries[] | select(.value.status != "end-of-life" and .value.status != "planned") | {version: .key, branch: (.value.branch // .key), python_version: (if .key == "3.10" then "3.12" else "3" end)}]')
20+
echo "versions=$versions" >> "$GITHUB_OUTPUT"
21+
build:
22+
needs: get-versions
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include: ${{ fromJson(needs.get-versions.outputs.versions) }}
27+
uses: ./.github/workflows/build.yaml
28+
with:
29+
reference: ${{ matrix.branch }}
30+
dist_version: ${{ matrix.version }}
31+
python_version: ${{ matrix.python_version }}
32+
publish: ${{ 'true' }}

0 commit comments

Comments
 (0)