Skip to content

Commit 80ba736

Browse files
committed
ci: add test matrix and publish-on-release workflows
No CI existed in this repo. Adds: - test.yml: runs the unittest suite on Python 3.8-3.12 for pushes and PRs - publish.yml: builds and publishes to PyPI on GitHub Release, via PyPI Trusted Publishing (OIDC) so no API token is stored in the repo AB#698642
1 parent 4a6af1b commit 80ba736

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish to PyPI
2+
3+
# Publishes the package to PyPI when a GitHub Release is published.
4+
# Uses PyPI Trusted Publishing (OIDC) — no API token is stored in the repo.
5+
# One-time setup: on PyPI, add a Trusted Publisher for this project pointing at
6+
# this repository and the "publish.yml" workflow.
7+
# https://docs.pypi.org/trusted-publishers/
8+
9+
on:
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
environment: pypi
17+
permissions:
18+
id-token: write # required for Trusted Publishing
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Build sdist and wheel
29+
run: |
30+
python -m pip install --upgrade pip build
31+
python -m build
32+
33+
- name: Publish to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install package
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e .
28+
29+
- name: Run tests
30+
run: python -m unittest discover -s tests -v

0 commit comments

Comments
 (0)