Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
build:
name: Build distribution packages
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build package
run: uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ github.run_id }}
path: dist/

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
if: "!github.event.release.prerelease"
permissions:
contents: read
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ github.run_id }}
path: dist/

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Check release tag
id: stable_tag
env:
TAG: ${{ github.event.release.tag_name }}
run: |
if [[ "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "publish=true" >>"$GITHUB_OUTPUT"
exit 0
fi
echo "::notice::Skipping publish for non-stable tag: $TAG"
echo "publish=false" >>"$GITHUB_OUTPUT"

- name: Publish to PyPI with uv
if: steps.stable_tag.outputs.publish == 'true'
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple