Skip to content

Commit 4d4059f

Browse files
committed
Add build and upload to PyPI workflow
1 parent dc30467 commit 4d4059f

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/workflows/publish.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Based on https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
2+
name: Build and upload to PyPI
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
release:
10+
types:
11+
- published
12+
13+
jobs:
14+
build-wheels:
15+
name: Build wheels
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build wheels
20+
uses: pypa/[email protected]
21+
- uses: actions/upload-artifact@v3
22+
with:
23+
path: ./wheelhouse/*.whl
24+
25+
build-sdist:
26+
name: Build source distribution
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Build sdist
31+
run: pipx run build --sdist
32+
- uses: actions/upload-artifact@v3
33+
with:
34+
path: dist/*.tar.gz
35+
36+
test-pypi-publish:
37+
name: Upload release to TestPyPI
38+
needs: [build-wheels, build-sdist]
39+
runs-on: ubuntu-latest
40+
environment: test-pypi
41+
permissions:
42+
id-token: write
43+
if: github.event_name == 'release' && github.event.action == 'published'
44+
steps:
45+
- uses: actions/download-artifact@v3
46+
with:
47+
name: artifact
48+
path: dist
49+
- name: Publish package distributions to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
with:
52+
repository-url: https://test.pypi.org/legacy/
53+
54+
pypi-publish:
55+
name: Upload release to PyPI
56+
needs: [build-wheels, build-sdist, test-pypi-publish]
57+
runs-on: ubuntu-latest
58+
environment: pypi
59+
permissions:
60+
id-token: write
61+
if: github.event_name == 'release' && github.event.action == 'published'
62+
steps:
63+
- uses: actions/download-artifact@v3
64+
with:
65+
name: artifact
66+
path: dist
67+
- name: Publish package distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)