Files
xemu/.github/workflows/build-macos.yml
2026-01-04 23:38:25 -07:00

114 lines
3.8 KiB
YAML

name: Build for macOS
on:
workflow_call:
jobs:
build:
name: Build for macOS (${{ matrix.arch }}, ${{ matrix.configuration }})
runs-on: macos-15
strategy:
matrix:
arch: [x86_64, arm64]
configuration: [debug, release]
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
CCACHE_DIR: ${{ github.workspace }}/xemu-ccache
CCACHE_MAXSIZE: 512M
steps:
- name: Download source package
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
name: src
- name: Extract source package
run: tar -xf xemu-*.tar.zst --strip-components=2
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: '3.12'
- name: Install dependencies
run: |
brew install \
ccache \
coreutils \
dylibbundler
pip install pyyaml requests
- name: Initialize compiler, library cache
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v4
with:
path: |
xemu-ccache
macos-pkgs
key: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-
- name: Setup ccache
run: |
echo "PATH=/opt/homebrew/opt/ccache/libexec:$PATH" >> "$GITHUB_ENV"
ccache -z
- name: Compile
env:
BUILD_FLAGS: ${{ matrix.configuration == 'debug' && '--debug' || '' }}
run: ./build.sh -a ${{ matrix.arch }} ${BUILD_FLAGS}
- name: Report ccache stats
run: ccache -s
- name: Package
id: package
run: |
# Determine package filename
version="$(cat XEMU_VERSION)"
if [[ "${{ matrix.configuration}}" == "debug" ]]; then
version="${version}-dbg"
fi
pkg_filename="xemu-${version}-macos-${{ matrix.arch }}-unsigned.zip"
echo "pkg_filename=${pkg_filename}" >> $GITHUB_OUTPUT
pushd dist
zip -r ../${pkg_filename} *
popd
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: xemu-macos-${{ matrix.arch }}-${{ matrix.configuration }}
path: ${{ steps.package.outputs.pkg_filename }}
compression-level: 0
build_universal:
name: Build macOS Universal bundle (${{ matrix.configuration }})
runs-on: macos-15
needs: build
strategy:
matrix:
configuration: [debug, release]
steps:
- name: Download architecture-specific builds
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v4
with:
pattern: "xemu-macos-*-${{ matrix.configuration }}"
merge-multiple: true
- name: Build Universal bundle
run: |
mkdir dist
pushd dist
for arch in x86_64 arm64; do
unzip -o ../xemu-*-${arch}-unsigned.zip
mv xemu.app/Contents/MacOS/xemu ../xemu_${arch}
done
lipo -create -output xemu.app/Contents/MacOS/xemu ../xemu_x86_64 ../xemu_arm64
codesign --force --deep --preserve-metadata=entitlements,requirements,flags,runtime --sign - xemu.app/Contents/MacOS/xemu
popd
- name: Package
id: package
run: |
pkg_filename="$(ls -1 xemu-*.zip | head -n1 | sed -E 's/(.*)(arm64|x86_64)/\1universal/')"
echo "pkg_filename=${pkg_filename}" >> $GITHUB_OUTPUT
pushd dist
zip -r ../${pkg_filename} *
popd
- name: Upload build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4
with:
name: xemu-macos-universal-${{ matrix.configuration }}
path: ${{ steps.package.outputs.pkg_filename }}
compression-level: 0