Skip to content

CI: Build MacOS bundle in CI #475

CI: Build MacOS bundle in CI

CI: Build MacOS bundle in CI #475

Workflow file for this run

name: Build
on:
push:
<<<<<<< HEAD

Check failure on line 5 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build.yml

Invalid workflow file

You have an error in your yaml syntax on line 5
branches: [main]
pull_request:
=======
branches:
- main
- pv/mac
pull_request:
branches:
- main
types:
- ready_for_review
workflow_dispatch:
>>>>>>> 99d395b (CI: Build MacOS bundle in CI)
jobs:
flatpak:
name: "Flatpak"
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-49
options: --privileged
strategy:
# Don't fail the whole workflow if one architecture fails
fail-fast: false
matrix:
variant:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.variant.runner }}
steps:
- uses: actions/checkout@v4
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: reflection.flatpak
manifest-path: cx.modal.reflection.json
cache-key: flatpak-builder-${{ github.sha }}
arch: ${{ matrix.variant.arch }}
run-tests: true
# The above job will build the application as a flatpak and
# publish it as an artifact. To test it locally you can download
# the zip artifact, extract it, install the flatpak and run it.
# unzip reflection-x86_64.zip
# flatpak --user install reflection.flatpak
# flatpak run cx.modal.reflection
macos:
<<<<<<< HEAD
if: false # This disable macos for now.
name: macOS
=======
name: macOS (${{ matrix.arch }})
>>>>>>> 99d395b (CI: Build MacOS bundle in CI)
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
arch: x86_64
- target: aarch64-apple-darwin
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
targets: ${{ matrix.target }}
channel: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Cache Homebrew packages
- uses: actions/cache@v4
with:
path: |
~/Library/Caches/Homebrew
/usr/local/Homebrew
# FIXME: Cache action is not allowed to cache x86_64 Homebrew directory
# /opt/homebrew
key: ${{ runner.os }}-${{ matrix.arch }}-brew-${{ hashFiles('**/Brewfile', '.github/workflows/build.yml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-brew-
- name: Setup x86_64 Homebrew
if: matrix.arch == 'x86_64'
run: |
HOMEBREW_PREFIX="/usr/local"
sudo mkdir -p /usr/local
sudo chown -R $(whoami) /usr/local
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Run macOS Build Script
run: |
if [ "${{ matrix.arch }}" = "x86_64" ]; then
eval "$(/usr/local/bin/brew shellenv)"
echo "Homebrew prefix: $HOMEBREW_PREFIX"
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
chmod +x scripts/build_macos.sh
./scripts/build_macos.sh --release --app-bundle --dmg --arch x86_64
else
chmod +x scripts/build_macos.sh
./scripts/build_macos.sh --release --app-bundle --dmg
fi
env:
PKG_CONFIG_ALLOW_CROSS: "1"
MACOSX_DEPLOYMENT_TARGET: "10.15"
<<<<<<< HEAD
- name: Install glib-compile-resources ARM64
if: matrix.arch == 'arm64'
run: brew install glib || echo ERROR
- name: Compile GResource
run: |
mkdir -p target/${{ matrix.target }}/release/
glib-compile-resources --sourcedir reflection-app/src --target target/${{ matrix.target }}/release/reflection.gresource reflection-app/src/reflection.gresource.xml
- name: Create App Bundle
run: |
mkdir -p Reflection.app/Contents/{MacOS,Resources}/share/reflection
cp target/${{ matrix.target }}/release/reflection Reflection.app/Contents/MacOS/
cp target/${{ matrix.target }}/release/reflection.gresource Reflection.app/Contents/Resources/share/reflection/
# Create Info.plist
cat > Reflection.app/Contents/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>reflection</string>
<key>CFBundleIdentifier</key>
<string>cx.modal.reflection</string>
<key>CFBundleName</key>
<string>Reflection</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
</dict>
</plist>
EOF
# Bundle dependencies
- name: Bundle dependencies
run: |
dylibbundler -od -b -x Reflection.app/Contents/MacOS/reflection \
-d Reflection.app/Contents/Frameworks/ \
-p @executable_path/../Frameworks/
# Create DMG
- name: Create DMG
run: hdiutil create -volname "Reflection" -srcfolder Reflection.app -ov -format UDZO reflection-${{ matrix.arch }}.dmg
=======
>>>>>>> 99d395b (CI: Build MacOS bundle in CI)
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
<<<<<<< HEAD
name: reflection-macos-${{ matrix.arch }}
path: reflection-${{ matrix.arch }}.dmg
=======
# Build script creates artifacts in the current directory
name: aardvark-macos-${{ matrix.arch }}
path: aardvark-${{ matrix.arch }}.dmg
>>>>>>> 99d395b (CI: Build MacOS bundle in CI)
- name: Smoke test the artifact
env:
RUST_BACKTRACE: "full"
RUST_LOG: "debug"
G_MESSAGES_DEBUG: "all"
run: |
./Reflection.app/Contents/MacOS/reflection &
PID=$!
sleep 5
echo Killing reflection
kill $PID || true