Skip to content

v1.3.1

v1.3.1 #2

Workflow file for this run

name: Release
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Set up uv
uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: true
- name: Validate release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
PACKAGE_VERSION="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
EXPECTED_TAG="v${PACKAGE_VERSION}"
if [ "${RELEASE_TAG}" != "${EXPECTED_TAG}" ]; then
echo "Release tag ${RELEASE_TAG} does not match expected tag ${EXPECTED_TAG} derived from project version ${PACKAGE_VERSION}."
exit 1
fi
- name: Validate release commit is on main
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
git fetch --no-tags origin main
RELEASE_SHA="$(git rev-list -n 1 "refs/tags/${RELEASE_TAG}")"
if ! git merge-base --is-ancestor "${RELEASE_SHA}" origin/main; then
echo "Release tag ${RELEASE_TAG} points to commit ${RELEASE_SHA}, which is not contained in origin/main."
exit 1
fi
- name: Build source distribution and wheel
run: uv build --sdist --wheel --out-dir dist
- name: Validate built artifacts
run: uvx twine check dist/*
- name: Upload built distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
steps:
- name: Download built distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/