95 lines
2.6 KiB
YAML
95 lines
2.6 KiB
YAML
name: Build macOS arm64 wheels
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- 'metal-*'
|
|
- 'q-*'
|
|
- attn-mask-fix
|
|
- fix-rope
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch_to_build:
|
|
description: 'Branch to build (optional, defaults to current ref)'
|
|
required: false
|
|
default: ''
|
|
|
|
concurrency:
|
|
group: build-${{ github.ref }}-${{ github.event.inputs.branch_to_build }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
name: Build wheel (Python ${{ matrix.python }})
|
|
runs-on: macos-14
|
|
timeout-minutes: 60
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
python: ['3.11', '3.12']
|
|
env:
|
|
CMAKE_BUILD_PARALLEL_LEVEL: '4'
|
|
steps:
|
|
- name: Determine target branch
|
|
id: branch
|
|
run: |
|
|
NAME="${{ github.event.inputs.branch_to_build }}"
|
|
if [ -z "$NAME" ]; then
|
|
NAME="${{ github.ref_name }}"
|
|
fi
|
|
# Sanitize for artifact naming (replace / with -)
|
|
SAFE_NAME=$(echo "$NAME" | tr '/' '-')
|
|
echo "name=$NAME" >> $GITHUB_OUTPUT
|
|
echo "safe_name=$SAFE_NAME" >> $GITHUB_OUTPUT
|
|
echo "Target branch: $NAME (safe: $SAFE_NAME)"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ steps.branch.outputs.name }}
|
|
submodules: recursive
|
|
|
|
- name: Set up Python ${{ matrix.python }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python }}
|
|
|
|
- name: Cache pip
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/pip
|
|
~/Library/Caches/pip
|
|
key: pip-${{ runner.os }}-py${{ matrix.python }}-${{ hashFiles('CMakeLists.txt', 'setup.py', 'pyproject.toml') }}
|
|
restore-keys: |
|
|
pip-${{ runner.os }}-py${{ matrix.python }}-
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
python -m pip install -U pip wheel build setuptools cmake nanobind
|
|
|
|
- name: Build wheel
|
|
run: |
|
|
mkdir -p ./wheels
|
|
pip wheel --no-deps . -w ./wheels
|
|
|
|
- name: List built wheels
|
|
run: ls -lh ./wheels
|
|
|
|
- name: Upload wheel artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: mlx-${{ steps.branch.outputs.safe_name }}-py${{ matrix.python }}-wheels
|
|
path: ./wheels/*.whl
|
|
retention-days: 30
|
|
if-no-files-found: error
|
|
|
|
- name: Create GitHub Release (on tag)
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: ./wheels/*.whl
|
|
fail_on_unmatched_files: false
|
|
generate_release_notes: true
|