Skip to content

Publish to PyPI

Publish to PyPI #12

Workflow file for this run

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag to publish (e.g., v0.2.0)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- uses: astral-sh/setup-uv@v4
- name: Verify version matches pyproject.toml
run: |
TOML_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
INPUT_VERSION="${{ inputs.version }}"
INPUT_VERSION="${INPUT_VERSION#v}"
if [ "$TOML_VERSION" != "$INPUT_VERSION" ]; then
echo "Error: Input version ($INPUT_VERSION) doesn't match pyproject.toml ($TOML_VERSION)"
exit 1
fi
working-directory: python
- name: Build
run: uv build
working-directory: python
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist/