Skip to content

Publish to PyPI

Publish to PyPI #75

Workflow file for this run

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@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
- uses: astral-sh/setup-uv@v7
- 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 }}