Skip to content

Publish to PyPI

Publish to PyPI #2

Workflow file for this run

name: Publish to PyPI
on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for proper versioning
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Bump version
run: |
uv version --bump ${{ github.event.inputs.bump_type }}
NEW_VERSION=$(uv version --short)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml uv.lock
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
git tag "v${{ env.NEW_VERSION }}"
git push origin main
git push origin "v${{ env.NEW_VERSION }}"
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# No token needed - uses OIDC trusted publishing
print-hash: true
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ env.NEW_VERSION }}" \
--repo="${{ github.repository }}" \
--title="v${{ env.NEW_VERSION }}" \
--generate-notes \
./dist/*