ci: publish package to PyPI on release tags

This commit is contained in:
Ousama Ben Younes 2026-07-27 18:23:58 +00:00
parent 8551339130
commit ad16408d5f

View file

@ -119,3 +119,36 @@ jobs:
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
generate_release_notes: true
files: release/**
publish-pypi:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
- name: Verify tag matches package version
shell: bash
run: |
VERSION="$(uv run python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [[ "${TAG_VERSION}" != "${VERSION}" ]]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match pyproject.toml version ${VERSION}"
exit 1
fi
- name: Build Python distribution
shell: bash
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1