66 pull_request :
77
88jobs :
9+ native-linux :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout repository
13+ uses : actions/checkout@v4
14+ with :
15+ submodules : recursive
16+
17+ - name : Install build dependencies
18+ run : |
19+ sudo apt-get update
20+ sudo apt-get install -y build-essential cmake libopenblas-dev liblapack-dev
21+
22+ - name : Configure native build
23+ run : cmake -S native -B native/build/linux -DCMAKE_BUILD_TYPE=Release
24+
25+ - name : Build native library
26+ run : cmake --build native/build/linux --target mlxsharp --config Release
27+
28+ - name : Package native artifact
29+ run : |
30+ mkdir -p artifacts/native/linux-x64
31+ cp native/build/linux/libmlxsharp.so artifacts/native/linux-x64/
32+
33+ - name : Upload native artifact
34+ uses : actions/upload-artifact@v4
35+ with :
36+ name : native-linux-x64
37+ path : artifacts/native/linux-x64/libmlxsharp.so
38+
939 build-test :
40+ needs : native-linux
1041 runs-on : macos-latest
1142 steps :
1243 - name : Checkout repository
@@ -35,10 +66,10 @@ jobs:
3566 run : |
3667 cmake -S native -B native/build -DCMAKE_BUILD_TYPE=Release
3768 cmake --build native/build --target mlxsharp --config Release
38- mkdir -p src/MLXSharp.Native /runtimes/osx-arm64/native
39- cp native/build/libmlxsharp.dylib src/MLXSharp.Native /runtimes/osx-arm64/native/
69+ mkdir -p src/MLXSharp/runtimes/osx-arm64/native
70+ cp native/build/libmlxsharp.dylib src/MLXSharp/runtimes/osx-arm64/native/
4071 echo "Native library built:"
41- ls -la src/MLXSharp.Native /runtimes/osx-arm64/native/
72+ ls -la src/MLXSharp/runtimes/osx-arm64/native/
4273
4374 - name : Rebuild solution with native libraries
4475 run : dotnet build --configuration Release --no-restore
6293 run : |
6394 TEST_OUTPUT="src/MLXSharp.Tests/bin/Release/net9.0"
6495 mkdir -p "$TEST_OUTPUT/runtimes/osx-arm64/native"
65- cp src/MLXSharp.Native /runtimes/osx-arm64/native/libmlxsharp.dylib "$TEST_OUTPUT/runtimes/osx-arm64/native/"
96+ cp src/MLXSharp/runtimes/osx-arm64/native/libmlxsharp.dylib "$TEST_OUTPUT/runtimes/osx-arm64/native/"
6697 ls -la "$TEST_OUTPUT/runtimes/osx-arm64/native/"
6798
6899 - name : Run tests
@@ -75,13 +106,25 @@ jobs:
75106 mkdir -p artifacts/test-results
76107 mkdir -p artifacts/packages
77108 mkdir -p artifacts/native
78- cp src/MLXSharp.Native/runtimes/osx-arm64/native/libmlxsharp.dylib artifacts/native/
109+ cp src/MLXSharp/runtimes/osx-arm64/native/libmlxsharp.dylib artifacts/native/
110+
111+ - name : Download Linux native library
112+ uses : actions/download-artifact@v4
113+ with :
114+ name : native-linux-x64
115+ path : artifacts/native/linux-x64
116+
117+ - name : Stage Linux native library in project
118+ run : |
119+ mkdir -p src/MLXSharp/runtimes/linux-x64/native
120+ cp artifacts/native/linux-x64/libmlxsharp.so src/MLXSharp/runtimes/linux-x64/native/
121+ cp artifacts/native/linux-x64/libmlxsharp.so artifacts/native/
79122
80123 - name : Pack MLXSharp library
81- run : dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib
124+ run : dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib -p:MLXSharpLinuxNativeBinary=$GITHUB_WORKSPACE/artifacts/native/linux-x64/libmlxsharp.so
82125
83126 - name : Pack MLXSharp.SemanticKernel library
84- run : dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib
127+ run : dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib -p:MLXSharpLinuxNativeBinary=$GITHUB_WORKSPACE/artifacts/native/linux-x64/libmlxsharp.so -p:MLXSharpSkipLinuxNativeValidation=true
85128
86129 - name : Verify package contains native libraries
87130 run : |
@@ -98,11 +141,25 @@ jobs:
98141 echo "Inspecting ${package}"
99142 filename=$(basename "${package}")
100143 case "${filename}" in
144+ MLXSharp.SemanticKernel.*.nupkg)
145+ echo " ↷ Skipping native check for ${filename}"
146+ ;;
101147 MLXSharp.*.nupkg)
148+ package_missing=0
102149 if unzip -l "${package}" | grep -q "runtimes/osx-arm64/native/libmlxsharp.dylib"; then
103- echo " ✓ Native library found"
150+ echo " ✓ macOS library present"
151+ else
152+ echo " ✗ macOS library missing"
153+ package_missing=1
154+ fi
155+ if unzip -l "${package}" | grep -q "runtimes/linux-x64/native/libmlxsharp.so"; then
156+ echo " ✓ Linux library present"
104157 else
105- echo " ✗ Native library NOT found"
158+ echo " ✗ Linux library missing"
159+ package_missing=1
160+ fi
161+
162+ if [ ${package_missing} -ne 0 ]; then
106163 unzip -l "${package}"
107164 missing=1
108165 fi
0 commit comments