6
6
pull_request :
7
7
8
8
jobs :
9
+ dotnet-build :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout repository
13
+ uses : actions/checkout@v4
14
+ with :
15
+ submodules : recursive
16
+
17
+ - name : Setup .NET
18
+ uses : actions/setup-dotnet@v4
19
+ with :
20
+ dotnet-version : 9.0.x
21
+
22
+ - name : Restore dependencies
23
+ run : dotnet restore
24
+
25
+ - name : Build managed projects
26
+ run : dotnet build --configuration Release --no-restore
27
+
9
28
native-linux :
29
+ needs : dotnet-build
10
30
runs-on : ubuntu-latest
11
31
steps :
12
32
- name : Checkout repository
36
56
name : native-linux-x64
37
57
path : artifacts/native/linux-x64/libmlxsharp.so
38
58
39
- build-test :
40
- needs : native-linux
59
+ native-macos :
60
+ needs : dotnet-build
61
+ runs-on : macos-latest
62
+ steps :
63
+ - name : Checkout repository
64
+ uses : actions/checkout@v4
65
+ with :
66
+ submodules : recursive
67
+
68
+ - name : Install CMake
69
+ run : brew install cmake
70
+
71
+ - name : Configure native build
72
+ run : cmake -S native -B native/build/macos -DCMAKE_BUILD_TYPE=Release
73
+
74
+ - name : Build native library
75
+ run : cmake --build native/build/macos --target mlxsharp --config Release
76
+
77
+ - name : Package native artifact
78
+ run : |
79
+ mkdir -p artifacts/native/osx-arm64
80
+ cp native/build/macos/libmlxsharp.dylib artifacts/native/osx-arm64/
81
+
82
+ - name : Upload native artifact
83
+ uses : actions/upload-artifact@v4
84
+ with :
85
+ name : native-osx-arm64
86
+ path : artifacts/native/osx-arm64/libmlxsharp.dylib
87
+
88
+ package-test :
89
+ needs :
90
+ - native-linux
91
+ - native-macos
41
92
runs-on : macos-latest
42
93
steps :
43
94
- name : Checkout repository
@@ -59,21 +110,6 @@ jobs:
59
110
- name : Build C# projects (initial validation)
60
111
run : dotnet build --configuration Release --no-restore
61
112
62
- - name : Install CMake
63
- run : brew install cmake
64
-
65
- - name : Build native stub library
66
- run : |
67
- cmake -S native -B native/build -DCMAKE_BUILD_TYPE=Release
68
- cmake --build native/build --target mlxsharp --config Release
69
- mkdir -p src/MLXSharp/runtimes/osx-arm64/native
70
- cp native/build/libmlxsharp.dylib src/MLXSharp/runtimes/osx-arm64/native/
71
- echo "Native library built:"
72
- ls -la src/MLXSharp/runtimes/osx-arm64/native/
73
-
74
- - name : Rebuild solution with native libraries
75
- run : dotnet build --configuration Release --no-restore
76
-
77
113
- name : Setup Python for HuggingFace
78
114
uses : actions/setup-python@v5
79
115
with :
@@ -89,6 +125,28 @@ jobs:
89
125
echo "Model files:"
90
126
ls -la models/Qwen1.5-0.5B-Chat-4bit/
91
127
128
+ - name : Download macOS native library
129
+ uses : actions/download-artifact@v4
130
+ with :
131
+ name : native-osx-arm64
132
+ path : artifacts/native/osx-arm64
133
+
134
+ - name : Download Linux native library
135
+ uses : actions/download-artifact@v4
136
+ with :
137
+ name : native-linux-x64
138
+ path : artifacts/native/linux-x64
139
+
140
+ - name : Stage native libraries in project
141
+ run : |
142
+ mkdir -p src/MLXSharp/runtimes/osx-arm64/native
143
+ cp artifacts/native/osx-arm64/libmlxsharp.dylib src/MLXSharp/runtimes/osx-arm64/native/
144
+ mkdir -p src/MLXSharp/runtimes/linux-x64/native
145
+ cp artifacts/native/linux-x64/libmlxsharp.so src/MLXSharp/runtimes/linux-x64/native/
146
+
147
+ - name : Build C# projects with native libraries
148
+ run : dotnet build --configuration Release --no-restore
149
+
92
150
- name : Copy native library to test output
93
151
run : |
94
152
TEST_OUTPUT="src/MLXSharp.Tests/bin/Release/net9.0"
@@ -106,25 +164,14 @@ jobs:
106
164
mkdir -p artifacts/test-results
107
165
mkdir -p artifacts/packages
108
166
mkdir -p 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/
167
+ cp artifacts/native/osx-arm64/libmlxsharp.dylib artifacts/native/
121
168
cp artifacts/native/linux-x64/libmlxsharp.so artifacts/native/
122
169
123
170
- name : Pack MLXSharp library
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
171
+ run : dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/artifacts/ native/osx-arm64 /libmlxsharp.dylib -p:MLXSharpLinuxNativeBinary=$GITHUB_WORKSPACE/artifacts/native/linux-x64/libmlxsharp.so
125
172
126
173
- name : Pack MLXSharp.SemanticKernel library
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
174
+ run : dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --output artifacts/packages -p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/artifacts/ native/osx-arm64 /libmlxsharp.dylib -p:MLXSharpLinuxNativeBinary=$GITHUB_WORKSPACE/artifacts/native/linux-x64/libmlxsharp.so -p:MLXSharpSkipLinuxNativeValidation=true
128
175
129
176
- name : Verify package contains native libraries
130
177
run : |
@@ -195,7 +242,7 @@ jobs:
195
242
196
243
release :
197
244
if : github.ref == 'refs/heads/main' && github.event_name == 'push'
198
- needs : build -test
245
+ needs : package -test
199
246
runs-on : ubuntu-latest
200
247
permissions :
201
248
contents : write
0 commit comments