macos actions #31
This file contains 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: Build MacOS | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/build-macos.yml' | |
- 'src/**' | |
- 'include/**' | |
- 'example/**' | |
- 'CMakeLists.txt' | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-13, macos-14] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Install Homebrew | |
run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
- name: Update CMake | |
run: brew install cmake | |
- name: Determine CPU Cores | |
id: cpu-info | |
run: echo "CPU_CORES=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV | |
- name: Configure CMake | |
run: cmake -B build -DCMAKE_BUILD_TYPE=Release | |
- name: Build | |
run: cmake --build build --config Release -- -j${{ env.CPU_CORES }} | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }} | |
path: lib/ | |
create-universal-dylibs: | |
needs: build | |
runs-on: macos-latest | |
steps: | |
- name: Download x86_64 Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: macos-13 | |
path: macos-13 | |
- name: Download arm64 Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: macos-14 | |
path: macos-14 | |
- name: Create Universal dylibs | |
run: | | |
mkdir -p universal/lib | |
for dylib in macos-13/*.dylib; do | |
dylib_name=$(basename $dylib) | |
lipo -create macos-13/$dylib_name macos-14/$dylib_name -output universal/$dylib_name | |
done | |
- name: Upload Universal dylibs | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos-universal | |
path: universal/ |