Skip to content

Commit c75ee0f

Browse files
committed
more api
1 parent 8a28dbd commit c75ee0f

File tree

16 files changed

+1435
-431
lines changed

16 files changed

+1435
-431
lines changed

.github/workflows/ci.yml

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -266,104 +266,104 @@ jobs:
266266
fetch-depth: 0
267267
submodules: recursive
268268

269-
- name: Determine MLX version
270-
id: mlx_version
271-
run: |
272-
git submodule update --init --recursive
273-
git -C extern/mlx fetch --tags
274-
275-
if MLX_TAG=$(git -C extern/mlx describe --tags --abbrev=0 2>/dev/null); then
276-
echo "Detected MLX tag: ${MLX_TAG}"
277-
else
278-
echo "::warning::Unable to determine MLX tag; falling back to commit hash"
279-
MLX_TAG="unknown"
280-
fi
281-
282-
MLX_COMMIT=$(git -C extern/mlx rev-parse --short HEAD)
283-
284-
echo "tag=${MLX_TAG}" >> "$GITHUB_OUTPUT"
285-
echo "commit=${MLX_COMMIT}" >> "$GITHUB_OUTPUT"
286-
287-
- name: Extract version from Directory.Build.props
288-
id: version
289-
run: |
290-
VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props)
291-
echo "version=$VERSION" >> $GITHUB_OUTPUT
292-
echo "Extracted version: $VERSION"
293-
294-
- name: Check if tag exists
295-
id: check_tag
296-
run: |
297-
if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}"; then
298-
echo "exists=true" >> $GITHUB_OUTPUT
299-
echo "Tag v${{ steps.version.outputs.version }} already exists"
300-
else
301-
echo "exists=false" >> $GITHUB_OUTPUT
302-
echo "Tag v${{ steps.version.outputs.version }} does not exist"
303-
fi
304-
305-
- name: Download package artifacts
306-
if: steps.check_tag.outputs.exists == 'false'
307-
uses: actions/download-artifact@v4
308-
with:
309-
name: packages
310-
path: artifacts/packages
311-
312-
- name: Publish to NuGet
313-
if: steps.check_tag.outputs.exists == 'false'
314-
run: |
315-
for package in artifacts/packages/*.nupkg; do
316-
echo "Publishing $package..."
317-
dotnet nuget push "$package" \
318-
--api-key ${{ secrets.NUGET_API_KEY }} \
319-
--source https://api.nuget.org/v3/index.json \
320-
--skip-duplicate || true
321-
done
322-
323-
- name: Create Git tag
324-
if: steps.check_tag.outputs.exists == 'false'
325-
run: |
326-
git config user.name "github-actions[bot]"
327-
git config user.email "github-actions[bot]@users.noreply.github.com"
328-
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
329-
git push origin "v${{ steps.version.outputs.version }}"
330-
331-
- name: Generate release notes
332-
if: steps.check_tag.outputs.exists == 'false'
333-
id: release_notes
334-
env:
335-
RELEASE_VERSION: ${{ steps.version.outputs.version }}
336-
MLX_TAG: ${{ steps.mlx_version.outputs.tag }}
337-
MLX_COMMIT: ${{ steps.mlx_version.outputs.commit }}
338-
run: |
339-
PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
340-
if [ -z "$PREVIOUS_TAG" ]; then
341-
COMMITS=$(git log --pretty=format:"- %s (%h)" --reverse)
342-
else
343-
COMMITS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --reverse)
344-
fi
345-
346-
echo "## What's Changed" > release_notes.md
347-
echo "" >> release_notes.md
348-
echo "$COMMITS" >> release_notes.md
349-
echo "" >> release_notes.md
350-
echo "## Upstream MLX" >> release_notes.md
351-
echo "- Version: ${MLX_TAG}" >> release_notes.md
352-
echo "- Commit: ${MLX_COMMIT}" >> release_notes.md
353-
echo "" >> release_notes.md
354-
echo "## NuGet Packages" >> release_notes.md
355-
echo "- [MLXSharp v${RELEASE_VERSION}](https://www.nuget.org/packages/MLXSharp/${RELEASE_VERSION})" >> release_notes.md
356-
echo "- [MLXSharp.SemanticKernel v${RELEASE_VERSION}](https://www.nuget.org/packages/MLXSharp.SemanticKernel/${RELEASE_VERSION})" >> release_notes.md
357-
358-
cat release_notes.md
359-
360-
- name: Create GitHub Release
361-
if: steps.check_tag.outputs.exists == 'false'
362-
uses: softprops/action-gh-release@v1
363-
with:
364-
tag_name: v${{ steps.version.outputs.version }}
365-
name: Release v${{ steps.version.outputs.version }}
366-
body_path: release_notes.md
367-
files: artifacts/packages/*
368-
env:
369-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
269+
# - name: Determine MLX version
270+
# id: mlx_version
271+
# run: |
272+
# git submodule update --init --recursive
273+
# git -C extern/mlx fetch --tags
274+
#
275+
# if MLX_TAG=$(git -C extern/mlx describe --tags --abbrev=0 2>/dev/null); then
276+
# echo "Detected MLX tag: ${MLX_TAG}"
277+
# else
278+
# echo "::warning::Unable to determine MLX tag; falling back to commit hash"
279+
# MLX_TAG="unknown"
280+
# fi
281+
#
282+
# MLX_COMMIT=$(git -C extern/mlx rev-parse --short HEAD)
283+
#
284+
# echo "tag=${MLX_TAG}" >> "$GITHUB_OUTPUT"
285+
# echo "commit=${MLX_COMMIT}" >> "$GITHUB_OUTPUT"
286+
#
287+
# - name: Extract version from Directory.Build.props
288+
# id: version
289+
# run: |
290+
# VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props)
291+
# echo "version=$VERSION" >> $GITHUB_OUTPUT
292+
# echo "Extracted version: $VERSION"
293+
#
294+
# - name: Check if tag exists
295+
# id: check_tag
296+
# run: |
297+
# if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}"; then
298+
# echo "exists=true" >> $GITHUB_OUTPUT
299+
# echo "Tag v${{ steps.version.outputs.version }} already exists"
300+
# else
301+
# echo "exists=false" >> $GITHUB_OUTPUT
302+
# echo "Tag v${{ steps.version.outputs.version }} does not exist"
303+
# fi
304+
#
305+
# - name: Download package artifacts
306+
# if: steps.check_tag.outputs.exists == 'false'
307+
# uses: actions/download-artifact@v4
308+
# with:
309+
# name: packages
310+
# path: artifacts/packages
311+
#
312+
# - name: Publish to NuGet
313+
# if: steps.check_tag.outputs.exists == 'false'
314+
# run: |
315+
# for package in artifacts/packages/*.nupkg; do
316+
# echo "Publishing $package..."
317+
# dotnet nuget push "$package" \
318+
# --api-key ${{ secrets.NUGET_API_KEY }} \
319+
# --source https://api.nuget.org/v3/index.json \
320+
# --skip-duplicate || true
321+
# done
322+
#
323+
# - name: Create Git tag
324+
# if: steps.check_tag.outputs.exists == 'false'
325+
# run: |
326+
# git config user.name "github-actions[bot]"
327+
# git config user.email "github-actions[bot]@users.noreply.github.com"
328+
# git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
329+
# git push origin "v${{ steps.version.outputs.version }}"
330+
#
331+
# - name: Generate release notes
332+
# if: steps.check_tag.outputs.exists == 'false'
333+
# id: release_notes
334+
# env:
335+
# RELEASE_VERSION: ${{ steps.version.outputs.version }}
336+
# MLX_TAG: ${{ steps.mlx_version.outputs.tag }}
337+
# MLX_COMMIT: ${{ steps.mlx_version.outputs.commit }}
338+
# run: |
339+
# PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
340+
# if [ -z "$PREVIOUS_TAG" ]; then
341+
# COMMITS=$(git log --pretty=format:"- %s (%h)" --reverse)
342+
# else
343+
# COMMITS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --reverse)
344+
# fi
345+
#
346+
# echo "## What's Changed" > release_notes.md
347+
# echo "" >> release_notes.md
348+
# echo "$COMMITS" >> release_notes.md
349+
# echo "" >> release_notes.md
350+
# echo "## Upstream MLX" >> release_notes.md
351+
# echo "- Version: ${MLX_TAG}" >> release_notes.md
352+
# echo "- Commit: ${MLX_COMMIT}" >> release_notes.md
353+
# echo "" >> release_notes.md
354+
# echo "## NuGet Packages" >> release_notes.md
355+
# echo "- [MLXSharp v${RELEASE_VERSION}](https://www.nuget.org/packages/MLXSharp/${RELEASE_VERSION})" >> release_notes.md
356+
# echo "- [MLXSharp.SemanticKernel v${RELEASE_VERSION}](https://www.nuget.org/packages/MLXSharp.SemanticKernel/${RELEASE_VERSION})" >> release_notes.md
357+
#
358+
# cat release_notes.md
359+
#
360+
# - name: Create GitHub Release
361+
# if: steps.check_tag.outputs.exists == 'false'
362+
# uses: softprops/action-gh-release@v1
363+
# with:
364+
# tag_name: v${{ steps.version.outputs.version }}
365+
# name: Release v${{ steps.version.outputs.version }}
366+
# body_path: release_notes.md
367+
# files: artifacts/packages/*
368+
# env:
369+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sync-mlx.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ jobs:
3131
fi
3232
3333
CURRENT_TAG=$(git -C extern/mlx describe --tags --abbrev=0 2>/dev/null || echo "")
34+
CURRENT_COMMIT=$(git -C extern/mlx rev-parse --short HEAD 2>/dev/null || echo "")
35+
LATEST_COMMIT=$(git -C extern/mlx rev-list -n 1 "${LATEST_TAG}")
3436
3537
echo "latest_tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT"
38+
echo "latest_commit=${LATEST_COMMIT}" >> "$GITHUB_OUTPUT"
3639
echo "current_tag=${CURRENT_TAG}" >> "$GITHUB_OUTPUT"
40+
echo "current_commit=${CURRENT_COMMIT}" >> "$GITHUB_OUTPUT"
3741
echo "latest_version=${LATEST_TAG#v}" >> "$GITHUB_OUTPUT"
3842
3943
if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then
@@ -163,3 +167,60 @@ jobs:
163167
});
164168
core.info(`Created PR ${pr.html_url}`);
165169
}
170+
171+
- name: Create tracking issue
172+
if: steps.commit.outputs.changed == 'true'
173+
uses: actions/github-script@v7
174+
env:
175+
ISSUE_TITLE: "Review bindings for MLX ${{ steps.mlx.outputs.latest_tag }}"
176+
LATEST_TAG: ${{ steps.mlx.outputs.latest_tag }}
177+
LATEST_COMMIT: ${{ steps.mlx.outputs.latest_commit }}
178+
CURRENT_TAG: ${{ steps.mlx.outputs.current_tag }}
179+
with:
180+
github-token: ${{ secrets.GITHUB_TOKEN }}
181+
script: |
182+
const issueTitle = process.env.ISSUE_TITLE.replace(/\s+/g, ' ').trim();
183+
const latestTag = process.env.LATEST_TAG;
184+
const latestCommit = process.env.LATEST_COMMIT;
185+
const previousTag = process.env.CURRENT_TAG && process.env.CURRENT_TAG.length > 0 ? process.env.CURRENT_TAG : 'unknown';
186+
const compareBase = previousTag === 'unknown' ? latestTag : previousTag;
187+
const compareUrl = `https://github.com/ml-explore/mlx/compare/${compareBase}...${latestTag}`;
188+
189+
const issueBody = [
190+
`The upstream MLX submodule updated to \`${latestTag}\`.`,
191+
'',
192+
'Please review the upstream diff and ensure the C API (`native/include/mlxsharp/api.h`) and managed bindings stay in sync.',
193+
'',
194+
`- Upstream tag: \`${latestTag}\``,
195+
`- Upstream commit: \`${latestCommit}\``,
196+
`- Previous tag: \`${previousTag}\``,
197+
`- Compare: ${compareUrl}`,
198+
'',
199+
'Track interface updates, adjust `native/src/mlxsharp.cpp`, refresh docs/tests as needed.'
200+
].join('\n');
201+
const owner = context.repo.owner;
202+
const repo = context.repo.repo;
203+
204+
const { data: issues } = await github.rest.issues.listForRepo({
205+
owner,
206+
repo,
207+
state: 'open',
208+
per_page: 100,
209+
});
210+
211+
const existing = issues.find(issue => issue.title === issueTitle);
212+
if (existing) {
213+
core.info(`Issue already exists: ${existing.html_url}`);
214+
return;
215+
}
216+
217+
const { data: created } = await github.rest.issues.create({
218+
owner,
219+
repo,
220+
title: issueTitle,
221+
body: issueBody,
222+
assignees: ['copoit'],
223+
labels: ['dependency-update'],
224+
});
225+
226+
core.info(`Created issue ${created.html_url}`);

native/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ endif()
1515

1616
add_subdirectory(${CMAKE_SOURCE_DIR}/../extern/mlx ${CMAKE_BINARY_DIR}/extern/mlx EXCLUDE_FROM_ALL)
1717

18-
# Stub implementation for testing and development
19-
add_library(mlxsharp SHARED src/mlxsharp.cpp)
18+
add_library(mlxsharp SHARED
19+
src/mlxsharp.cpp
20+
)
2021

2122
target_link_libraries(mlxsharp PRIVATE mlx)
2223

23-
target_include_directories(mlxsharp PRIVATE ${CMAKE_SOURCE_DIR}/../extern/mlx/mlx)
24+
target_include_directories(mlxsharp
25+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
26+
PRIVATE ${CMAKE_SOURCE_DIR}/../extern/mlx/mlx)
2427

2528
target_compile_definitions(mlxsharp PRIVATE MLXSHARP_EXPORTS)
2629

0 commit comments

Comments
 (0)