release #1
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
| # Build and publish cuPeriod to PyPI via Trusted Publishing (OIDC — no API tokens). | |
| # | |
| # One-time setup before this works: | |
| # 1. Create the distribution project on PyPI and TestPyPI (a first manual upload, or | |
| # reserve the name). | |
| # 2. Add a "Trusted Publisher" on each: | |
| # PyPI: project → Settings → Publishing → add GitHub publisher | |
| # TestPyPI: same, on test.pypi.org | |
| # with owner: tjayasinghe repo: cuPeriod workflow: release.yml | |
| # and environment names `pypi` / `testpypi` respectively. | |
| # 3. Create matching GitHub Environments named `pypi` and `testpypi` | |
| # (Settings → Environments). | |
| # | |
| # Usage: | |
| # * Push a tag `vX.Y.Z` → builds and publishes to PyPI. | |
| # * Run manually (workflow_dispatch) → builds and publishes to TestPyPI (a dry run). | |
| name: release | |
| on: | |
| push: | |
| tags: ["v*"] | |
| workflow_dispatch: {} | |
| jobs: | |
| build: | |
| name: build distributions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Build sdist + wheel | |
| run: uv build | |
| - name: Check metadata | |
| run: uvx twine check dist/* | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| testpypi: | |
| name: publish to TestPyPI (dry run) | |
| if: github.event_name == 'workflow_dispatch' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: testpypi | |
| permissions: | |
| id-token: write # required for Trusted Publishing | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| pypi: | |
| name: publish to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write # required for Trusted Publishing | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: pypa/gh-action-pypi-publish@release/v1 |