Skip to content

Commit 94fe100

Browse files
committed
ci: add GitHub Actions pipeline for test, format, build and PyPI publish
1 parent 80fdfd0 commit 94fe100

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

.github/workflows/format.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Formatter
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
tags: ["v*"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
format:
14+
name: Formatter check (black)
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
cache: pip
25+
26+
- name: Install black
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install black
30+
31+
- name: Check formatting
32+
run: black --check .

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
name: Build package
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
cache: pip
23+
24+
- name: Build dists
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install build
28+
python -m build
29+
30+
- name: Upload dist artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: python-dist
34+
path: dist/*
35+
36+
publish-pypi:
37+
name: Publish to PyPI
38+
runs-on: ubuntu-latest
39+
needs: [build]
40+
permissions:
41+
id-token: write
42+
environment:
43+
name: pypi
44+
steps:
45+
- name: Download dist artifacts
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: python-dist
49+
path: dist/
50+
51+
- name: Publish package to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
tags: ["v*"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Tests (Python ${{ matrix.python-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.10", "3.11", "3.12", "3.13"]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
cache: pip
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install .[dev]
34+
35+
- name: Run tests
36+
run: pytest

0 commit comments

Comments
 (0)