Release #2
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: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| use-testpypi: | |
| description: 'Publish to TestPyPI instead of production PyPI (for dry-run rehearsals)' | |
| type: boolean | |
| default: false | |
| jobs: | |
| build-and-publish: | |
| name: Build & publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Build sdist + wheel | |
| run: | | |
| python -m pip install --upgrade pip build | |
| python -m build | |
| - name: Verify version is final (production target only) | |
| if: ${{ !inputs.use-testpypi }} | |
| run: | | |
| VERSION=$(ls dist/*.tar.gz | sed -E 's|.*-(.*)\.tar\.gz|\1|') | |
| echo "Built version: $VERSION" | |
| case "$VERSION" in | |
| *+*|*dev*) echo "Refusing to publish non-final version $VERSION to production PyPI"; exit 1 ;; | |
| esac | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: ${{ inputs.use-testpypi && 'https://test.pypi.org/legacy/' || '' }} | |
| skip-existing: true |