Skip to content

Commit 7ce5c76

Browse files
committed
Add GitHub Actions workflow for publishing to PyPI and Test PyPI
1 parent 6f0d7a2 commit 7ce5c76

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/publish.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v3
24+
25+
- name: Build package
26+
run: uv build
27+
28+
- name: Upload build artifacts
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: dist
32+
path: dist/
33+
34+
test-pypi:
35+
runs-on: ubuntu-latest
36+
needs: build
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Download build artifacts
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: dist
45+
path: dist/
46+
47+
- name: Publish to Test PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
with:
50+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
51+
repository-url: https://test.pypi.org/legacy/
52+
53+
pypi:
54+
runs-on: ubuntu-latest
55+
needs: [build, test-pypi]
56+
environment: release
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Download build artifacts
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: dist
65+
path: dist/
66+
67+
- name: Publish to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)