Skip to content

ci: Fix publishing packages #282

ci: Fix publishing packages

ci: Fix publishing packages #282

Workflow file for this run

name: build
on: push
jobs:
build:
runs-on: >-
${{
(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' && matrix.arch == runner.arch
run: sudo apt-get install -y libblas-dev liblapack-dev liblapacke-dev
- name: Install mac dependencies
if: matrix.os == 'mac' && matrix.arch == 'x64'
run: brew install 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 (native)
if: matrix.os != 'linux' || matrix.arch == runner.arch
run: yarn && yarn build -p ${{ steps.cpu-cores.outputs.count }} && yarn test
- name: Set up QEMU
if: matrix.os == 'linux' && matrix.arch != runner.arch
uses: docker/setup-qemu-action@v3
with:
platforms: matrix.arch
- name: Enable multi-arch containers in QEMU
if: matrix.os == 'linux' && matrix.arch != runner.arch
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Build (docker)
if: matrix.os == 'linux' && matrix.arch != runner.arch
uses: addnab/docker-run-action@v3
with:
image: zcbenz/node-mlx:main
options: --platform=linux/${{ matrix.arch }} -v ${{ github.workspace }}:/build -w /build
run: |
export CI=true
yarn && yarn build -p ${{ steps.cpu-cores.outputs.count }} && 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'