Skip to content

Commit f1175c8

Browse files
Create python-publish.yml
1 parent ee167f8 commit f1175c8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/python-publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and Publish to PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build-wheels:
12+
name: Build wheels on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macOS-latest]
17+
python-version: ['3.8', '3.9', '3.10', '3.11']
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install cibuildwheel
27+
run: python -m pip install cibuildwheel
28+
29+
- name: Build wheels
30+
run: python -m cibuildwheel --output-dir wheelhouse
31+
32+
- uses: actions/upload-artifact@v2
33+
with:
34+
path: ./wheelhouse/*.whl
35+
36+
publish:
37+
needs: build-wheels
38+
runs-on: ubuntu-latest
39+
if: github.event_name == 'release' && github.event.action == 'created'
40+
steps:
41+
- uses: actions/download-artifact@v2
42+
with:
43+
name: artifact
44+
path: dist
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v2
48+
with:
49+
python-version: '3.x'
50+
51+
- name: Install twine
52+
run: python -m pip install twine
53+
54+
- name: Publish to PyPI
55+
run: twine upload dist/*
56+
env:
57+
TWINE_USERNAME: __token__
58+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)