Skip to content

v0.1.1

v0.1.1 #2

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
permissions:
contents: read
jobs:
tests:
uses: ./.github/workflows/test.yaml
build:
name: Build distributions
needs: tests
runs-on: ubuntu-latest
steps:
- name: Checkout release ref
uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name }}
fetch-depth: 0
- name: Install uv and Python
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: "3.11"
enable-cache: true
- name: Verify tagged commit is on main
run: |
git fetch origin main --force
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<'PY'
import os
import tomllib
from pathlib import Path
version = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["project"]["version"]
expected = f"v{version}"
actual = os.environ["RELEASE_TAG"]
if actual != expected:
raise SystemExit(f"release tag {actual!r} does not match package version {expected!r}")
PY
- name: Build distributions
run: uv build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distributions
uses: pypa/gh-action-pypi-publish@release/v1