-
Notifications
You must be signed in to change notification settings - Fork 1
409 lines (351 loc) · 12.3 KB
/
Copy pathrelease.yml
File metadata and controls
409 lines (351 loc) · 12.3 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
name: Build and Release PyPi and Rust Packages
on:
push:
branches:
- main
release:
types: [published]
permissions:
contents: read
env:
PACKAGE_NAME: scouter
RUSTFLAGS: -C debuginfo=0
PYTHON_VERSION: "3.12"
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
PROTOC_VERSION: "33.2"
jobs:
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Protocol Buffers Compiler
uses: arduino/setup-protoc@v3
with:
version: "33.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
maturin-version: 1.8.3
rust-toolchain: stable
working-directory: ./py-scouter
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: pypi_sdist
path: ./py-scouter/dist
retention-days: 1
build-linux:
name: build - ${{ matrix.runner-type }} - ${{ matrix.manylinux }} - ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
manylinux: "2_28"
runner-type: ubuntu-latest
runner: ubuntu-latest
docker-options: "-e CI"
- target: aarch64-unknown-linux-gnu
manylinux: "2_28"
runner-type: ubuntu-24.04-arm
runner: ubuntu-24.04-arm
docker-options: "-e CI -e SIMSIMD_DISABLE_SVE=1 -e SIMSIMD_TARGET_SVE=0 -e SIMSIMD_TARGET_SVE2=0"
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install -U "twine>=6.1.0" "packaging>=24.2"
- name: Set OPENSSL_DIR environment variable
run: echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
args: --release --out dist
rust-toolchain: stable
docker-options: ${{ matrix.docker-options }}
working-directory: ./py-scouter
before-script-linux: |
# Install required packages
if command -v yum &> /dev/null; then
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic curl-devel
# If we're running on i686 we need to symlink libatomic
# in order to build openssl with -latomic flag.
if [[ ! -d "/usr/lib64" ]]; then
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
fi
else
# If we're running on debian-based system.
apt update -y && apt-get install -y libssl-dev openssl pkg-config
fi
# Determine architecture and install CMake
ARCH=$(uname -m)
echo "Detected architecture: $ARCH"
# Install Protocol Buffers Compiler (protoc)
PROTOC_VERSION="33.2"
if [[ "$ARCH" == "x86_64" ]]; then
PROTOC_ARCH="linux-x86_64"
elif [[ "$ARCH" == "aarch64" ]]; then
PROTOC_ARCH="linux-aarch_64"
else
echo "Unsupported architecture for protoc: $ARCH"
exit 1
fi
echo "Installing protoc ${PROTOC_VERSION} for ${PROTOC_ARCH}"
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_ARCH}.zip"
unzip "protoc-${PROTOC_VERSION}-${PROTOC_ARCH}.zip" -d /usr/local
rm "protoc-${PROTOC_VERSION}-${PROTOC_ARCH}.zip"
chmod +x /usr/local/bin/protoc
protoc --version
# Install bindgen CLI
cargo install --force --locked bindgen-cli
if [[ "$ARCH" == "x86_64" ]]; then
echo "Downloading CMake for x86_64 architecture"
curl -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh -o cmake.sh
chmod +x cmake.sh
./cmake.sh --skip-license --prefix=/usr/local
elif [[ "$ARCH" == "aarch64" ]]; then
echo "Downloading CMake for aarch64 architecture"
curl -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-aarch64.sh -o cmake.sh
chmod +x cmake.sh
./cmake.sh --skip-license --prefix=/usr/local
elif [[ "$ARCH" == "i686" ]]; then
echo "Downloading CMake for x86 architecture"
curl -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4.tar.gz -o cmake.tar.gz
tar -xzf cmake.tar.gz
cd cmake-3.26.4
./bootstrap --prefix=/usr/local
make -j$(nproc)
make install
cd ..
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
cmake --version
# Set ARM64-specific environment variables for simsimd
if [[ "$ARCH" == "aarch64" ]]; then
echo "Setting up ARM64 build environment"
export SIMSIMD_DISABLE_SVE=1
export SIMSIMD_TARGET_SVE=0
export SIMSIMD_TARGET_SVE2=0
export SIMSIMD_TARGET_SVE_F16=0
export SIMSIMD_TARGET_SVE_BF16=0
export SIMSIMD_TARGET_SVE_I8=0
export CFLAGS="-march=armv8-a"
export CXXFLAGS="-march=armv8-a"
fi
- name: Check dist
working-directory: ./py-scouter
run: ls -lh dist/
- name: Check wheel
working-directory: ./py-scouter
run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: pypi_files_ubuntu_${{ matrix.target }}
path: ./py-scouter/dist
retention-days: 1
build-macos:
name: build - macos - (${{ matrix.os}} - ${{ matrix.architecture}})
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
architecture: x86-64
target: x86_64-apple-darwin
- os: macos-15
architecture: aarch64
target: aarch64-apple-darwin
runs-on: ${{ matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Protocol Buffers Compiler
uses: arduino/setup-protoc@v3
with:
version: "33.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: pip install -U "twine>=6.1.0" "packaging>=24.2"
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ matrix.target }}
args: --release --out dist
rust-toolchain: stable
working-directory: ./py-scouter
- name: Check dist
working-directory: ./py-scouter
run: ls -lh dist/
- name: Check wheel
working-directory: ./py-scouter
run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: pypi_files_macos_${{ matrix.target }}
path: ./py-scouter/dist
retention-days: 1
build-windows:
name: build - windows - (${{ matrix.os}} - ${{ matrix.architecture}})
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
architecture: x86-64
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
if: matrix.os != 'windows-11-arm'
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Protocol Buffers Compiler
uses: arduino/setup-protoc@v3
with:
version: "33.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: pip install -U "twine>=6.1.0" "packaging>=24.2"
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ matrix.target }}
args: --release --out dist
rust-toolchain: stable
working-directory: ./py-scouter
- name: Check dist
working-directory: ./py-scouter
run: dir dist/
- name: Check wheel
working-directory: ./py-scouter
run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: pypi_files_windows_${{ matrix.target }}
path: ./py-scouter/dist
retention-days: 1
inspect-pypi-assets:
needs: [build-linux, build-macos, build-windows, build-sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files_*
merge-multiple: true
path: dist
- name: list dist files
run: |
ls -lh dist/
ls -l dist/
echo "`ls dist | wc -l` files"
test-builds-os:
name: test build on ${{ matrix.os }}
needs: [build-linux, build-macos, build-windows, build-sdist]
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- name: set up python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create virtual environment
working-directory: ./py-scouter
run: |
python -m venv .venv
echo "$GITHUB_WORKSPACE/scouter/.venv/bin" >> $GITHUB_PATH
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files_${{ matrix.os }}_*
merge-multiple: true
path: py-scouter/dist
- name: install scouter-ml
working-directory: ./py-scouter
run: |
python3 -m pip install scouter-ml --no-deps --no-index --force-reinstall --find-links dist
pip install -r tests/requirements.txt
pytest --ignore tests/integration --benchmark-skip
python-release:
if: github.event_name == 'release'
name: Release-Python
environment: release
runs-on: ubuntu-latest
needs: [test-builds-os]
steps:
- uses: actions/checkout@v4
- name: install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Check version
working-directory: ./py-scouter
run: |
export VERSION=$(cargo pkgid | cut -d "#" -f2)
echo "version: $VERSION"
echo "tag: ${{ github.ref_name }}"
test "v$VERSION" "=" "${{ github.ref_name }}"
- name: set up python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -U "twine>=6.1.0" "packaging>=24.2"
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files_*
merge-multiple: true
path: dist
- run: twine check --strict dist/*
- name: upload to pypi
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
rust-release:
if: github.event_name == 'release'
environment: release
name: Release-Rust
runs-on: ubuntu-latest
needs: [test-builds-os]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: cache rust
id: cargo_release_cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cargo-release
- name: Clear cargo registry index
run: rm -rf ~/.cargo/registry/index
- name: Switch to main branch
run: git checkout main
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_REGISTRY_TOKEN }}