Skip to content

Commit 0e77a35

Browse files
committed
Fix mac native packaging in CI
1 parent 56d225e commit 0e77a35

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,52 @@ jobs:
7878
cp src/MLXSharp.Native/runtimes/osx-arm64/native/libmlxsharp.dylib artifacts/native/
7979
8080
- name: Pack MLXSharp library
81-
run: dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --output artifacts/packages \
82-
-p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib
81+
run: |
82+
set -euo pipefail
83+
: "${GITHUB_WORKSPACE:=${PWD}}"
84+
MAC_NATIVE_BINARY="${GITHUB_WORKSPACE}/native/build/libmlxsharp.dylib"
85+
echo "Packing MLXSharp with native binary: ${MAC_NATIVE_BINARY}"
86+
dotnet pack \
87+
src/MLXSharp/MLXSharp.csproj \
88+
--configuration Release \
89+
--output artifacts/packages \
90+
"/p:MLXSharpMacNativeBinary=${MAC_NATIVE_BINARY}"
8391
8492
- name: Pack MLXSharp.SemanticKernel library
85-
run: dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --output artifacts/packages \
86-
-p:MLXSharpMacNativeBinary=$GITHUB_WORKSPACE/native/build/libmlxsharp.dylib
93+
run: |
94+
set -euo pipefail
95+
: "${GITHUB_WORKSPACE:=${PWD}}"
96+
MAC_NATIVE_BINARY="${GITHUB_WORKSPACE}/native/build/libmlxsharp.dylib"
97+
echo "Packing MLXSharp.SemanticKernel with native binary: ${MAC_NATIVE_BINARY}"
98+
dotnet pack \
99+
src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj \
100+
--configuration Release \
101+
--output artifacts/packages \
102+
"/p:MLXSharpMacNativeBinary=${MAC_NATIVE_BINARY}"
87103
88104
- name: Verify package contains native libraries
89105
run: |
90106
echo "Checking package contents..."
91-
if unzip -l artifacts/packages/*.nupkg | grep -q "runtimes/osx-arm64/native/libmlxsharp.dylib"; then
92-
echo "✓ Native library found in package"
93-
else
94-
echo "✗ ERROR: Native library NOT found in package!"
95-
echo "Package contents:"
96-
unzip -l artifacts/packages/*.nupkg
107+
shopt -s nullglob
108+
packages=(artifacts/packages/*.nupkg)
109+
if [ ${#packages[@]} -eq 0 ]; then
110+
echo "✗ ERROR: No packages were produced"
111+
exit 1
112+
fi
113+
114+
missing=0
115+
for package in "${packages[@]}"; do
116+
echo "Inspecting ${package}"
117+
if unzip -l "${package}" | grep -q "runtimes/osx-arm64/native/libmlxsharp.dylib"; then
118+
echo " ✓ Native library found"
119+
else
120+
echo " ✗ Native library NOT found"
121+
unzip -l "${package}"
122+
missing=1
123+
fi
124+
done
125+
126+
if [ $missing -ne 0 ]; then
97127
exit 1
98128
fi
99129

src/MLXSharp/MLXSharp.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
</ItemGroup>
1616

1717
<PropertyGroup>
18-
<MLXSharpMacNativeBinary Condition="'$(MLXSharpMacNativeBinary)' == ''">$(MSBuildProjectDirectory)..\..\native\build\libmlxsharp.dylib</MLXSharpMacNativeBinary>
19-
<MLXSharpMacNativeDestination>..\MLXSharp.Native\runtimes\osx-arm64\native\libmlxsharp.dylib</MLXSharpMacNativeDestination>
18+
<MLXProjectRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\'))</MLXProjectRoot>
19+
<MLXSharpMacNativeBinary Condition="'$(MLXSharpMacNativeBinary)' == ''">$([System.IO.Path]::Combine('$(MLXProjectRoot)','native','build','libmlxsharp.dylib'))</MLXSharpMacNativeBinary>
20+
<MLXSharpMacNativeDestination>$([System.IO.Path]::Combine('$(MLXProjectRoot)','src','MLXSharp.Native','runtimes','osx-arm64','native','libmlxsharp.dylib'))</MLXSharpMacNativeDestination>
2021
<MLXSharpSkipMacNativeValidation Condition="'$(MLXSharpSkipMacNativeValidation)' == ''">false</MLXSharpSkipMacNativeValidation>
2122
</PropertyGroup>
2223

0 commit comments

Comments
 (0)