# Publish the package: to PyPI when a release is published, or to # TestPyPI via a manual "Run workflow" dispatch (any branch) for dry-runs. # Publishing uses PyPI trusted publishing (OIDC) — no API tokens. # # NOTE: keep this filename (deploy.yml) — the PyPI and TestPyPI trusted # publishers are configured against it; renaming the file breaks # publishing until the publishers are updated on both indexes. name: Upload Python Package on: release: types: [published] # Manual TestPyPI dry-run from the Actions tab or # `gh workflow run deploy.yml --ref `. workflow_dispatch: permissions: contents: read jobs: # Re-run the full CI (lint + test matrix) on the exact ref being # published, so a release or dry-run can't ship untested code. ci: uses: ./.github/workflows/ci.yml permissions: contents: read publish: needs: - ci runs-on: ubuntu-latest timeout-minutes: 10 permissions: id-token: write steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.13" # Building needs only Poetry itself (poetry-core backend) — no # dependency install, no git history. - uses: snok/install-poetry@v1 - name: Build package run: poetry build - name: Publish package uses: pypa/gh-action-pypi-publish@v1.13.0 with: repository-url: ${{ github.event_name == 'release' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}