| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: [ main ] |
| 6 |
tags: |
| 7 |
- 'v*.*.*' |
| 8 |
pull_request: |
| 9 |
branches: [ main ] |
| 10 |
|
| 11 |
jobs: |
| 12 |
build: |
| 13 |
runs-on: ubuntu-latest |
| 14 |
strategy: |
| 15 |
matrix: |
| 16 |
python-version: ["3.10", "3.11", "3.12", "3.13"] |
| 17 |
steps: |
| 18 |
- uses: actions/checkout@v3 |
| 19 |
- name: Set up Python |
| 20 |
uses: actions/setup-python@v4 |
| 21 |
with: |
| 22 |
python-version: ${{ matrix.python-version }} |
| 23 |
- name: Install dependencies |
| 24 |
run: | |
| 25 |
python -m pip install --upgrade pip |
| 26 |
pip install -e '.[dev]' |
| 27 |
- name: Lint with ruff |
| 28 |
run: ruff check . |
| 29 |
- name: Check formatting with black |
| 30 |
run: black --check . |
| 31 |
- name: Run tests |
| 32 |
run: pytest |
| 33 |
- name: Build package |
| 34 |
run: python -m build |
| 35 |
- name: Check package |
| 36 |
run: twine check dist/* |
| 37 |
|
| 38 |
deploy: |
| 39 |
name: Publish Python 🐍 distribution 📦 to PyPI |
| 40 |
needs: build |
| 41 |
runs-on: ubuntu-latest |
| 42 |
if: startsWith(github.ref, 'refs/tags/v') |
| 43 |
steps: |
| 44 |
- uses: actions/checkout@v3 |
| 45 |
- name: Set up Python |
| 46 |
uses: actions/setup-python@v4 |
| 47 |
with: |
| 48 |
python-version: '3.10' |
| 49 |
- name: Install build tools |
| 50 |
run: | |
| 51 |
python -m pip install --upgrade pip |
| 52 |
pip install build twine |
| 53 |
- name: Build package |
| 54 |
run: python -m build |
| 55 |
- name: Publish to PyPI |
| 56 |
env: |
| 57 |
TWINE_USERNAME: __token__ |
| 58 |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 59 |
run: twine upload dist/* |