Skip to content

Commit 5ce8b8f

Browse files
committed
ci: Implement build, test, and release workflows using GitHub Actions.
1 parent 01efcd1 commit 5ce8b8f

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: build-and-test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Build sdist and wheel
23+
run: |
24+
python -m pip install -U pip build
25+
python -m build -s -w
26+
27+
- name: Install wheel and smoke-check metadata
28+
run: |
29+
python -m pip install dist/*.whl
30+
python - << 'PY'
31+
import importlib.metadata as md
32+
print("quantumhall_matrixelements version:", md.version("quantumhall_matrixelements"))
33+
PY
34+

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
# 👇 This must match exactly the environment you configure on PyPI
13+
environment: release
14+
permissions:
15+
contents: read
16+
id-token: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Build sdist and wheel
27+
run: |
28+
python -m pip install -U pip build
29+
python -m build -s -w
30+
31+
- name: Smoke-check package metadata
32+
run: |
33+
python -m pip install dist/*.whl
34+
python - << 'PY'
35+
import importlib.metadata as md
36+
print("quantumhall_matrixelements version:", md.version("quantumhall_matrixelements"))
37+
PY
38+
39+
# Only publish on tag refs like v0.1.0
40+
- name: Publish to PyPI via OIDC (Trusted Publisher)
41+
if: startsWith(github.ref, 'refs/tags/v')
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
with:
44+
packages-dir: dist/
45+

0 commit comments

Comments
 (0)