Skip to content

Commit 086446c

Browse files
authored
Add GitHub Actions workflow for PyPI publishing
1 parent da8dd6c commit 086446c

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
# Optional: Allow manually running this workflow from the "Actions" tab for testing
7+
workflow_dispatch:
8+
9+
jobs:
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
# Mac, Windows, and Linux
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
# Used to build the wheels
22+
- name: Build wheels
23+
uses: pypa/cibuildwheel@v2.16.5
24+
env:
25+
CIBW_SKIP: "cp36-* cp37-*"
26+
27+
# Ensure we build for both x86_64 and arm64 on Mac (Apple Silicon support)
28+
CIBW_ARCHS_MACOS: x86_64 arm64
29+
30+
- uses: actions/upload-artifact@v3
31+
with:
32+
path: ./wheelhouse/*.whl
33+
34+
build_sdist:
35+
name: Build source distribution
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Build sdist
41+
run: pipx run build --sdist
42+
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
path: dist/*.tar.gz
46+
47+
upload_pypi:
48+
needs: [build_wheels, build_sdist]
49+
runs-on: ubuntu-latest
50+
51+
# Only upload to PyPI if this is a Release (not a manual test run)
52+
if: github.event_name == 'release' && github.event.action == 'published'
53+
54+
steps:
55+
- uses: actions/download-artifact@v3
56+
with:
57+
name: artifact
58+
path: dist
59+
60+
- uses: pypa/gh-action-pypi-publish@v1.8.10
61+
with:
62+
user: __token__
63+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)