Skip to content

Commit 09fa2de

Browse files
committed
PyPI release workflow
1 parent df33a9b commit 09fa2de

File tree

7 files changed

+143
-87
lines changed

7 files changed

+143
-87
lines changed

.github/workflows/check-format.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/check-types.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/main-checks.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Main branch checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
checks:
9+
uses: ./.github/workflows/shared.yml

.github/workflows/main.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/publish-pypi.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publishing
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
release-build:
10+
name: Build distribution
11+
runs-on: ubuntu-latest
12+
needs: [checks]
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v3
18+
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version-file: ".python-version"
23+
24+
- name: Install the project
25+
run: uv sync --frozen --all-extras --dev
26+
27+
- name: Build
28+
run: uv build
29+
30+
- name: Upload artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: release-dists
34+
path: dist/
35+
36+
checks:
37+
uses: ./.github/workflows/shared.yml
38+
39+
pypi-publish:
40+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
41+
name: Upload release to PyPI
42+
runs-on: ubuntu-latest
43+
environment: release
44+
needs:
45+
- release-build
46+
permissions:
47+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
48+
49+
steps:
50+
- name: Retrieve release distributions
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: release-dists
54+
path: dist/
55+
56+
- name: Publish package distributions to PyPI
57+
uses: pypa/gh-action-pypi-publish@release/v1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Pull request checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
checks:
8+
uses: ./.github/workflows/shared.yml

.github/workflows/shared.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Shared Checks
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
format:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v3
14+
with:
15+
enable-cache: true
16+
17+
- name: "Set up Python"
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version-file: ".python-version"
21+
22+
- name: Install the project
23+
run: uv sync --frozen --all-extras --dev
24+
25+
- name: Run ruff format check
26+
run: uv run --frozen ruff check .
27+
28+
typecheck:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v3
35+
with:
36+
enable-cache: true
37+
38+
- name: "Set up Python"
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version-file: ".python-version"
42+
43+
- name: Install the project
44+
run: uv sync --frozen --all-extras --dev
45+
46+
- name: Run pyright
47+
run: uv run --frozen pyright
48+
49+
build:
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install uv
56+
uses: astral-sh/setup-uv@v3
57+
with:
58+
enable-cache: true
59+
60+
- name: "Set up Python"
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version-file: ".python-version"
64+
65+
- name: Install the project
66+
run: uv sync --frozen --all-extras --dev
67+
68+
- name: Run pytest
69+
run: uv run --frozen pytest

0 commit comments

Comments
 (0)