PyPI Release #100
This file contains hidden or 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: PyPI Release | ||
|
Check failure on line 1 in .github/workflows/release.yml
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| branches: | ||
| - 'test-publish/*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: 'Dry run (do not publish to PyPi)' | ||
| required: false | ||
| type: boolean | ||
| dev_release: | ||
| description: 'Development release (DEV_RELEASE=1)' | ||
| required: false | ||
| type: boolean | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| build_documentation: | ||
| if: github.repository == 'ml-explore/mlx' | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: ./.github/actions/build-docs | ||
| deploy_documentation: | ||
| if: ${{ !inputs.dry_run }} | ||
| needs: build_documentation | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v5 | ||
| build_linux_release: | ||
| name: ${{ runner.os }} (${{ matrix.toolkit }}, ${{ matrix.arch }}, py${{ matrix.python-version }}) | ||
| if: github.repository == 'ml-explore/mlx' | ||
| strategy: | ||
| matrix: | ||
| arch: ['x86_64', 'aarch64'] | ||
| toolkit: ['cpu', 'cuda-12.9', 'cuda-13.0'] | ||
| python-version: ['3.10'] | ||
| include: | ||
| - toolkit: 'cpu' | ||
| python-version: '3.11' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.12' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.13' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.14' | ||
| runs-on: |- | ||
| ${{ case(matrix.toolkit == 'cpu' && matrix.arch == 'x86_64', 'ubuntu-22.04', | ||
| matrix.toolkit == 'cpu' && matrix.arch == 'aarch64', 'ubuntu-22.04-arm', | ||
| matrix.arch == 'x86_64', 'ubuntu-22-large', | ||
| 'ubuntu-22-large-arm') | ||
| }} | ||
| env: | ||
| PYPI_RELEASE: 1 | ||
| DEV_RELEASE: ${{ inputs.dev_release && 1 || 0 }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: ./.github/actions/setup-linux | ||
| id: setup | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| use-ccache: false | ||
| - uses: ./.github/actions/build-wheel | ||
| with: | ||
| cmake-args: ${{ steps.setup.outputs.cmake-args }} | ||
| build-frontend: ${{ matrix.toolkit == 'cpu' }} | ||
| build-backend: ${{ matrix.python-version == '3.10' }} | ||
| - name: Upload frontend packages | ||
| if: matrix.toolkit == 'cpu' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: frontend-${{ runner.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} | ||
| path: wheelhouse/mlx-*.whl | ||
| if-no-files-found: error | ||
| - name: Upload backend packages | ||
| if: matrix.python-version == '3.10' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: backend-${{ matrix.toolkit }}-${{ runner.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} | ||
| path: | | ||
| wheelhouse/mlx_cpu-*.whl | ||
| wheelhouse/mlx_cuda12-*.whl | ||
| wheelhouse/mlx_cuda13-*.whl | ||
| if-no-files-found: error | ||
| build_mac_release: | ||
| name: macOS (py${{ matrix.python-version }}) | ||
| if: github.repository == 'ml-explore/mlx' | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] | ||
| runs-on: [self-hosted, macos] | ||
| env: | ||
| PYPI_RELEASE: 1 | ||
| DEV_RELEASE: ${{ inputs.dev_release && 1 || 0 }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: ./.github/actions/setup-macos | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Build macOS 14 package | ||
| uses: ./.github/actions/build-macos-release | ||
| with: | ||
| macos-target: '14.0' | ||
| build-backend: ${{ matrix.python-version == '3.10' }} | ||
| - name: Build macOS 15 package | ||
| uses: ./.github/actions/build-macos-release | ||
| with: | ||
| macos-target: '15.0' | ||
| build-backend: ${{ matrix.python-version == '3.10' }} | ||
| - name: Build macOS 26 package | ||
| uses: ./.github/actions/build-macos-release | ||
| with: | ||
| macos-target: '26.2' | ||
| build-backend: ${{ matrix.python-version == '3.10' }} | ||
| - name: Upload MLX artifacts | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: frontend-${{ runner.os }}-py${{ matrix.python-version }} | ||
| path: dist/mlx-*.whl | ||
| if-no-files-found: error | ||
| - name: Upload Metal artifacts | ||
| if: matrix.python-version == '3.10' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: backend-metal-${{ runner.os }} | ||
| path: dist/mlx_metal-*.whl | ||
| if-no-files-found: error | ||
| build_windows_release: | ||
| name: ${{ runner.os }} (${{ matrix.toolkit }}, ${{ matrix.arch }}, py${{ matrix.python-version }}) | ||
| if: github.repository == 'ml-explore/mlx' | ||
| strategy: | ||
| matrix: | ||
| arch: ['x86_64'] | ||
| toolkit: ['cpu', 'cuda-12.9', 'cuda-13.0'] | ||
| python-version: ['3.10'] | ||
| include: | ||
| - toolkit: 'cpu' | ||
| python-version: '3.11' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.12' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.13' | ||
| - toolkit: 'cpu' | ||
| python-version: '3.14' | ||
| runs-on: windows-2022 | ||
| env: | ||
| PYPI_RELEASE: 1 | ||
| DEV_RELEASE: ${{ inputs.dev_release && 1 || 0 }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: ./.github/actions/setup-windows | ||
| id: setup | ||
| with: | ||
| toolkit: ${{ matrix.toolkit }} | ||
| ccache-key: 'ccache-release' | ||
| - uses: ./.github/actions/build-wheel | ||
| with: | ||
| cmake-args: ${{ steps.setup.outputs.cmake-args }} | ||
| build-frontend: ${{ matrix.toolkit == 'cpu' }} | ||
| build-backend: ${{ matrix.python-version == '3.10' }} | ||
| - name: Upload frontend packages | ||
| if: matrix.toolkit == 'cpu' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: frontend-${{ runner.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} | ||
| path: wheelhouse/mlx-*.whl | ||
| if-no-files-found: error | ||
| - name: Upload backend packages | ||
| if: matrix.python-version == '3.10' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| overwrite: true | ||
| name: backend-${{ matrix.toolkit }}-${{ runner.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} | ||
| path: | | ||
| wheelhouse/mlx_cpu-*.whl | ||
| wheelhouse/mlx_cuda12-*.whl | ||
| wheelhouse/mlx_cuda13-*.whl | ||
| if-no-files-found: error | ||
| pypi-publish: | ||
| name: Upload release to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: [build_linux_release, build_mac_release] | ||
| permissions: | ||
| id-token: write | ||
| environment: | ||
| name: ${{ inputs.dry_run && 'dry-run' || 'pypi' }} | ||
| url: https://pypi.org/p/mlx | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: frontend-* | ||
| merge-multiple: true | ||
| path: dist | ||
| - name: Display structure of downloaded files | ||
| run: du -ah dist | ||
| - name: Publish package distributions to PyPI | ||
| if: ${{ !inputs.dry_run }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://upload.pypi.org/legacy/ | ||
| pypi-publish-cuda: | ||
| name: Upload CUDA release to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: [build_linux_release] | ||
| permissions: | ||
| id-token: write | ||
| environment: | ||
| name: ${{ inputs.dry_run && 'dry-run' || 'pypi' }} | ||
| url: https://pypi.org/p/mlx-cuda | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: backend-cuda* | ||
| merge-multiple: true | ||
| path: dist | ||
| - name: Display structure of downloaded files | ||
| run: du -ah dist | ||
| - name: Publish package distributions to PyPI | ||
| if: ${{ !inputs.dry_run }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://upload.pypi.org/legacy/ | ||
| pypi-publish-cpu: | ||
| name: Upload CPU release to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: [build_linux_release] | ||
| permissions: | ||
| id-token: write | ||
| environment: | ||
| name: ${{ inputs.dry_run && 'dry-run' || 'pypi' }} | ||
| url: https://pypi.org/p/mlx-cpu | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| pattern: backend-cpu-* | ||
| merge-multiple: true | ||
| path: dist | ||
| - name: Display structure of downloaded files | ||
| run: du -ah dist | ||
| - name: Publish package distributions to PyPI | ||
| if: ${{ !inputs.dry_run }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://upload.pypi.org/legacy/ | ||
| pypi-publish-metal: | ||
| name: Upload Metal release to PyPI | ||
| runs-on: ubuntu-latest | ||
| needs: [build_mac_release] | ||
| permissions: | ||
| id-token: write | ||
| environment: | ||
| name: ${{ inputs.dry_run && 'dry-run' || 'pypi' }} | ||
| url: https://pypi.org/p/mlx-metal | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| name: backend-metal-* | ||
| path: dist | ||
| - name: Display structure of downloaded files | ||
| run: du -ah dist | ||
| - name: Publish package distributions to PyPI | ||
| if: ${{ !inputs.dry_run }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://upload.pypi.org/legacy/ | ||