Skip to content

Commit af121f5

Browse files
authored
Create pypi.yml
1 parent e863aaa commit af121f5

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

.github/workflows/pypi.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Publish to PyPI.org
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
push:
8+
branches: ["master"]
9+
pull_request:
10+
branches: ["master"]
11+
12+
jobs:
13+
build_sdist:
14+
name: Build source distribution
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Build sdist
20+
run: pipx run build --sdist ${{github.workspace}}/python/
21+
- name: Move sdist to dist
22+
run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/
23+
24+
- uses: actions/upload-artifact@v3
25+
with:
26+
path: dist/*.tar.gz
27+
28+
cibuildwheel:
29+
name: Build wheels on ${{ matrix.os }}
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
os: [ubuntu-22.04, windows-2022, macos-14]
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Build test wheels (only PRs)
39+
if: github.event_name != 'release'
40+
uses: pypa/[email protected]
41+
env: # build 1 build per platform just to make sure we can do it later when releasing
42+
CIBW_BUILD: "cp310-*"
43+
with:
44+
package-dir: ${{github.workspace}}/python/
45+
46+
- name: Build all wheels
47+
if: github.event_name == 'release'
48+
uses: pypa/[email protected]
49+
with:
50+
package-dir: ${{github.workspace}}/python/
51+
52+
- uses: actions/upload-artifact@v3
53+
with:
54+
path: ./wheelhouse/*.whl
55+
56+
pypi:
57+
if: github.event_name == 'release'
58+
needs: [cibuildwheel, build_sdist]
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/download-artifact@v3
62+
with:
63+
name: artifact
64+
path: dist
65+
66+
- uses: pypa/gh-action-pypi-publish@release/v1
67+
with:
68+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)