1+ name : Build and Publish Wheels
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ tags : [ "v*.*.*" ]
7+ pull_request :
8+ branches : [ "main" ]
9+ workflow_dispatch :
10+
11+ jobs :
12+ build_sdist :
13+ name : Build source distribution
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v4
17+
18+ - uses : actions/setup-python@v5
19+ with :
20+ python-version : " 3.x"
21+
22+ - name : Build SDist
23+ run : |
24+ pip install build
25+ python -m build --sdist
26+
27+ - uses : actions/upload-artifact@v4
28+ with :
29+ name : cibw-sdist
30+ path : dist/*.tar.gz
31+
32+ build_wheels :
33+ name : Build wheels on ${{ matrix.os }} (${{ matrix.arch }})
34+ runs-on : ${{ matrix.os }}
35+ strategy :
36+ fail-fast : false
37+ matrix :
38+ include :
39+ # Linux
40+ - os : ubuntu-latest
41+ arch : x86_64
42+ - os : ubuntu-latest
43+ arch : aarch64
44+
45+ # macOS (Intel and Apple Silicon)
46+ - os : macos-13
47+ arch : x86_64
48+ - os : macos-14
49+ arch : arm64
50+
51+ # Windows
52+ - os : windows-latest
53+ arch : AMD64
54+
55+ steps :
56+ - uses : actions/checkout@v4
57+
58+ - name : Set up QEMU (for Linux ARM64)
59+ if : runner.os == 'Linux' && matrix.arch == 'aarch64'
60+ uses : docker/setup-qemu-action@v3
61+
62+ - name : Install dependencies (macOS)
63+ if : runner.os == 'macOS'
64+ run : |
65+ brew install gcc ninja
66+
67+ - name : Setup MSYS2 (Windows)
68+ if : runner.os == 'Windows'
69+ uses : msys2/setup-msys2@v2
70+ with :
71+ msystem : MINGW64
72+ update : true
73+ install : >-
74+ mingw-w64-x86_64-gcc
75+ mingw-w64-x86_64-gcc-fortran
76+ mingw-w64-x86_64-cmake
77+ mingw-w64-x86_64-ninja
78+ # crucial to allow cibuildwheel to see the MSYS2 tools
79+ path-type : inherit
80+
81+ - name : Build wheels
82+ uses : pypa/cibuildwheel@v2.17.0
83+ env :
84+ CIBW_ARCHS : " ${{ matrix.arch }}"
85+
86+ - uses : actions/upload-artifact@v4
87+ with :
88+ name : cibw-wheels-${{ matrix.os }}-${{ matrix.arch }}
89+ path : ./wheelhouse/*.whl
90+
91+ upload_pypi :
92+ name : Upload to PyPI
93+ needs : [build_wheels, build_sdist]
94+ runs-on : ubuntu-latest
95+ # Only publish on version tags
96+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
97+
98+ # Required for PyPI Trusted Publishing (OIDC)
99+ environment :
100+ name : pypi
101+ url : https://pypi.org/p/mpi-stubs
102+ permissions :
103+ id-token : write
104+
105+ steps :
106+ - uses : actions/download-artifact@v4
107+ with :
108+ pattern : cibw-*
109+ merge-multiple : true
110+ path : dist
111+
112+ - name : Publish package distributions to PyPI
113+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments