Skip to content

Tests in CI, badges, deploy only when tests pass #2

Tests in CI, badges, deploy only when tests pass

Tests in CI, badges, deploy only when tests pass #2

Workflow file for this run

# Publish to PyPI when a GitHub release is created
# 1. Create a PyPI API token: https://pypi.org/manage/account/token/
# 2. Add it under environment "pypi": Settings → Environments → pypi → Environment secrets → PYPI_API_TOKEN
name: Publish to PyPI
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set version from release tag
run: |
TAG="${{ github.event.release.tag_name }}"
VERSION="${TAG#v}"
sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
echo "Building version ${VERSION}"
grep '^version = ' pyproject.toml
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*