Skip to content

Commit 7f65f2a

Browse files
authored
ci: add macOS arm64 (Metal) build (#2)
* ci: add macOS arm64 (Metal) build for stable-diffusion.cpp Adds a macos-arm64-cmake job covering [macos-14, macos-latest] that builds leejet/stable-diffusion.cpp with Metal enabled and produces a release-ready sd-*-bin-Darwin-macOS-<ver>-arm64.zip artifact, mirroring the existing Linux job's naming convention. Wired into the release job so macOS arm64 binaries are attached alongside Linux/Windows on scheduled and manual releases. * ci(macos): bake @loader_path rpath so dylib loads next to binary Without this, sd-cli ships with the GitHub runner's absolute build path hardcoded in its rpath and fails at runtime with 'Library not loaded: @rpath/libstable-diffusion.dylib'. Mirrors llama.cpp's release.yml flags. * ci(macos): use stable artifact filename without OS version Drop the dynamic Darwin-macOS-{sw_vers}-arm64 suffix in favor of a stable sd-{branch}-{hash}-bin-Darwin-arm64.zip name (with -latest variant for macos-latest). The previous naming embedded the runner image's macOS point release (e.g. 14.8.5, 15.7.4), which churns silently as GitHub patches the image and would break downstream consumers (Lemonade C++) that download by exact filename. Matches the fixed-name pattern already used by the Windows builds. * ci: grant contents:write so the release job can publish artifacts Without this, the workflow's GITHUB_TOKEN defaults to read-only on forks and the 'Create release' / 'Upload release' steps fail with HTTP 403 'Resource not accessible by integration'. Same fix the Linux/Windows release flow needs to function on Geramy's fork; safe on upstream where the org-default token already has write access (this just makes it explicit and forks-portable). * ci(macos): name artifact …Darwin-arm64-metal.zip to align with backend ID Lemonade's recipe matrix is adopting a 'metal' backend identifier for macOS arm64 (mirroring the existing llamacpp/metal pattern). Renaming the artifact's suffix to match keeps Lemonade C++'s download URL construction trivial (filename = sd-{ver}-bin-Darwin-arm64-metal.zip) and signals to consumers that this build has Metal acceleration enabled (GGML_METAL=ON GGML_METAL_USE_BF16=ON GGML_METAL_EMBED_LIBRARY=ON).
1 parent 8d8f55a commit 7f65f2a

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
env:
1414
BRANCH_NAME: master
1515

16+
permissions:
17+
contents: write
18+
1619
concurrency:
1720
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
1821
cancel-in-progress: true
@@ -549,6 +552,70 @@ jobs:
549552
path: |
550553
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip
551554
555+
macos-arm64-cmake:
556+
strategy:
557+
fail-fast: false
558+
matrix:
559+
include:
560+
- os: macos-14
561+
label: macos-14
562+
archive_suffix: ""
563+
- os: macos-latest
564+
label: macos-latest
565+
archive_suffix: "-latest"
566+
runs-on: ${{ matrix.os }}
567+
568+
steps:
569+
- name: Clone
570+
uses: actions/checkout@v6
571+
with:
572+
submodules: recursive
573+
fetch-depth: 0
574+
repository: 'leejet/stable-diffusion.cpp'
575+
576+
- name: ccache
577+
uses: ggml-org/ccache-action@v1.2.21
578+
with:
579+
key: macos-arm64-${{ matrix.label }}
580+
evict-old-files: 1d
581+
582+
- name: Build
583+
id: cmake_build
584+
run: |
585+
sysctl -a
586+
mkdir build
587+
cd build
588+
cmake .. \
589+
-DGGML_METAL=ON \
590+
-DGGML_METAL_USE_BF16=ON \
591+
-DGGML_METAL_EMBED_LIBRARY=ON \
592+
-DSD_BUILD_SHARED_LIBS=ON \
593+
-DCMAKE_INSTALL_RPATH='@loader_path' \
594+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
595+
-DCMAKE_BUILD_TYPE=Release
596+
cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
597+
598+
- name: Get commit hash
599+
id: commit
600+
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
601+
uses: prompt/actions-commit-hash@v2
602+
603+
- name: Pack artifacts
604+
id: pack_artifacts
605+
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
606+
run: |
607+
cp ggml/LICENSE ./build/bin/ggml.txt
608+
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
609+
zip -j sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Darwin-arm64-metal${{ matrix.archive_suffix }}.zip ./build/bin/*
610+
611+
- name: Upload artifacts
612+
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
613+
uses: actions/upload-artifact@v4
614+
with:
615+
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Darwin-arm64-metal${{ matrix.archive_suffix }}.zip
616+
path: |
617+
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-Darwin-arm64-metal${{ matrix.archive_suffix }}.zip
618+
552619
release:
553620
if: ${{ github.event_name == 'schedule' || github.event.inputs.create_release == 'true' }}
554621

@@ -560,6 +627,7 @@ jobs:
560627
- windows-latest-cmake-hip
561628
- windows-latest-rocm
562629
- windows-latest-cmake
630+
- macos-arm64-cmake
563631

564632
steps:
565633
- name: Clone

0 commit comments

Comments
 (0)