-
Notifications
You must be signed in to change notification settings - Fork 30
154 lines (136 loc) · 4.07 KB
/
Copy pathbuild-necpp-wheels.yml
File metadata and controls
154 lines (136 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Copyright (c) 2008-2026 Tim Molteno (tim@elec.ac.nz)
name: Build and upload necpp to PyPI
on:
workflow_dispatch:
release:
types:
- published
jobs:
build_wheels:
name: Build necpp wheels on ${{ matrix.os }}
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
strategy:
matrix:
include:
- os: linux
runs-on: ubuntu-latest
- os: macos-arm
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install build dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y swig cmake
- name: Install build dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install swig cmake
- name: Configure necpp_src
shell: bash
run: |
cd necpp_src
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Setup package directory and generate SWIG wrapper
shell: bash
run: |
cd necpp
ln -s ../necpp_src .
swig -I../necpp_src/src/ -python necpp.i
- name: Build wheels
uses: pypa/cibuildwheel@v4.1.0
env:
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
CIBW_SKIP: "*-musllinux_*"
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: necpp
output-dir: wheelhouse
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-necpp-${{ matrix.os }}
path: ./wheelhouse/*.whl
test:
name: Test necpp on ${{ matrix.os }}
needs: [build_wheels, build_sdist]
runs-on: ${{ matrix.runs-on }}
permissions:
contents: read
strategy:
matrix:
include:
- os: linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-necpp-${{ matrix.os }}
path: wheelhouse
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install wheel and run tests
# cibuildwheel produces one wheel per Python version (cp310-cp313).
# Install only the wheel matching the interpreter set up above,
# instead of globbing all ABIs (which pip rejects as incompatible).
shell: bash
run: |
PYTAG="cp$(python -c 'import sys;print(f"{sys.version_info.major}{sys.version_info.minor}")')"
pip install "$(ls wheelhouse/*-$PYTAG-*.whl | head -1)"
pip install pytest
python -m pytest necpp/tests/ -v
build_sdist:
name: Build necpp source distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y swig cmake
- name: Configure necpp_src
run: |
cd necpp_src
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Setup package directory and generate SWIG wrapper
run: |
cd necpp
ln -s ../necpp_src .
swig -I../necpp_src/src/ -python necpp.i
- name: Build sdist
run: |
cd necpp
pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist-necpp
path: necpp/dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1