ci: Use ninja #285
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: push | |
jobs: | |
build: | |
runs-on: >- | |
${{ | |
((matrix.os == 'linux' && matrix.arch == 'arm64') && | |
'ubuntu-22.04-arm' || | |
((matrix.os == 'mac' && matrix.arch == 'arm64') && | |
'macos-15' || | |
(fromJson('{"linux":"ubuntu-22.04","mac":"macos-13","win":"windows-2022"}')[matrix.os]))) | |
}} | |
continue-on-error: false | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [linux, mac] | |
arch: [arm64, x64] | |
exclude: | |
- os: win | |
arch: arm64 | |
steps: | |
- name: Install linux dependencies | |
if: matrix.os == 'linux' | |
run: sudo apt-get install -y ninja-build libblas-dev liblapack-dev liblapacke-dev | |
- name: Install mac dependencies | |
if: matrix.os == 'mac' | |
run: brew install ninja openblas | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Get number of CPU cores | |
uses: SimenB/github-actions-cpu-cores@v2 | |
id: cpu-cores | |
- name: Build | |
shell: bash | |
run: | | |
yarn | |
yarn build -p ${{ steps.cpu-cores.outputs.count }} \ | |
-G Ninja | |
- name: Test | |
run: yarn test | |
- name: Prepare .node file | |
run: cp build/Release/mlx.node mlx-${{ matrix.os }}-${{ matrix.arch }}.node | |
- name: Prepare .metallib file | |
if: matrix.os == 'mac' && matrix.arch == 'arm64' | |
run: cp build/deps/mlx/mlx/backend/metal/kernels/mlx.metallib mlx-${{ matrix.os }}-${{ matrix.arch }}.metallib | |
- name: Upload Binary Files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mlx-${{ matrix.os }}-${{ matrix.arch }} | |
path: mlx-${{ matrix.os }}-${{ matrix.arch }}.* | |
retention-days: 1 | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [build] | |
runs-on: ubuntu-latest | |
permissions: | |
# Needed by action-gh-release. | |
contents: write | |
steps: | |
- name: Download Files | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Compress files | |
run: gzip * | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
name: node-mlx ${{ github.ref_name }} | |
body: '## Changelog' | |
files: '*.gz' |