Skip to content

Commit ba4dad3

Browse files
committed
PyPI release workflow
1 parent df33a9b commit ba4dad3

File tree

7 files changed

+166
-87
lines changed

7 files changed

+166
-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: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publishing
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
branches:
8+
- test-release
9+
10+
jobs:
11+
release-build:
12+
name: Build distribution
13+
runs-on: ubuntu-latest
14+
needs: [checks]
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
20+
21+
- name: "Set up Python"
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version-file: ".python-version"
25+
26+
- name: Install the project
27+
run: uv sync --frozen --all-extras --dev
28+
29+
- name: Build
30+
run: uv build
31+
32+
- name: Upload artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: release-dists
36+
path: dist/
37+
38+
checks:
39+
uses: ./.github/workflows/shared.yml
40+
41+
pypi-publish:
42+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
43+
name: Upload release to PyPI
44+
runs-on: ubuntu-latest
45+
environment: release
46+
needs:
47+
- release-build
48+
permissions:
49+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
50+
51+
steps:
52+
- name: Retrieve release distributions
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: release-dists
56+
path: dist/
57+
58+
- name: Publish package distributions to PyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
61+
test-pypi-publish:
62+
name: Upload release to TestPyPI
63+
runs-on: ubuntu-latest
64+
environment: release
65+
needs:
66+
- release-build
67+
permissions:
68+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
69+
70+
steps:
71+
- name: Retrieve release distributions
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: release-dists
75+
path: dist/
76+
77+
- name: Publish package distributions to TestPyPI
78+
uses: pypa/gh-action-pypi-publish@release/v1
79+
with:
80+
repository-url: https://test.pypi.org/legacy/
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)