Skip to content

Commit 3e246a4

Browse files
committed
Add self-contained .app build step to macOS DMG workflow, including Python and GTK vendorization, resource registration, and minimal Info.plist generation.
1 parent f6af7ec commit 3e246a4

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/macos-dmg.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,88 @@ jobs:
129129
export BREW_PREFIX
130130
gtk-mac-bundler macos/ssh-studio.bundle
131131
132+
- name: Build self-contained .app (vendor Python + GTK)
133+
run: |
134+
set -euxo pipefail
135+
APP="dist/SSH Studio.app"
136+
APPROOT="$APP/Contents"
137+
MACOS="$APPROOT/MacOS"
138+
RES="$APPROOT/Resources"
139+
FRAMEWORKS="$APPROOT/Frameworks"
140+
mkdir -p "$MACOS" "$RES/python" "$FRAMEWORKS"
141+
142+
# 1) Copy your Python sources
143+
rsync -a src/ "$RES/python/ssh_studio/"
144+
# 2) Copy compiled GResource from Meson install
145+
APP_ID="io.github.BuddySirJava.SSH-Studio"
146+
install -m 0644 "stage/share/$APP_ID/ssh-studio-resources.gresource" "$RES/"
147+
148+
# 3) Vendor Python.framework
149+
BREW_PREFIX="$(brew --prefix)"
150+
rsync -a "$BREW_PREFIX/Frameworks/Python.framework" "$FRAMEWORKS/"
151+
152+
# 4) Vendor GTK & friends (most-used libs)
153+
for p in glib gtk4 libadwaita gtksourceview5 gdk-pixbuf pango cairo harfbuzz fribidi graphite2 libpng jpeg libtiff libepoxy libffi gettext; do
154+
if [ -d "$BREW_PREFIX/opt/$p/lib" ]; then
155+
mkdir -p "$FRAMEWORKS/$p/lib"
156+
rsync -a "$BREW_PREFIX/opt/$p/lib/" "$FRAMEWORKS/$p/lib/"
157+
fi
158+
if [ -d "$BREW_PREFIX/opt/$p/lib/girepository-1.0" ]; then
159+
mkdir -p "$RES/girepository-1.0"
160+
rsync -a "$BREW_PREFIX/opt/$p/lib/girepository-1.0/" "$RES/girepository-1.0/"
161+
fi
162+
if [ -d "$BREW_PREFIX/opt/$p/share" ]; then
163+
mkdir -p "$RES/share/$p"
164+
rsync -a "$BREW_PREFIX/opt/$p/share/" "$RES/share/"
165+
fi
166+
done
167+
168+
# 5) Schemas needed by GSettings
169+
mkdir -p "$RES/share/glib-2.0/schemas"
170+
rsync -a "$BREW_PREFIX/opt/glib/share/glib-2.0/schemas/" "$RES/share/glib-2.0/schemas/"
171+
glib-compile-schemas "$RES/share/glib-2.0/schemas"
172+
173+
# 6) Launcher that sets env so app uses bundled runtimes
174+
cat > "$MACOS/ssh-studio" <<'SH'
175+
#!/bin/bash
176+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
177+
RES="$SCRIPT_DIR/../Resources"
178+
FW="$SCRIPT_DIR/../Frameworks"
179+
180+
export PYTHONHOME="$FW/Python.framework/Versions/3.13"
181+
export PYTHONPATH="$RES/python"
182+
export DYLD_FALLBACK_LIBRARY_PATH="$FW:$FW/glib/lib:$FW/gtk4/lib:$FW/libadwaita/lib:$FW/pango/lib:$FW/cairo/lib:$FW/gtksourceview5/lib"
183+
export GI_TYPELIB_PATH="$RES/girepository-1.0"
184+
export XDG_DATA_DIRS="$RES/share"
185+
export GSETTINGS_SCHEMA_DIR="$RES/share/glib-2.0/schemas"
186+
export GTK_DATA_PREFIX="$RES"
187+
188+
# Register GResource then run app
189+
"$PYTHONHOME/bin/python3" - <<'PY'
190+
import os, sys
191+
from gi.repository import Gio
192+
res_path = os.path.join(os.path.dirname(__file__), '..', 'Resources', 'ssh-studio-resources.gresource')
193+
Gio.resources_register(Gio.Resource.load(res_path))
194+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'Resources', 'python'))
195+
from ssh_studio import main as _main
196+
sys.exit(_main.main())
197+
PY
198+
SH
199+
chmod 0755 "$MACOS/ssh-studio"
200+
201+
# 7) Minimal Info.plist (if you’re not generating it already)
202+
cat > "$APPROOT/Info.plist" <<'PLIST'
203+
<?xml version="1.0" encoding="UTF-8"?>
204+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
205+
<plist version="1.0"><dict>
206+
<key>CFBundleIdentifier</key><string>io.github.BuddySirJava.SSH-Studio</string>
207+
<key>CFBundleName</key><string>SSH Studio</string>
208+
<key>CFBundleExecutable</key><string>ssh-studio</string>
209+
<key>CFBundlePackageType</key><string>APPL</string>
210+
<key>LSMinimumSystemVersion</key><string>11.0</string>
211+
</dict></plist>
212+
PLIST
213+
132214
- name: List .app contents
133215
run: |
134216
set -euxo pipefail

0 commit comments

Comments
 (0)