Main packaging #54
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]> | |
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause | |
name: Main packaging | |
on: | |
workflow_dispatch: | |
inputs: | |
pre_test: | |
default: false | |
type: boolean | |
test: | |
default: true | |
type: boolean | |
publish: | |
default: false | |
type: boolean | |
conda: | |
default: false | |
type: boolean | |
py_version: | |
default: '3.12' | |
type: string | |
runner: | |
default: 'ubuntu-latest' | |
type: string | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# TODO sync sourcebuild patches & third-party licenses with pdfium-binaries on before release? | |
# TODO(201): schedule test_setup and test_sourcebuild separately | |
test_setup: | |
if: ${{ inputs.pre_test }} | |
uses: ./.github/workflows/test_setup.yaml | |
test_sourcebuild: | |
if: ${{ inputs.pre_test }} | |
uses: ./.github/workflows/test_sourcebuild.yaml | |
build: | |
runs-on: ${{ inputs.runner }} | |
outputs: | |
new_version: ${{ steps.get_version.outputs.new_version }} | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ inputs.py_version }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
fetch-depth: 0 | |
- name: Install/update dependencies | |
run: python3 -m pip install -U -r req/setup.txt -r req/test.txt -r req/utilities.txt | |
# NOTE autorelease sets a tag, but it's just temporary for informational purpose and does not match the actually published tag | |
# We can't push the tag at this stage because we don't know the outcome of the following jobs yet | |
# In the future, we might want to move away from using a git branch & tag at this stage, and instead transfer the changes as a patchfile. | |
- name: Run autorelease script | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "geisserml" | |
git reset --hard HEAD | |
# autorelease.py --register automatically switches us onto the autorelease_tmp branch | |
python3 setupsrc/pypdfium2_setup/autorelease.py --register | |
- name: Get new version | |
id: get_version | |
run: echo "new_version=$(git describe --abbrev=0)" >> $GITHUB_OUTPUT | |
- name: Install pypdfium2 | |
run: python3 -m pip install --no-build-isolation -e . | |
- name: Run test suite | |
run: ./run test | |
- name: Run PyPI packaging script | |
run: ./run packaging_pypi | |
- name: Upload release notes | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release_notes | |
path: RELEASE.md | |
- name: Upload packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: dist/* | |
# tag deliberately not pushed (see above) | |
- name: Push autorelease_tmp branch | |
run: git push -u origin autorelease_tmp | |
test: | |
if: ${{ inputs.test }} | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
# NOTE On GH actions, macOS <=13 is Intel, whereas macOS >=14 will be ARM64 | |
os: ['ubuntu-latest', 'ubuntu-24.04-arm', 'macos-13', 'macos-14', 'windows-latest'] | |
py: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
include: | |
- os: ubuntu-latest | |
wheel: dist/*manylinux_*_x86_64*.whl | |
- os: ubuntu-24.04-arm | |
wheel: dist/*manylinux_*_aarch64*.whl | |
- os: macos-13 | |
wheel: dist/*macosx_*_x86_64*.whl | |
- os: macos-14 | |
wheel: dist/*macosx_*_arm64*.whl | |
- os: windows-latest | |
wheel: dist/*win_amd64.whl | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py }} | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: autorelease_tmp | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
- name: Install dependencies | |
run: | | |
python3 -m pip install -U pip setuptools auditwheel | |
python3 -m pip install -U pytest pillow numpy | |
- name: Run auditwheel (informational) | |
if: ${{ startsWith(matrix.os, 'ubuntu') }} | |
run: python3 -m auditwheel show ${{ matrix.wheel }} | |
- name: Install pypdfium2 from artifact | |
run: python3 -m pip install ${{ matrix.wheel }} | |
- name: Run Test Suite | |
run: ./run test | |
publish: | |
needs: [test_setup, test_sourcebuild, build, test] | |
if: ${{ inputs.publish && !cancelled() && !contains(needs.*.result, 'failure') }} | |
runs-on: ${{ inputs.runner }} | |
environment: release # PyPI upload via "trusted publishing" | |
permissions: | |
id-token: write # PyPI upload via "trusted publishing" | |
contents: write # autorelease repository changes | |
actions: write # GH pages workflow-dispatch | |
steps: | |
- name: Check out repository (deep) | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ inputs.py_version }} | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
- name: Download release notes | |
uses: actions/download-artifact@v4 | |
with: | |
name: release_notes | |
- name: Apply and push repository changes | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "geisserml" | |
git checkout main | |
git merge origin/autorelease_tmp | |
git tag -a ${{ needs.build.outputs.new_version }} -m "Autorelease" | |
git push | |
git push --tags | |
git checkout stable | |
git reset --hard main | |
git push --force | |
git checkout main | |
# Upload to TestPyPI / PyPI via "trusted publishing". | |
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
# https://docs.pypi.org/trusted-publishers/using-a-publisher/ | |
# https://github.com/pypa/gh-action-pypi-publish | |
- name: Publish to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
packages-dir: dist/ # the default | |
attestations: false # https://github.com/pypa/gh-action-pypi-publish/issues/283#issuecomment-2499296440 | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: dist/ # the default | |
# TODO make sure RELEASE.md is less than 125000 chars, otherwise attach it as an artifact and write a new body pointing out the attachment. We've been hit by this limit in v4.30.1, due to an excessively long pdfium commit log. | |
- name: Publish to GitHub | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: 'dist/*' | |
bodyFile: 'RELEASE.md' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ needs.build.outputs.new_version }} | |
prerelease: ${{ contains(needs.build.outputs.new_version, 'b') }} | |
- name: Trigger GH Pages rebuild | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: gh_pages.yaml # takes no inputs | |
conda_trigger: | |
needs: [build, test, publish] | |
if: ${{ inputs.conda && !cancelled() && !contains(needs.*.result, 'failure') }} | |
runs-on: ${{ inputs.runner }} | |
steps: | |
- name: Trigger conda pypdfium2_helpers build | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
# FIXME input not respected for py_version here | |
workflow: conda.yaml | |
inputs: | | |
{ | |
"package": "helpers", | |
"pdfium_ver": "latest", | |
"new_only": "false", | |
"test": "true", | |
"publish": "${{ inputs.publish }}", | |
"py_version": "3.12" | |
} | |
cleanup: | |
needs: [build, test, publish, conda_trigger] | |
if: ${{ !cancelled() }} | |
runs-on: ${{ inputs.runner }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
- name: Remove temporary branch | |
run: git push origin --delete autorelease_tmp |