Skip to content

chore: use MonomorphizationPass (#732) #168

chore: use MonomorphizationPass (#732)

chore: use MonomorphizationPass (#732) #168

name: Pure Python wheels 🐍
# Builds and publishes the pure wheels on pypi.
#
# This does not include the main `tket2-py` package, which is built using maturin.
# See `python-wheels.yml` for that workflow.
#
# When running on a release event or as a workflow dispatch for a tag,
# and if the tag matches `{package}-v*`,
# this workflow will publish the wheels to pypi.
# If the version is already published, pypi just ignores it.
on:
workflow_dispatch:
push:
branches:
- main
release:
types:
- published
env:
# Pinned version for the uv package manager
UV_VERSION: "0.4.18"
jobs:
build-publish:
name: Package and publish wheels
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
strategy:
matrix:
target:
- { dir: tket2-eccs, name: tket2_eccs}
- { dir: tket2-exts, name: tket2_exts}
steps:
# Check the release tag against the package name
#
# Skip the workflow when triggered by a release event for any other package.
- name: Check tag
id: check-tag
run: |
echo "run=$SHOULD_RUN" >> $GITHUB_OUTPUT
env:
SHOULD_RUN: ${{ github.event_name != 'release' || ( github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) }}
- uses: actions/checkout@v4
if: ${{ steps.check-tag.outputs.run == 'true' }}
- name: Run sccache-cache
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: mozilla-actions/[email protected]
- name: Set up uv
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: astral-sh/setup-uv@v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install Python 3.13
run: uv python install 3.13
if: ${{ steps.check-tag.outputs.run == 'true' }}
- name: Build sdist and wheels
if: ${{ steps.check-tag.outputs.run == 'true' }}
run: |
cd ${{ matrix.target.dir }}
uvx --from build pyproject-build --installer uv --outdir ../dist
- name: Upload the built packages as artifacts
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target.dir }}-sdist
path: |
dist/*.tar.gz
dist/*.whl
- name: Test installing the built wheels
if: ${{ steps.check-tag.outputs.run == 'true' }}
run: |
echo "Testing the newly built ${{ matrix.target.name }} wheels..."
uv run -f dist --with ${{ matrix.target.name }} --refresh-package ${{ matrix.target.name }} --no-project -- python -c "import ${{ matrix.target.name }}"
uvx twine check --strict dist/*
- name: Report
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) }}
run: |
echo "Publishing to PyPI..."
echo "Based on the following workflow variables, this is a new version tag push:"
echo " - event_name: ${{ github.event_name }}"
echo " - ref_type: ${{ github.ref_type }}"
echo " - ref: ${{ github.ref }}"
- name: Publish package distributions to PyPI
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
skip-existing: true