Skip to content

Commit b4272b4

Browse files
authored
Separate source and documentation builds
1 parent 59e9778 commit b4272b4

2 files changed

Lines changed: 65 additions & 26 deletions

File tree

.github/workflows/source-and-docs-release.yml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
name: "Build Python source and docs artifacts"
2020

2121
jobs:
22-
build-source-and-docs:
22+
verify-input:
2323
runs-on: ubuntu-22.04
2424
steps:
2525
- name: "Workflow run information"
@@ -28,9 +28,6 @@ jobs:
2828
echo "git_commit: ${{ inputs.git_commit }}"
2929
echo "cpython_release: ${{ inputs.cpython_release }}"
3030
31-
- name: "Checkout python/release-tools"
32-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33-
3431
- name: "Checkout ${{ inputs.git_remote }}/cpython"
3532
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3633
with:
@@ -45,6 +42,21 @@ jobs:
4542
exit 1
4643
fi
4744
45+
build-source:
46+
runs-on: ubuntu-22.04
47+
needs:
48+
- verify-input
49+
steps:
50+
- name: "Checkout python/release-tools"
51+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
52+
53+
- name: "Checkout ${{ inputs.git_remote }}/cpython"
54+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
55+
with:
56+
repository: "${{ inputs.git_remote }}/cpython"
57+
ref: "v${{ inputs.cpython_release }}"
58+
path: "cpython"
59+
4860
- name: "Setup Python"
4961
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
5062
with:
@@ -55,45 +67,65 @@ jobs:
5567
python -m pip install --no-deps \
5668
-r requirements.txt
5769
70+
- name: "Build Python release artifacts"
71+
run: |
72+
cd cpython
73+
python ../release.py --export ${{ inputs.cpython_release }} --skip-docs
74+
75+
- name: "Upload the source artifacts"
76+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
77+
with:
78+
name: source
79+
path: |
80+
cpython/${{ inputs.cpython_release }}/src
81+
82+
build-docs:
83+
runs-on: ubuntu-22.04
84+
needs:
85+
- verify-input
86+
87+
# Docs aren't built for alpha or beta releases.
88+
if: ${{ !(contains(inputs.cpython_release, 'a') || contains(inputs.cpython_release, 'b')) }}
89+
90+
steps:
91+
- name: "Checkout ${{ inputs.git_remote }}/cpython"
92+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
93+
with:
94+
repository: "${{ inputs.git_remote }}/cpython"
95+
ref: "v${{ inputs.cpython_release }}"
96+
97+
- name: "Setup Python"
98+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
99+
with:
100+
python-version: 3.11
101+
58102
- name: "Install docs dependencies"
59-
# Docs aren't built for alpha or beta releases.
60-
if: ${{ !(contains(inputs.cpython_release, 'a') || contains(inputs.cpython_release, 'b')) }}
61103
run: |
62104
python -m pip install \
63-
-r cpython/Doc/requirements.txt
105+
-r Doc/requirements.txt
64106
65107
sudo apt-get update
66108
sudo apt-get install --yes --no-install-recommends \
67109
latexmk texlive-xetex xindy texinfo texlive-latex-base \
68110
texlive-fonts-recommended texlive-fonts-extra \
69111
texlive-full
70112
71-
- name: "Build Python release artifacts"
113+
- name: "Build docs"
72114
run: |
73-
cd cpython
74-
python ../release.py --export ${{ inputs.cpython_release }}
75-
76-
- name: "Upload the source artifacts"
77-
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
78-
with:
79-
name: source
80-
path: |
81-
cpython/${{ inputs.cpython_release }}/src
115+
cd Doc
116+
SPHINXOPTS="-j10" make dist
82117
83118
- name: "Upload the docs artifacts"
84119
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
85-
# Conditionally run this step if there is a 'docs/' directory.
86-
# Docs aren't built for alpha or beta releases.
87-
if: ${{ hashFiles(format('cpython/{0}/docs', inputs.cpython_release)) != '' }}
88120
with:
89121
name: docs
90122
path: |
91-
cpython/${{ inputs.cpython_release }}/docs
123+
Doc/dist/
92124
93125
test-source:
94126
runs-on: ubuntu-22.04
95127
needs:
96-
- build-source-and-docs
128+
- build-source
97129
steps:
98130
- name: "Download the source artifacts"
99131
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4

release.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ def get_arg_parser():
125125
p.add_option('-d', '--done',
126126
default=False, action='store_true',
127127
help='Do post-release cleanups (i.e. you\'re done!)')
128+
p.add_option('--skip-docs',
129+
default=False, action='store_true',
130+
help='Skip building the documentation during export')
128131
return p
129132

130133

@@ -278,7 +281,7 @@ def tarball(source, clamp_mtime):
278281
checksum_xz.hexdigest(), int(os.path.getsize(xz)), xz))
279282

280283

281-
def export(tag, silent=False):
284+
def export(tag, silent=False, skip_docs=False):
282285
make_dist(tag.text)
283286
print('Exporting tag:', tag.text)
284287
archivename = 'Python-%s' % tag.text
@@ -314,7 +317,9 @@ def export(tag, silent=False):
314317
# build docs *before* we do "blurb export"
315318
# because docs now depend on Misc/NEWS.d
316319
# and we remove Misc/NEWS.d as part of cleanup for export
317-
if tag.is_final or tag.level == 'rc':
320+
#
321+
# If --skip-docs is provided we don't build and docs.
322+
if not skip_docs and (tag.is_final or tag.level == 'rc'):
318323
docdist = build_docs()
319324

320325
print('Using blurb to build Misc/NEWS')
@@ -336,7 +341,7 @@ def export(tag, silent=False):
336341
for name in ('.azure-pipelines', '.git', '.github', '.hg'):
337342
shutil.rmtree(name, ignore_errors=True)
338343

339-
if tag.is_final or tag.level == 'rc':
344+
if not skip_docs and (tag.is_final or tag.level == 'rc'):
340345
shutil.copytree(docdist, 'docs')
341346

342347
with pushd(os.path.join(archivename, 'Doc')):
@@ -513,6 +518,8 @@ def main(argv):
513518
chdir_to_repo_root()
514519
parser = get_arg_parser()
515520
options, args = parser.parse_args(argv)
521+
if options.skip_docs and not options.export:
522+
error("--skip-docs option has no effect without --export")
516523
if len(args) != 2:
517524
if 'RELEASE_TAG' not in os.environ:
518525
parser.print_usage()
@@ -528,7 +535,7 @@ def main(argv):
528535
if options.tag:
529536
make_tag(tag)
530537
if options.export:
531-
export(tag)
538+
export(tag, skip_docs=options.skip_docs)
532539
if options.upload:
533540
upload(tag, options.upload)
534541
if options.done:

0 commit comments

Comments
 (0)