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: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Ensure Python (uses your .python-version / requires-python) | |
| run: uv python install | |
| - name: Verify version matches release tag | |
| shell: bash | |
| run: | | |
| TAG="${GITHUB_EVENT_NAME:-release}" | |
| # On release event, the tag name is here: | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| VERSION="$(uv version --short)" | |
| echo "tag=${TAG_NAME} pyproject=${VERSION}" | |
| # Accept tags like v1.2.3 -> 1.2.3 | |
| TAG_STRIPPED="${TAG_NAME#v}" | |
| if [ "${VERSION}" != "${TAG_STRIPPED}" ]; then | |
| echo "::error::Version mismatch detected!" | |
| echo "Release tag: ${TAG_NAME}" | |
| echo "pyproject.toml version: ${VERSION}" | |
| echo "" | |
| echo "To fix:" | |
| echo " - Ensure the release tag matches the version in pyproject.toml (e.g., tag 'v${VERSION}')" | |
| echo " - If the tag is incorrect, delete and recreate the release with the correct tag." | |
| exit 1 | |
| fi | |
| - name: Build distributions | |
| run: uv build --no-sources | |
| - name: Publish to PyPI | |
| run: uv publish |