Skip to content

Commit 768f6a0

Browse files
cafcajsparber
authored andcommitted
CI: Build MacOS bundle in CI
1 parent e9ef11d commit 768f6a0

13 files changed

Lines changed: 1076 additions & 277 deletions

File tree

.github/workflows/build.yml

Lines changed: 27 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ jobs:
3838
# flatpak --user install reflection.flatpak
3939
# flatpak run cx.modal.reflection
4040

41-
macos:
42-
if: false # This disable macos for now.
43-
name: macOS
41+
macos:
42+
name: macOS (${{ matrix.arch }})
4443
runs-on: macos-latest
4544
strategy:
4645
fail-fast: false
@@ -53,6 +52,9 @@ jobs:
5352
steps:
5453
- uses: actions/checkout@v4
5554
- uses: moonrepo/setup-rust@v1
55+
with:
56+
targets: ${{ matrix.target }}
57+
channel: nightly
5658
env:
5759
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5860

@@ -62,8 +64,9 @@ jobs:
6264
path: |
6365
~/Library/Caches/Homebrew
6466
/usr/local/Homebrew
65-
/opt/homebrew
66-
key: ${{ runner.os }}-${{ matrix.arch }}-brew-${{ hashFiles('.github/workflows/build.yml') }}
67+
# FIXME: Cache action is not allowed to cache x86_64 Homebrew directory
68+
# /opt/homebrew
69+
key: ${{ runner.os }}-${{ matrix.arch }}-brew-${{ hashFiles('**/Brewfile', '.github/workflows/build.yml') }}
6770
restore-keys: |
6871
${{ runner.os }}-${{ matrix.arch }}-brew-
6972
@@ -74,158 +77,38 @@ jobs:
7477
sudo mkdir -p /usr/local
7578
sudo chown -R $(whoami) /usr/local
7679
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
77-
eval "$(/usr/local/bin/brew shellenv)"
78-
echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/opt/pango/lib/pkgconfig:/usr/local/opt/cairo/lib/pkgconfig:/usr/local/opt/gdk-pixbuf/lib/pkgconfig:/usr/local/opt/graphene/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/gtk4/lib/pkgconfig:/usr/local/opt/libadwaita/lib/pkgconfig" >> $GITHUB_ENV
79-
80-
- name: Install pkg-config (x86_64)
81-
if: matrix.arch == 'x86_64'
82-
run: arch -x86_64 /usr/local/bin/brew install pkg-config || echo ERROR
83-
84-
- name: Install GDK-Pixbuf (x86_64)
85-
if: matrix.arch == 'x86_64'
86-
run: arch -x86_64 /usr/local/bin/brew install gdk-pixbuf || echo ERROR
87-
88-
- name: Install Cairo (x86_64)
89-
if: matrix.arch == 'x86_64'
90-
run: arch -x86_64 /usr/local/bin/brew install cairo || echo ERROR
91-
92-
- name: Install Pango (x86_64)
93-
if: matrix.arch == 'x86_64'
94-
run: arch -x86_64 /usr/local/bin/brew install pango || echo ERROR
95-
96-
- name: Install AT-SPI2-Core (x86_64)
97-
if: matrix.arch == 'x86_64'
98-
run: arch -x86_64 /usr/local/bin/brew install at-spi2-core || echo ERROR
99-
100-
- name: Install Graphene (x86_64)
101-
if: matrix.arch == 'x86_64'
102-
run: arch -x86_64 /usr/local/bin/brew install graphene || echo ERROR
103-
104-
- name: Install GTK4 (x86_64)
105-
if: matrix.arch == 'x86_64'
106-
run: arch -x86_64 /usr/local/bin/brew install gtk4 || echo ERROR
107-
108-
- name: Install GtkSourceView5 (x86_64)
109-
if: matrix.arch == 'x86_64'
110-
run: arch -x86_64 /usr/local/bin/brew install gtksourceview5 || echo ERROR
111-
112-
- name: Install Libadwaita (x86_64)
113-
if: matrix.arch == 'x86_64'
114-
run: arch -x86_64 /usr/local/bin/brew install -v libadwaita
11580
116-
- name: Install dylibbundler (x86_64)
117-
if: matrix.arch == 'x86_64'
118-
run: arch -x86_64 /usr/local/bin/brew install -v dylibbundler
119-
120-
- name: Install dylibbundler ARM64
121-
if: matrix.arch == 'arm64'
122-
run: brew install -v dylibbundler
123-
124-
- name: Verify and link x86_64 packages
125-
if: matrix.arch == 'x86_64'
126-
run: |
127-
# Verify installations
128-
arch -x86_64 /usr/local/bin/brew list pango
129-
arch -x86_64 /usr/local/bin/brew list cairo
130-
arch -x86_64 /usr/local/bin/brew list gdk-pixbuf
131-
arch -x86_64 /usr/local/bin/brew list gtk4
132-
arch -x86_64 /usr/local/bin/brew list gtksourceview5
133-
arch -x86_64 /usr/local/bin/brew list libadwaita
134-
135-
# Link packages individually with error handling
136-
for package in pango cairo gdk-pixbuf gtk4 gtksourceview5 libadwaita; do
137-
arch -x86_64 /usr/local/bin/brew link --force $package || true
138-
done
139-
140-
- name: Install ARM64 dependencies
141-
if: matrix.arch == 'arm64'
142-
run: |
143-
brew install pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita gtksourceview5 || true
144-
brew upgrade pkg-config gtk4 pango cairo gdk-pixbuf at-spi2-core graphene libadwaita gtksourceview5 || true
145-
146-
- name: Finalize ARM64 setup
147-
if: matrix.arch == 'arm64'
81+
- name: Run macOS Build Script
14882
run: |
149-
echo "PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig" >> $GITHUB_ENV
150-
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
151-
- name: Add target ${{ matrix.target }}
152-
run: rustup target add ${{ matrix.target }}
153-
- name: Build
83+
if [ "${{ matrix.arch }}" = "x86_64" ]; then
84+
eval "$(/usr/local/bin/brew shellenv)"
85+
echo "Homebrew prefix: $HOMEBREW_PREFIX"
86+
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
87+
chmod +x scripts/build_macos.sh
88+
./scripts/build_macos.sh --release --app-bundle --dmg --arch x86_64
89+
else
90+
chmod +x scripts/build_macos.sh
91+
./scripts/build_macos.sh --release --app-bundle --dmg
92+
fi
15493
env:
15594
PKG_CONFIG_ALLOW_CROSS: "1"
156-
CFLAGS: "-I/usr/local/include -I/usr/local/include/gtk-4.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include"
157-
LDFLAGS: "-L/usr/local/lib -framework Cocoa -framework Security"
15895
MACOSX_DEPLOYMENT_TARGET: "10.15"
159-
PKG_CONFIG_SYSROOT_DIR: ""
160-
PKG_CONFIG_PATH: "${{ env.PKG_CONFIG_PATH }}"
161-
run: cargo build --release --target ${{ matrix.target }}
162-
- name: Install glib-compile-resources
163-
if: matrix.arch == 'x86_64'
164-
run: arch -x86_64 /usr/local/bin/brew install glib || echo ERROR
165-
166-
- name: Install glib-compile-resources ARM64
167-
if: matrix.arch == 'arm64'
168-
run: brew install glib || echo ERROR
16996

