name: 'Build macOS release'
description: 'Build MLX releases macOS'

inputs:
  macos-target:
    description: 'macOS build target'
    required: false
    default: '15.0'
  build-backend:
    description: 'Build the backend mlx-metal package'
    type: boolean
    required: false
    default: false

runs:
  using: "composite"
  steps:
    - name: Build Python package
      shell: bash -l {0}
      env:
        DEVELOPER_DIR: /Applications/Xcode-latest.app
        MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
      run: |
        pip install build
        python setup.py clean --all
        MLX_BUILD_STAGE=1 python -m build -w

    - name: Build backend package
      if: ${{ inputs.build-backend }}
      shell: bash -l {0}
      env:
        DEVELOPER_DIR: /Applications/Xcode-latest.app
        MACOSX_DEPLOYMENT_TARGET: ${{ inputs.macos-target }}
      run: |
        python setup.py clean --all
        MLX_BUILD_STAGE=2 python -m build -w
