Skip to content

Commit e679797

Browse files
committed
Added CI Workflow for publishing automatically
1 parent a6816e5 commit e679797

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/build_wheels.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build_wheels:
14+
name: Build wheels on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
# macos-13 is an intel runner, macos-14 is apple silicon
19+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Build wheels
25+
uses: pypa/[email protected]
26+
27+
- uses: actions/upload-artifact@v4
28+
with:
29+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
30+
path: ./wheelhouse/*.whl
31+
32+
build_sdist:
33+
name: Build source distribution
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Build sdist
39+
run: pipx run build --sdist
40+
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: cibw-sdist
44+
path: dist/*.tar.gz
45+
46+
upload_pypi:
47+
needs: [build_wheels, build_sdist]
48+
runs-on: ubuntu-latest
49+
environment: pypi
50+
permissions:
51+
id-token: write
52+
if: github.event_name == 'release' && github.event.action == 'published'
53+
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
54+
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
55+
steps:
56+
- uses: actions/download-artifact@v4
57+
with:
58+
# unpacks all CIBW artifacts into dist/
59+
pattern: cibw-*
60+
path: dist
61+
merge-multiple: true
62+
63+
- name: Generate artifact attestations
64+
uses: actions/[email protected]
65+
with:
66+
subject-path: "dist/*"
67+
68+
- uses: pypa/gh-action-pypi-publish@release/v1
69+
#with:
70+
# To test: repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)