v2026.5.24 #4
Workflow file for this run
This file contains hidden or 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
| name: publish | |
| # Builds the package and uploads it to PyPI when a GitHub release is | |
| # published. Requires `PYPI_API_TOKEN` to be set as a repo secret | |
| # (Settings → Secrets and variables → Actions). Use a project-scoped | |
| # PyPI API token, never a user-scoped one. | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # `pypa/gh-action-pypi-publish` supports OIDC trusted publishing | |
| # in addition to API tokens — `id-token: write` enables that | |
| # without changing the action invocation below. Falls back to | |
| # PYPI_API_TOKEN when trusted publishing isn't configured. | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| # The release tag is the authoritative version source — overwrite | |
| # pyproject.toml and setup.py with the tag name (minus the leading | |
| # `v`) so PyPI sees the value the release was cut at, regardless | |
| # of what the SDK was synced with. Enables intra-day releases via | |
| # PEP 440 post-release tags: `v2026.5.23-1` → `2026.5.23.post1`, | |
| # `v2026.5.23-2` → `2026.5.23.post2`, etc. (PyPI's PEP 440 | |
| # normalizer rewrites the dash form on upload.) Skipped for | |
| # workflow_dispatch runs — the manual trigger uses whatever's | |
| # already in the working tree. | |
| - name: Set version from release tag | |
| if: github.event_name == 'release' | |
| run: | | |
| set -eu | |
| TAG="${GITHUB_REF_NAME#v}" | |
| echo "Using version: $TAG (from tag $GITHUB_REF_NAME)" | |
| sed -i -E "s/^version = \".*\"/version = \"${TAG}\"/" pyproject.toml | |
| sed -i -E "s/^VERSION = \".*\"/VERSION = \"${TAG}\"/" setup.py | |
| grep -E '^version|^VERSION' pyproject.toml setup.py | |
| - name: Install build backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Build sdist + wheel | |
| run: python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |