Skip to content

Commit 18f94cc

Browse files
committed
Use GH actions to publish pypi packages.
1 parent 0135ac4 commit 18f94cc

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
version: "latest"
2222

2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

.github/workflows/publish.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Publish Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: astral-sh/setup-uv@v1
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Install dependencies
30+
run: uv sync --all-extras -p ${{ matrix.python-version }}
31+
32+
- name: Run unit tests
33+
run: uv run tox -e py${{ matrix.python-version }}
34+
35+
- name: Run Style Checks
36+
run: uv run tox -e style
37+
38+
build:
39+
runs-on: ubuntu-latest
40+
needs: [test]
41+
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: astral-sh/setup-uv@v1
45+
with:
46+
version: "latest"
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: '3.12'
52+
53+
- name: Install dependencies
54+
run: uv sync --all-extras -p 3.12
55+
56+
- name: Build
57+
run: |
58+
python -m build
59+
60+
- name: Store the distribution packages
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: python-packages
64+
path: dist/
65+
66+
publish:
67+
name: Publish to PyPI
68+
runs-on: ubuntu-latest
69+
if: startsWith(github.ref, 'refs/tags/')
70+
needs: [build]
71+
environment: release
72+
permissions:
73+
id-token: write
74+
steps:
75+
- name: Download distribution packages
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: python-packages
79+
path: dist/
80+
- name: Publish to PyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)