Skip to content

Commit cc22d25

Browse files
authored
Add GitHub Actions workflow for PyPI release (#216)
* Add GitHub Actions workflow for PyPI release * Add smoke test for populationsim module This smoke test checks if the populationsim module is available and prints a success message. * Add workflow_dispatch to release.yml
1 parent 7826bbf commit cc22d25

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
# Publish on any tag starting with a `v`, e.g., v1.2.3
7+
- v*
8+
workflow_dispatch:
9+
10+
jobs:
11+
pypi:
12+
name: Publish to PyPI
13+
runs-on: ubuntu-latest
14+
# Environment and permissions trusted publishing.
15+
environment:
16+
# Create this environment in the GitHub repository under Settings -> Environments
17+
name: pypi
18+
permissions:
19+
id-token: write
20+
contents: read
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v5
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v6
26+
- name: Install Python 3.13
27+
run: uv python install 3.13
28+
- name: Build
29+
run: uv build
30+
# Check that basic features work and we didn't miss to include crucial files
31+
- name: Smoke test (wheel)
32+
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
33+
- name: Smoke test (source distribution)
34+
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
35+
- name: Publish
36+
run: uv publish

tests/smoke_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Check that basic features work.
2+
3+
Catch cases where e.g. files are missing so the import doesn't work. It is
4+
recommended to check that e.g. assets are included."""
5+
6+
import populationsim
7+
8+
if populationsim is not None:
9+
print("Smoke test succeeded")

0 commit comments

Comments
 (0)