170-
- name: Compile GResource
171-
run: |
172-
mkdir -p target/${{ matrix.target }}/release/
173-
glib-compile-resources --sourcedir reflection-app/src --target target/${{ matrix.target }}/release/reflection.gresource reflection-app/src/reflection.gresource.xml
174-
175-
- name: Create App Bundle
176-
run: |
177-
mkdir -p Reflection.app/Contents/{MacOS,Resources}/share/reflection
178-
cp target/${{ matrix.target }}/release/reflection Reflection.app/Contents/MacOS/
179-
cp target/${{ matrix.target }}/release/reflection.gresource Reflection.app/Contents/Resources/share/reflection/
180-
181-
# Create Info.plist
182-
cat > Reflection.app/Contents/Info.plist << EOF
183-
<?xml version="1.0" encoding="UTF-8"?>
184-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
185-
<plist version="1.0">
186-
<dict>
187-
<key>CFBundleExecutable</key>
188-
<string>reflection</string>
189-
<key>CFBundleIdentifier</key>
190-
<string>cx.modal.reflection</string>
191-
<key>CFBundleName</key>
192-
<string>Reflection</string>
193-
<key>CFBundlePackageType</key>
194-
<string>APPL</string>
195-
<key>CFBundleShortVersionString</key>
196-
<string>0.1.0</string>
197-
<key>LSMinimumSystemVersion</key>
198-
<string>10.15</string>
199-
<key>CFBundleSupportedPlatforms</key>
200-
<array>
201-
<string>MacOSX</string>
202-
</array>
203-
</dict>
204-
</plist>
205-
EOF
206-
207-
# Bundle dependencies
208-
- name: Bundle dependencies
209-
run: |
210-
dylibbundler -od -b -x Reflection.app/Contents/MacOS/reflection \
211-
-d Reflection.app/Contents/Frameworks/ \
212-
-p @executable_path/../Frameworks/
213-
# Create DMG
214-
- name: Create DMG
215-
run: hdiutil create -volname "Reflection" -srcfolder Reflection.app -ov -format UDZO reflection-${{ matrix.arch }}.dmg
21697
- name: Upload Artifact
217-
uses: actions/upload-artifact@v3
98+
uses: actions/upload-artifact@v4
21899
with:
219-
name: reflection-macos-${{ matrix.arch }}
220-
path: reflection-${{ matrix.arch }}.dmg
100+
# Build script creates artifacts in the current directory
101+
name: aardvark-macos-${{ matrix.arch }}
102+
path: aardvark-${{ matrix.arch }}.dmg
103+
221104
- name: Smoke test the artifact
222105
env:
223106
RUST_BACKTRACE: "full"
224107
RUST_LOG: "debug"
225108
G_MESSAGES_DEBUG: "all"
226109
run: |
227-
./Reflection.app/Contents/MacOS/reflection &
110+
./Aardvark.app/Contents/MacOS/aardvark &
228111
PID=$!
229112
sleep 5
230-
echo Killing reflection
231-
kill $PID || true
113+
echo Killing aardvark
114+
kill $PID || true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ target
33
reflection-app/src/config.rs
44

55
/subprojects/blueprint-compiler
6+
7+
# Build artifacts
8+
Reflection.app/
9+
install/
10+
reflection*.dmg

Brewfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build tools
2+
brew "meson"
3+
brew "ninja"
4+
brew "pkg-config"
5+
6+
# Rust toolchain (if not already installed)
7+
brew "rustup-init"
8+
9+
# Core GTK4 and GNOME dependencies
10+
brew "gtk4"
11+
brew "libadwaita"
12+
brew "gtksourceview5"
13+
brew "glib"
14+
15+
# Graphics and text rendering
16+
brew "cairo"
17+
brew "pango"
18+
brew "gdk-pixbuf"
19+
brew "graphene"
20+
21+
# Accessibility
22+
brew "at-spi2-core"
23+
24+
# Desktop file utilities (for update-desktop-database)
25+
brew "desktop-file-utils"
26+
27+
# App bundling for macOS
28+
brew "dylibbundler"
29+
30+
# Optional: For creating DMG files
31+
brew "create-dmg"

0 commit comments

Comments
 (0)