-
Notifications
You must be signed in to change notification settings - Fork 316
1288 lines (1155 loc) · 43 KB
/
release.yml
File metadata and controls
1288 lines (1155 loc) · 43 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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Release
on:
push:
branches: ["main"]
env:
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
PYTHONUTF8: 1
PYTHON_VERSION: 3.11
DOTNET_VERSION: 8.0.x
NODE_VERSION: 20
JAVA_VERSION: 21
GO_VERSION: "^1.22.0"
ANDROID_NDK_VERSION: 26.3.11579264
ANDROID_SDK_VERSION: 21
EMSCRIPTEN_VERSION: 3.1.47
MINGW_VERSION: 12.2.0
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
packages: write
jobs:
versioning:
name: Update Version
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Run TinySemVer
uses: ashvardanian/tinysemver@v3.0.0
with:
verbose: "true"
version-file: "VERSION"
update-version-in: |
package.json:"version": "(\d+\.\d+\.\d+)"
CITATION.cff:^version: (\d+\.\d+\.\d+)
Cargo.toml:^version = "(\d+\.\d+\.\d+)"
wasmer.toml:^version = "(\d+\.\d+\.\d+)"
conanfile.py:version = "(\d+\.\d+\.\d+)"
java/README.md:usearchVersion = '(\d+\.\d+\.\d+)'
java/README.md:version: '(\d+\.\d+\.\d+)'
README.md:version = {(\d+\.\d+\.\d+)}
csharp/nuget/nuget-package.props:>(\d+\.\d+\.\d+)</Version>
CMakeLists.txt:VERSION (\d+\.\d+\.\d+)
update-major-version-in: |
include/usearch/index.hpp:^#define USEARCH_VERSION_MAJOR (\d+)
update-minor-version-in: |
include/usearch/index.hpp:^#define USEARCH_VERSION_MINOR (\d+)
update-patch-version-in: |
include/usearch/index.hpp:^#define USEARCH_VERSION_PATCH (\d+)
dry-run: "false"
push: "true"
create-release: "true"
github-token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
rebase:
name: Rebase Dev Branch
needs: versioning
runs-on: ubuntu-24.04
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Perform rebase
run: |
git fetch origin main
git checkout main-dev
git rebase origin/main
- name: Push changes
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
branch: main-dev
unprotect_reviews: True
force: True
create_linux_deb_package:
name: Build Linux Package
runs-on: ubuntu-24.04
needs: versioning
env:
CC: clang
CXX: clang++
AR: llvm-ar
NM: llvm-nm
RANLIB: llvm-ranlib
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
target: x86_64-linux-gnu
- arch: arm64
target: aarch64-linux-gnu
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Get version
id: set_version
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang lld make crossbuild-essential-arm64 crossbuild-essential-armhf libjemalloc-dev
- name: Build C/C++
run: |
# Configure and build the project
cmake -B build_release \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
-DUSEARCH_BUILD_LIB_C=1 \
-DUSEARCH_BUILD_SQLITE=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0
cmake --build build_release --config Release
cp build_release/libusearch_c.so "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.so"
cp build_release/libusearch_sqlite.so "usearch_sqlite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.so"
mkdir -p "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN"
touch "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
mkdir -p "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib"
mkdir "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include"
cp c/usearch.h "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include/"
cp build_release/libusearch_c.so "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib/"
echo -e "Package: usearch\nVersion: ${{ steps.set_version.outputs.version }}\nMaintainer: Ash Vardanian\nArchitecture: ${{ matrix.arch }}\nDescription: Faster & Smaller Single-File Search Engine for Vectors & Texts" > "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
dpkg-deb --build "usearch_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}"
- name: Upload native library for Java
uses: actions/upload-artifact@v5
with:
name: native-libs-linux-${{ matrix.arch }}
path: build_release/libusearch_c.so
retention-days: 1
- name: Upload library
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.so;*.deb"
update_latest_release: true
create_windows_dll_library:
name: Build Windows Library
runs-on: windows-2022
needs: versioning
strategy:
fail-fast: false
matrix:
arch: [x64, x86, arm64]
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Setup MinGW
if: matrix.arch != 'arm64'
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ matrix.arch }}
version: ${{ env.MINGW_VERSION }}
- name: Setup MSVC for ARM64
if: matrix.arch == 'arm64'
uses: microsoft/setup-msbuild@v2
- name: Get version
id: set_version
shell: bash
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build library (MinGW)
if: matrix.arch != 'arm64'
# `-G "MinGW Makefiles"` is required: without it, CMake on the
# `windows-2022` runner falls back to the Visual Studio generator
# (x64 by default), so the `x86` matrix entry was silently producing
# a 64-bit DLL and shipping it under the `windows_x86` archive name.
run: |
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=0 -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_BENCH_CPP=0 -B ./build_release
cmake --build ./build_release --config Release
mkdir pkg
copy .\build_release\libusearch_c.dll pkg\
copy .\c\usearch.h pkg\
tar -cvf usearch_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar -C pkg libusearch_c.dll usearch.h
# Guard against silent generator fallback — the DLL must match the
# advertised matrix arch, otherwise the archive ships a mislabeled binary.
- name: Verify Windows DLL architecture
if: matrix.arch != 'arm64'
shell: bash
run: |
case "${{ matrix.arch }}" in
x64) expected='x86-64' ;;
x86) expected='80386\|Intel 80386' ;;
esac
file ./build_release/libusearch_c.dll
file ./build_release/libusearch_c.dll | grep -q "$expected"
- name: Build library (MSVC ARM64)
if: matrix.arch == 'arm64'
run: |
cmake -G "Visual Studio 17 2022" -A ARM64 -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=0 -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_BENCH_CPP=0 -B ./build_release
cmake --build ./build_release --config Release
mkdir pkg
copy .\build_release\libusearch_c.dll pkg\
copy .\c\usearch.h pkg\
tar -cvf usearch_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar -C pkg libusearch_c.dll usearch.h
- name: Upload native library for Java
uses: actions/upload-artifact@v5
with:
name: native-libs-windows-${{ matrix.arch }}
path: build_release/libusearch_c.dll
retention-days: 1
- name: Upload archive
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "usearch_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar"
update_latest_release: true
create_macos_dylib_library:
name: Build macOS Library
runs-on: macos-15
needs: versioning
strategy:
fail-fast: false
matrix:
arch: [arm64, x86_64]
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Get version
id: set_version
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build library
run: |
cmake -DCMAKE_BUILD_TYPE=Release \
-DUSEARCH_BUILD_LIB_C=1 \
-DUSEARCH_BUILD_SQLITE=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0 \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
-B ./build_release
cmake --build ./build_release --config Release
zip -j usearch_macos_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.zip build_release/libusearch_c.dylib c/usearch.h
mv build_release/libusearch_sqlite.dylib usearch_sqlite_macos_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.dylib
- name: Upload native library for Java
uses: actions/upload-artifact@v5
with:
name: native-libs-macos-${{ matrix.arch }}
path: build_release/libusearch_c.dylib
retention-days: 1
- name: Upload library
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.dylib"
update_latest_release: true
- name: Upload archive
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.zip"
update_latest_release: true
create_android_library:
name: Build Android Library
runs-on: ubuntu-24.04
needs: versioning
strategy:
fail-fast: false
matrix:
include:
- processor: armv7a
abi: armeabi-v7a
target: armv7-linux-androideabi
arch: arm32
- processor: aarch64
abi: arm64-v8a
target: aarch64-linux-android
arch: arm64
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Get version
id: set_version
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Install NDK
run: |
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ANDROID_NDK_VERSION }}"
- name: Build C/C++
run: |
cmake -B build_artifacts \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_TOOLCHAIN_FILE=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/build/cmake/android.toolchain.cmake \
-D CMAKE_ANDROID_STL_TYPE=c++_static \
-D ANDROID_PLATFORM=${{ env.ANDROID_SDK_VERSION }} \
-D ANDROID_ABI=${{ matrix.abi }} \
-D USEARCH_BUILD_LIB_C=1 \
-D USEARCH_BUILD_TEST_CPP=0 \
-D USEARCH_BUILD_BENCH_CPP=0
cmake --build build_artifacts --config Release
- name: Package library
run: |
zip -j usearch_android_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.zip build_artifacts/libusearch_c.so c/usearch.h
- name: Upload native library for Java
uses: actions/upload-artifact@v5
with:
name: native-libs-android-${{ matrix.arch }}
path: build_artifacts/libusearch_c.so
retention-days: 1
- name: Upload archive
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.zip"
update_latest_release: true
build_jni_linux:
name: Build JNI for Linux
runs-on: ubuntu-24.04
needs: versioning
# `-target <triple>` is a Clang flag; without these, CMake picks the host
# GCC and silently drops the cross-target. Mirrors the prerelease
# `test_ubuntu_cross_compilation` job.
env:
CC: clang
CXX: clang++
AR: llvm-ar
NM: llvm-nm
RANLIB: llvm-ranlib
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
cmake_processor: x86_64
target: x86_64-linux-gnu
expected_arch: x86-64
- arch: arm64
cmake_processor: aarch64
target: aarch64-linux-gnu
expected_arch: aarch64
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang mold make crossbuild-essential-arm64 crossbuild-essential-armhf
# `-fuse-ld=mold` keeps clang LTO on while sidestepping the
# experimental `lld 1:18.0-59~exp2` from Noble universe that
# segfaults on the widened `nk_shared` LTO unit.
- name: Build JNI library
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.cmake_processor }} \
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=mold \
-DCMAKE_MODULE_LINKER_FLAGS=-fuse-ld=mold \
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold \
-DUSEARCH_BUILD_JNI=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0 \
-DUSEARCH_BUILD_LIB_C=0 \
-DUSEARCH_USE_NUMKONG=1 \
-DNK_DYNAMIC_DISPATCH=1
cmake --build build_artifacts --config Release -j
# Guard against silent host-toolchain fallback — the binary must actually
# be for the target arch, otherwise packaging will ship a broken library.
- name: Verify target architecture
run: |
file build_artifacts/libusearch_jni.so | grep -q '${{ matrix.expected_arch }}'
- name: Upload JNI library artifact
uses: actions/upload-artifact@v5
with:
name: usearch-jni-linux-${{ matrix.arch }}
path: build_artifacts/libusearch_jni.so
retention-days: 1
build_jni_windows:
name: Build JNI for Windows
runs-on: windows-2022
needs: versioning
# Only x64 is supported today. 32-bit MSVC leaves NumKong's SIMD backends
# undefined, and ARM64 MSVC hits a stale `<immintrin.h>` include in
# NumKong — both require upstream fixes.
strategy:
fail-fast: false
matrix:
include:
- arch: x64
cmake_arch: x64
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Build JNI library
run: |
cmake -B build_artifacts -A ${{ matrix.cmake_arch }} `
-DCMAKE_BUILD_TYPE=Release `
-DUSEARCH_BUILD_JNI=1 `
-DUSEARCH_BUILD_TEST_CPP=0 `
-DUSEARCH_BUILD_BENCH_CPP=0 `
-DUSEARCH_BUILD_LIB_C=0 `
-DUSEARCH_USE_NUMKONG=1 `
-DNK_DYNAMIC_DISPATCH=1
cmake --build build_artifacts --config Release
- name: Upload JNI library artifact
uses: actions/upload-artifact@v5
with:
name: usearch-jni-windows-${{ matrix.arch }}
path: build_artifacts/libusearch_jni.dll
retention-days: 1
build_jni_macos:
name: Build JNI for macOS
runs-on: macos-15
needs: versioning
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
cmake_arch: x86_64
- arch: arm64
cmake_arch: arm64
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Build JNI library
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.cmake_arch }} \
-DUSEARCH_BUILD_JNI=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0 \
-DUSEARCH_BUILD_LIB_C=0 \
-DUSEARCH_USE_NUMKONG=1 \
-DNK_DYNAMIC_DISPATCH=1
cmake --build build_artifacts --config Release
- name: Verify target architecture
run: |
file build_artifacts/libusearch_jni.dylib | grep -q '${{ matrix.cmake_arch }}'
- name: Upload JNI library artifact
uses: actions/upload-artifact@v5
with:
name: usearch-jni-macos-${{ matrix.arch }}
path: build_artifacts/libusearch_jni.dylib
retention-days: 1
build_jni_android:
name: Build JNI for Android
runs-on: ubuntu-24.04
needs: versioning
strategy:
fail-fast: false
matrix:
include:
- processor: armv7a
abi: armeabi-v7a
arch: arm32
- processor: aarch64
abi: arm64-v8a
arch: arm64
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Install NDK
run: |
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ env.ANDROID_NDK_VERSION }}"
- name: Build JNI library
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_HOME}/ndk/${{ env.ANDROID_NDK_VERSION }}/build/cmake/android.toolchain.cmake \
-DCMAKE_ANDROID_STL_TYPE=c++_static \
-DANDROID_PLATFORM=${{ env.ANDROID_SDK_VERSION }} \
-DANDROID_ABI=${{ matrix.abi }} \
-DUSEARCH_BUILD_JNI=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0 \
-DUSEARCH_BUILD_LIB_C=0 \
-DUSEARCH_USE_NUMKONG=1 \
-DNK_TARGET_NEON=1 \
-DNK_TARGET_NEONBFDOT=1 \
-DNK_TARGET_NEONHALF=1 \
-DNK_TARGET_NEONSDOT=1 \
-DNK_DYNAMIC_DISPATCH=1
cmake --build build_artifacts --config Release
- name: Upload JNI library artifact
uses: actions/upload-artifact@v5
with:
name: usearch-jni-android-${{ matrix.arch }}
path: build_artifacts/libusearch_jni.so
retention-days: 1
create_wasm_library:
name: Build WASM Library
runs-on: ubuntu-24.04
needs: versioning
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Get version
id: set_version
run: |
version=$(cat VERSION)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
- name: Build WASM with CMake
run: |
emcmake cmake -B build_wasm \
-DCMAKE_BUILD_TYPE=Release \
-DUSEARCH_BUILD_LIB_C=ON \
-DUSEARCH_BUILD_TEST_CPP=OFF \
-DUSEARCH_BUILD_TEST_C=OFF \
-DUSEARCH_BUILD_BENCH_CPP=OFF \
-DUSEARCH_BUILD_SQLITE=OFF \
-DUSEARCH_USE_OPENMP=OFF \
-DUSEARCH_USE_NUMKONG=ON \
-DUSEARCH_USE_JEMALLOC=OFF
emmake cmake --build build_wasm --config Release
cd build_wasm
cp ../c/usearch.h .
tar -czf ../usearch_wasm_${{ steps.set_version.outputs.version }}.tar.gz libusearch_c.* usearch.h
zip -j ../usearch_wasm_${{ steps.set_version.outputs.version }}.zip libusearch_c.* usearch.h
- name: Upload archives
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "usearch_wasm_*.tar.gz;usearch_wasm_*.zip"
update_latest_release: true
publish_checksums:
name: Compute Assets Checksums
runs-on: ubuntu-24.04
needs:
[
versioning,
create_linux_deb_package,
create_windows_dll_library,
create_macos_dylib_library,
create_android_library,
create_wasm_library,
publish_java,
build_docs,
]
steps:
- name: Get last release ID
id: last_release
run: |
response=$(curl -s -H "Authorization: Bearer ${{ secrets.SEMANTIC_RELEASE_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
echo "last_release_id=$(echo "$response" | jq -r '.id')" >> $GITHUB_OUTPUT
- name: Download release assets
uses: robinraju/release-downloader@v1.12
with:
latest: true
fileName: "*"
out-file-path: "downloads"
tarBall: true
zipBall: true
- name: Generate hash list
id: hash_list
run: |
cd $GITHUB_WORKSPACE/downloads
{
echo "## Hashes"
for asset_name in $(ls); do
asset_hash=$(sha256sum $asset_name | awk '{print $1}')
echo "* $asset_name : \`$asset_hash\`"
done
} > hashes.md
echo "hash_body<<EOF" >> $GITHUB_OUTPUT
cat hashes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Upload hashes to release
uses: irongut/EditRelease@v1.2.0
with:
token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
id: ${{ steps.last_release.outputs.last_release_id }}
prerelease: false
replacebody: false
body: ${{ steps.hash_list.outputs.hash_body }}
build_wheels:
name: Build Python Wheels
runs-on: ${{ matrix.os }}
needs: versioning
strategy:
matrix:
os: [ubuntu-24.04, macos-14, windows-2022]
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Setup Docker
if: matrix.os == 'ubuntu-24.04'
uses: docker/setup-docker-action@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup QEMU
if: matrix.os == 'ubuntu-24.04' # We only need QEMU for Linux builds
uses: docker/setup-qemu-action@v3
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ENABLE: cpython-freethreading # No-GIL 3.13t builds
CIBW_TEST_SKIP: "*-win_arm64" # Too complex to emulate Windows ARM
- name: Upload wheels
uses: actions/upload-artifact@v5
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
overwrite: true
publish_python:
name: Publish Python
needs: build_wheels
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/p/usearch
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v6
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
verbose: true
print-hash: true
build_javascript:
name: Build JavaScript Native Modules
needs: versioning
strategy:
fail-fast: false
matrix:
arch: [x64, x86]
# Windows pre-build is not working
# - windows-latest
os: [macos-14, ubuntu-24.04]
exclude:
- arch: x86
os: macos-14
- arch: x86
os: ubuntu-24.04
runs-on: ${{ matrix.os }}
env:
CC: gcc
CXX: g++
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
architecture: ${{ matrix.arch }}
- name: Update compilers
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt update
sudo apt install -y cmake build-essential libjemalloc-dev libomp-dev
sudo apt install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu g++-aarch64-linux-gnu
# NPM installation fails spuriously all the time
- name: Install Dependencies
run: |
npm install --ignore-scripts
- run: npm run prebuild-single
if: matrix.os != 'macos-14'
- run: npm run prebuild-darwin-x64+arm64
env:
CC: clang
CXX: clang++
if: matrix.os == 'macos-14'
- run: file prebuilds/*/*
if: matrix.os == 'macos-14'
- name: Extra for cross build
if: matrix.os == 'ubuntu-24.04'
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
AR: aarch64-linux-gnu-ar
AS: aarch64-linux-gnu-as
LD: aarch64-linux-gnu-ld
STRIP: aarch64-linux-gnu-strip
run: |
npm run prebuild-arm64
aarch64-linux-gnu-strip prebuilds/linux-arm64/*node
- name: Upload prebuilds
uses: actions/upload-artifact@v5
with:
name: prebuilds-${{ matrix.os }}-${{ matrix.arch }}
path: prebuilds
retention-days: 1
publish_javascript:
name: Publish JavaScript
needs: build_javascript
runs-on: ubuntu-24.04
environment:
name: npm-usearch
url: https://www.npmjs.com/package/usearch
permissions:
contents: read
id-token: write
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Download prebuilds
uses: actions/download-artifact@v6
with:
pattern: prebuilds-*
merge-multiple: true
path: prebuilds
- name: Look for links
run: find . -type f -links +1
# NPM installation fails spuriously all the time
- name: Install Dependencies
run: |
npm install --ignore-scripts
- name: Build the JS from TS
run: npm run build-js
- name: Last minute test with prebuild artifact
run: npm run test
- name: Publish Dry Run
run: npm publish --dry-run
- name: Publish
run: npm publish --provenance --access public
publish_rust:
name: Publish Rust
needs: versioning
runs-on: ubuntu-24.04
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish_java:
name: Publish Java
needs: [versioning, build_jni_linux, build_jni_windows, build_jni_macos, build_jni_android]
runs-on: ubuntu-24.04
permissions:
contents: write
packages: write
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
steps:
- name: Check out refreshed version
uses: actions/checkout@v6
with:
ref: "main"
- name: Pull Git submodules
run: git submodule update --init --recursive
- name: Download all JNI libraries
uses: actions/download-artifact@v6
with:
pattern: usearch-jni-*
- name: Set up Java
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "adopt"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build fat JAR with all platforms
run: |
# First build the JAR, which will build local native lib
# and overwrite "build/libs/usearch/shared"
gradle compileJava processResources
# Now organize the pre-built JNI libraries to overwrite the local one
mkdir -p build/libs/usearch/shared/{linux-amd64,linux-arm64,windows-amd64,windows-x86,windows-arm64,darwin-amd64,darwin-arm64,android-arm64,android-arm32}
# Linux
cp usearch-jni-linux-amd64/libusearch_jni.so build/libs/usearch/shared/linux-amd64/libusearch_jni.so || true
cp usearch-jni-linux-arm64/libusearch_jni.so build/libs/usearch/shared/linux-arm64/libusearch_jni.so || true
# Windows
cp usearch-jni-windows-x64/libusearch_jni.dll build/libs/usearch/shared/windows-amd64/libusearch_jni.dll || true
cp usearch-jni-windows-x86/libusearch_jni.dll build/libs/usearch/shared/windows-x86/libusearch_jni.dll || true
cp usearch-jni-windows-arm64/libusearch_jni.dll build/libs/usearch/shared/windows-arm64/libusearch_jni.dll || true