Skip to content

Commit c7267cf

Browse files
committed
ci: add GitHub Actions workflows
1 parent a856b16 commit c7267cf

2 files changed

Lines changed: 131 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: 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", "3.14"]
20+
21+
env:
22+
QT_QPA_PLATFORM: offscreen
23+
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
cache: pip
33+
34+
- name: Install package and test dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
python -m pip install -e ".[qt-pyside6]" pytest build twine
38+
39+
- name: Run tests
40+
run: |
41+
python -m pytest
42+
43+
- name: Build package
44+
run: |
45+
python -m build
46+
47+
- name: Check package metadata
48+
run: |
49+
twine check dist/*

.github/workflows/publish.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
name: Build distribution
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.release.tag_name }}
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.14"
24+
25+
- name: Install build dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install build twine
29+
30+
- name: Validate release tag matches package version
31+
run: |
32+
python - <<'PY'
33+
import pathlib
34+
import re
35+
import sys
36+
37+
tag = "${{ github.event.release.tag_name }}"
38+
version_file = pathlib.Path("src/abracatabra/__about__.py")
39+
match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', version_file.read_text())
40+
41+
if match is None:
42+
sys.exit("Could not find __version__ in src/abracatabra/__about__.py")
43+
44+
version = match.group(1)
45+
expected_tag = f"v{version}"
46+
47+
if tag != expected_tag:
48+
sys.exit(f"Release tag {tag!r} does not match package version {version!r}; expected {expected_tag!r}")
49+
PY
50+
51+
- name: Build package
52+
run: |
53+
python -m build
54+
55+
- name: Check package metadata
56+
run: |
57+
twine check dist/*
58+
59+
- name: Upload distributions
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: dist
63+
path: dist/*
64+
if-no-files-found: error
65+
66+
publish:
67+
name: Publish distribution
68+
runs-on: ubuntu-latest
69+
needs: build
70+
environment: pypi
71+
permissions:
72+
id-token: write
73+
74+
steps:
75+
- name: Download distributions
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: dist
79+
path: dist
80+
81+
- name: Publish package to PyPI
82+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)