Skip to content

5.2.0

5.2.0 #53

Workflow file for this run

name: PyPI Publish
on:
release:
types: [published]
jobs:
pypi-publish:
name: Publish tagged release on PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v5
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Ensure package version and tag name are equal
id: check-package
run: |
PKG_VER="$(grep -oP '^version = "\K[^"]+' pyproject.toml)"
TAG_VER="${GITHUB_REF##*/}"
echo "Package version is $PKG_VER" >&2
echo "Tag version is $TAG_VER" >&2
if [ "$PKG_VER" != "$TAG_VER" ]; then
echo "Package version and tag name mismatch." >&2
exit 1
fi
- name: Install pypa/build
id: install-build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
id: build
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Install the newly build package with all extras
id: install
run: |
TAR_PATH="$( realpath ./dist/*.tar.gz)"
python -m \
pip install \
"${TAR_PATH}[all]"
- name: Install testing requirements
id: install-dev
run: >-
python -m
pip install
--no-deps -r ./lock/requirements-dev.txt
- name: Run pytest on freshly installed package
id: test
run: |
pytest .
- name: Publish distribution package to PyPI (test)
id: publish-test
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution package to PyPI (production)
id: publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}