-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (174 loc) · 6.4 KB
/
ci-and-release.yml
File metadata and controls
194 lines (174 loc) · 6.4 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: ci-and-release
on:
pull_request:
push:
branches: [ main ]
tags: [ "v*" ]
workflow_dispatch:
concurrency:
group: ci-and-release-${{ github.ref }}
cancel-in-progress: true
jobs:
# =========================
# Build & test on PR/push
# =========================
build-test:
name: Build & Test (${{ matrix.os }} / py${{ matrix.python }})
strategy:
fail-fast: false
matrix:
include:
- { runner: ubuntu-latest, os: Linux, python: "3.10" }
- { runner: ubuntu-latest, os: Linux, python: "3.11" }
- { runner: ubuntu-latest, os: Linux, python: "3.12" }
- { runner: macos-15-intel, os: macOS-Intel, python: "3.10" }
- { runner: macos-15-intel, os: macOS-Intel, python: "3.11" }
- { runner: macos-15-intel, os: macOS-Intel, python: "3.12" }
- { runner: macos-15, os: macOS-ARM, python: "3.10" }
- { runner: macos-15, os: macOS-ARM, python: "3.11" }
- { runner: macos-15, os: macOS-ARM, python: "3.12" }
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
# ---------- System deps ----------
- name: Install system deps (Linux)
if: startsWith(matrix.os, 'Linux')
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libfftw3-dev cmake ninja-build pkg-config libboost-dev
- name: Install toolchain (macOS Intel)
if: matrix.os == 'macOS-Intel'
env: { HOMEBREW_NO_AUTO_UPDATE: "1" }
run: brew install fftw cmake ninja libomp boost || true
# ---------- Apple Silicon: build & cache FFTW in ~/.local ----------
- name: Cache FFTW (macOS ARM)
if: matrix.os == 'macOS-ARM'
uses: actions/cache@v4
with:
path: |
~/.local/include/fftw3.h
~/.local/lib/libfftw*
~/.local/lib/pkgconfig/fftw3*.pc
key: fftw-macos-arm-${{ hashFiles('ci/macos_arm_fftw.sh') }}
- name: Install toolchain & build FFTW (macOS ARM)
if: matrix.os == 'macOS-ARM'
env: { HOMEBREW_NO_AUTO_UPDATE: "1" }
run: |
brew install libomp boost cmake ninja || true
if [ ! -f "$HOME/.local/lib/libfftw3.dylib" ]; then
bash ci/macos_arm_fftw.sh
fi
# Help local *PR* builds find user-local FFTW during configure
{
echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH"
echo "CMAKE_PREFIX_PATH=$HOME/.local:$CMAKE_PREFIX_PATH"
echo "LIBRARY_PATH=$HOME/.local/lib:$HOME/.local/lib64:$LIBRARY_PATH"
echo "CPATH=$HOME/.local/include:$CPATH"
} >> "$GITHUB_ENV"
# ---------- Build wheel via scikit-build-core ----------
- name: Build wheel
run: |
python -m pip install -U pip numpy build
python -m build -w
- name: Install wheel
run: python -m pip install dist/*.whl
# ---------- Smoke test ----------
- name: Smoke test
working-directory: ${{ github.workspace }}
env:
# Ensure the loader can see FFTW/OMP in CI for local wheels
DYLD_FALLBACK_LIBRARY_PATH: ${{ matrix.os == 'macOS-ARM' && format('{0}:{1}', env.HOME, '/.local/lib') || '/opt/homebrew/lib:/usr/local/lib' }}
run: |
ls ci/smoke_test.py
python "$GITHUB_WORKSPACE/ci/smoke_test.py"
- name: Upload test wheels (optional)
uses: actions/upload-artifact@v4
with:
name: ci-wheels-${{ matrix.os }}-py${{ matrix.python }}
path: dist/*.whl
if-no-files-found: warn
# ==========================================
# Release wheels (cibuildwheel) — tags only
# ==========================================
wheels:
name: Wheels (${{ matrix.name }})
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.runner }}
permissions: { contents: read }
strategy:
fail-fast: false
matrix:
include:
- { name: linux-x86_64, runner: ubuntu-latest }
- { name: linux-aarch64, runner: ubuntu-24.04-arm }
- { name: macos-intel, runner: macos-15-intel }
- { name: macos-arm, runner: macos-15 }
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
# macOS prep (host environment for cibuildwheel)
- name: macOS toolchain (Intel)
if: matrix.name == 'macos-intel'
env: { HOMEBREW_NO_AUTO_UPDATE: "1" }
run: brew install fftw libomp boost cmake ninja || true
- name: macOS toolchain + FFTW from source (ARM)
if: matrix.name == 'macos-arm'
env: { HOMEBREW_NO_AUTO_UPDATE: "1" }
run: |
set -eux
brew install libomp boost cmake ninja || true
bash ci/macos_arm_fftw.sh
- name: Build wheels with cibuildwheel
uses: pypa/cibuildwheel@v2.21.3
# All config lives in pyproject.toml now
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-wheels-${{ matrix.name }}
path: wheelhouse/*
if-no-files-found: error
# ==========================
# Source dist — tags only
# ==========================
sdist:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions: { contents: read }
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: python -m pip install -U pip build
- run: python -m build -s
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*
if-no-files-found: error
# ==========================
# Publish — tags only
# ==========================
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build-test, wheels, sdist]
runs-on: ubuntu-latest
environment: cpp_hf_env
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/