diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14fac2badb..d9f1d29f97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,21 +146,35 @@ jobs: echo 'Not going to push build' fi macos-cmake: - name: macOS (x64) using CMake + name: macOS using CMake runs-on: macos-latest needs: check-code-formatting + strategy: + fail-fast: false + matrix: + arch: [x86_64, arm64] + include: + - arch: x86_64 + cache_key: macos-x64 + build_flags: -DARCH="x86_64" -DWITH_TESTS=on + run_tests: true + - arch: arm64 + cache_key: macos-arm64 + build_flags: -DARCH="arm64" + run_tests: false steps: - name: Checkout uses: actions/checkout@v2 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: - key: macos + key: ${{ matrix.cache_key }} - name: Build OpenRCT2 run: | HOMEBREW_NO_ANALYTICS=1 brew install ninja - . scripts/setenv -q && build -DWITH_TESTS=on -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=on + . scripts/setenv -q && build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=on ${{ matrix.build_flags }} - name: Run Tests + if: ${{matrix.run_tests}} run: . scripts/setenv -q && run-tests - name: Build artifacts run: | @@ -173,7 +187,45 @@ jobs: - name: Upload artifacts (CI) uses: actions/upload-artifact@v2 with: - name: OpenRCT2-${{ runner.os }}-cmake + name: OpenRCT2-${{ runner.os }}-${{ matrix.arch }}-cmake + path: artifacts/openrct2-macos.zip + if-no-files-found: error + macos-universal: + name: macOS universal app bundle + runs-on: macos-latest + needs: macos-cmake + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: download x64 app bundle + uses: actions/download-artifact@v2 + with: + name: OpenRCT2-${{ runner.os }}-x86_64-cmake + path: macos_universal/x64 + - name: download arm64 app bundle + uses: actions/download-artifact@v2 + with: + name: OpenRCT2-${{ runner.os }}-arm64-cmake + path: macos_universal/arm64 + - name: Make Universal app bundle + run: | + . scripts/setenv + cd macos_universal + unzip x64/openrct2-macos.zip -d x64 + unzip arm64/openrct2-macos.zip -d arm64 + create-macos-universal + - name: Create artifact + run: | + . scripts/setenv + mkdir -p artifacts + mv macos_universal/OpenRCT2-universal.app artifacts/OpenRCT2.app + echo -e "\033[0;36mCompressing OpenRCT2.app...\033[0m" + cd artifacts + zip -rqy openrct2-macos.zip OpenRCT2.app + - name: Upload artifacts (CI) + uses: actions/upload-artifact@v2 + with: + name: OpenRCT2-${{ runner.os }}-universal path: artifacts/openrct2-macos.zip if-no-files-found: error linux-portable: diff --git a/scripts/create-macos-universal b/scripts/create-macos-universal new file mode 100755 index 0000000000..2b8f94a412 --- /dev/null +++ b/scripts/create-macos-universal @@ -0,0 +1,28 @@ +#!/bin/bash -e + +echo "Creating macOS universal app bundle" +# create app skeleton +mkdir OpenRCT2-universal.app +mkdir OpenRCT2-universal.app/Contents + +# copy all resources (most will overwrite) +mkdir OpenRCT2-universal.app/Contents/Resources +# Note: g2.dat is expected to only be in one (matching OS of build machine) +rsync -ah x64/OpenRCT2.app/Contents/Resources/* OpenRCT2-universal.app/Contents/Resources/ +rsync -ah arm64/OpenRCT2.app/Contents/Resources/* OpenRCT2-universal.app/Contents/Resources/ + +# create a universal binary +mkdir OpenRCT2-universal.app/Contents/MacOS +lipo -create x64/OpenRCT2.app/Contents/MacOS/OpenRCT2 arm64/OpenRCT2.app/Contents/MacOS/OpenRCT2 -output OpenRCT2-universal.app/Contents/MacOS/OpenRCT2 + +# copy frameworks +mkdir OpenRCT2-universal.app/Contents/Frameworks +# with the exception of libopenrct2.dylib, the Frameworks are identical and are already universal dylibs +rsync -ah --exclude 'libopenrct2.dylib' x64/OpenRCT2.app/Contents/Frameworks/* OpenRCT2-universal.app/Contents/Frameworks +lipo -create x64/OpenRCT2.app/Contents/Frameworks/libopenrct2.dylib arm64/OpenRCT2.app/Contents/Frameworks/libopenrct2.dylib -output OpenRCT2-universal.app/Contents/Frameworks/libopenrct2.dylib + +# handle Info.plist +defaults import $PWD/OpenRCT2-universal.app/Contents/Info $PWD/x64/OpenRCT2.app/Contents/Info.plist $PWD/arm64/OpenRCT2.app/Contents/Info.plist +arm64_min_ver=$(defaults read $PWD/arm64/OpenRCT2.app/Contents/Info LSMinimumSystemVersion) +x64_min_ver=$(defaults read $PWD/x64/OpenRCT2.app/Contents/Info LSMinimumSystemVersion) +defaults write $PWD/OpenRCT2-universal.app/Contents/Info LSMinimumSystemVersionByArchitecture -dict x86_64 ${x64_min_ver} arm64 ${arm64_min_ver}