Skip to content

Build Python source and docs artifacts #15

Build Python source and docs artifacts

Build Python source and docs artifacts #15

on:
workflow_dispatch:
inputs:
git_remote:
type: choice
description: "Git remote to checkout"
options:
- python
- Yhg1s
- pablogsal
- ambv
git_commit:
type: string
description: "Git commit to target for the release. Must use the full commit SHA, not the short ID"
cpython_release:
type: string
description: "CPython release number (ie '3.11.5', note without the 'v' prefix)"
name: "Build Python source and docs artifacts"
jobs:
verify-input:
runs-on: ubuntu-22.04
steps:
- name: "Workflow run information"
run: |
echo "git_remote: ${{ inputs.git_remote }}"
echo "git_commit: ${{ inputs.git_commit }}"
echo "cpython_release: ${{ inputs.cpython_release }}"
- name: "Checkout ${{ inputs.git_remote }}/cpython"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: "${{ inputs.git_remote }}/cpython"
ref: "v${{ inputs.cpython_release }}"
path: "cpython"
- name: "Verify CPython commit matches tag"
run: |
if [[ "${{ inputs.git_commit }}" != "$(cd cpython && git rev-parse HEAD)" ]]; then
echo "expected git commit ('${{ inputs.git_commit }}') didn't match tagged commit ('$(git rev-parse HEAD)')"
exit 1
fi
build-source:
runs-on: ubuntu-22.04
needs:
- verify-input
steps:
- name: "Checkout python/release-tools"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Checkout ${{ inputs.git_remote }}/cpython"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: "${{ inputs.git_remote }}/cpython"
ref: "v${{ inputs.cpython_release }}"
path: "cpython"
- name: "Setup Python"
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: 3.11
- name: "Install source dependencies"
run: |
python -m pip install --no-deps \
-r requirements.txt
- name: "Build Python release artifacts"
run: |
cd cpython
python ../release.py --export ${{ inputs.cpython_release }} --skip-docs
- name: "Upload the source artifacts"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: source
path: |
cpython/${{ inputs.cpython_release }}/src
build-docs:
runs-on: ubuntu-22.04
needs:
- verify-input
# Docs aren't built for alpha or beta releases.
if: ${{ !(contains(inputs.cpython_release, 'a') || contains(inputs.cpython_release, 'b')) }}
steps:
- name: "Checkout ${{ inputs.git_remote }}/cpython"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: "${{ inputs.git_remote }}/cpython"
ref: "v${{ inputs.cpython_release }}"
- name: "Setup Python"
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: 3.11
- name: "Install docs dependencies"
run: |
python -m pip install \
-r Doc/requirements.txt
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
latexmk texlive-xetex xindy texinfo texlive-latex-base \
texlive-fonts-recommended texlive-fonts-extra \
texlive-full
- name: "Build docs"
run: |
cd Doc
SPHINXOPTS="-j10" make dist
- name: "Upload the docs artifacts"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: docs
path: |
Doc/dist/
test-source:
runs-on: ubuntu-22.04
needs:
- build-source
steps:
- name: "Download the source artifacts"
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: source
- name: "Test Python source tarballs"
run: |
mkdir -p ./tmp/installation/
cp Python-${{ inputs.cpython_release }}.tgz ./tmp/
cd tmp/
tar xvf Python-${{ inputs.cpython_release }}.tgz
cd Python-${{ inputs.cpython_release }}
./configure "--prefix=$(realpath '../installation/')"
make -j
make install -j
cd ../installation
./bin/python3 -m test -uall