Publish to PyPI #68
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 to PyPI | |
| on: | |
| workflow_run: | |
| workflows: [CI] | |
| types: [completed] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| name: Build & Publish | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| startsWith(github.event.workflow_run.head_branch, 'v') | |
| permissions: | |
| id-token: write | |
| contents: write | |
| env: | |
| TAG_NAME: ${{ github.event.workflow_run.head_branch }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install Python | |
| run: uv python install 3.13 | |
| - name: Sync version from tag | |
| run: | | |
| VERSION="${TAG_NAME#v}" | |
| sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml | |
| echo "Publishing version ${VERSION}" | |
| - name: Build package | |
| run: uv build | |
| - name: Publish to PyPI | |
| run: uv publish --trusted-publishing always | |
| - name: Create GitHub Release | |
| run: gh release create "${TAG_NAME}" dist/* --generate-notes | |
| env: | |
| GH_TOKEN: ${{ github.token }} |