Repository navigation
392 lines (360 loc) · 17.2 KB
/
Copy pathmacos-dmg.yml
File metadata and controls
392 lines (360 loc) · 17.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
name: macOS DMG
on:
workflow_dispatch:
push:
branches: [master]
tags: ["[0-9]*.[0-9]*.[0-9]*"]
pull_request:
paths:
- ".github/workflows/macos-dmg.yml"
- "meson.build"
- "data/**"
- "src/**"
- "macos/**"
jobs:
build-dmg:
strategy:
matrix:
os: [macos-14]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Show runner info
run: |
uname -a
sw_vers
sysctl -n machdep.cpu.brand_string || true
- name: Setup Homebrew and dependencies
run: |
brew update-reset
brew install meson ninja pkg-config glib gtk4 libadwaita pygobject3 gtksourceview5 python@3.13
brew --version
brew list --versions
- name: Build blueprint-compiler from git (v0.18.0)
run: |
set -euxo pipefail
git clone --depth 1 --branch v0.18.0 https://gitlab.gnome.org/GNOME/blueprint-compiler.git
cd blueprint-compiler
meson setup build --prefix "$PWD/../bp_prefix" --buildtype=release
meson compile -C build
meson install -C build
echo "$GITHUB_WORKSPACE/bp_prefix/bin" >> "$GITHUB_PATH"
- name: Build project (Meson)
run: |
set -euxo pipefail
PY_BIN="$(brew --prefix python@3.13)/bin/python3"
echo "Using Python: ${PY_BIN}"
export PYTHON="${PY_BIN}"
meson setup build --prefix "$PWD/stage" --buildtype=release
meson compile -C build
meson install -C build
- name: Prepare macOS bundle metadata
run: |
mkdir -p macos
BREW_PREFIX="$(brew --prefix)"
export BREW_PREFIX
echo "BREW_PREFIX=${BREW_PREFIX}" >> "$GITHUB_ENV"
echo "Detected Homebrew prefix: $BREW_PREFIX"
- name: Build self-contained .app (vendor Python + GTK)
run: |
set -euxo pipefail
APP="dist/SSH Studio.app"
APPROOT="$APP/Contents"
MACOS="$APPROOT/MacOS"
RES="$APPROOT/Resources"
FRAMEWORKS="$APPROOT/Frameworks"
mkdir -p "$MACOS" "$RES/python" "$FRAMEWORKS"
# 1) Copy your Python sources
rsync -a src/ "$RES/python/ssh_studio/"
# 2) Copy compiled GResource from Meson install
APP_ID="io.github.BuddySirJava.SSH-Studio"
RES_GRES="$RES/ssh-studio-resources.gresource"
SRC_GRES=""
for CAND in \
"stage/share/$APP_ID/ssh-studio-resources.gresource" \
"build/data/ssh-studio-resources.gresource" \
"_build/data/ssh-studio-resources.gresource"; do
if [ -f "$CAND" ]; then
SRC_GRES="$CAND"
break
fi
done
if [ -n "$SRC_GRES" ]; then
install -m 0644 "$SRC_GRES" "$RES_GRES"
else
echo "ERROR: Could not find ssh-studio-resources.gresource in expected locations" >&2
ls -la stage/share "$PWD"/build/data "$PWD"/_build/data || true
exit 1
fi
ls -la "$RES" || true
# 2b) Build macOS .icns app icon from our 512px PNG
ICON_SRC="data/media/icon_512.png"
if [ -f "$ICON_SRC" ]; then
ICONSET_DIR="macos/Icon.iconset"
rm -rf "$ICONSET_DIR"
mkdir -p "$ICONSET_DIR"
for sz in 16 32 64 128 256 512; do
sips -s format png "$ICON_SRC" --resampleWidth $sz --out "$ICONSET_DIR/icon_${sz}x${sz}.png" >/dev/null
done
# @2x variants
for sz in 16 32 128 256; do
db=$(($sz*2))
sips -s format png "$ICON_SRC" --resampleWidth $db --out "$ICONSET_DIR/icon_${sz}x${sz}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET_DIR" -o "$RES/SSHStudio.icns"
else
echo "WARN: Icon source $ICON_SRC not found; bundle will lack .icns" >&2
fi
# 3) Vendor Python.framework
BREW_PREFIX="$(brew --prefix)"
# Dereference symlinks so the framework is self-contained inside the app bundle
rsync -aL "$BREW_PREFIX/Frameworks/Python.framework" "$FRAMEWORKS/"
# Ensure a bin/python3 exists inside the vendored framework (Homebrew's may omit it)
PYFW="$FRAMEWORKS/Python.framework"
if [ -d "$PYFW/Versions/3.13" ]; then
PYHOME_DIR="$PYFW/Versions/3.13"
else
PYHOME_DIR="$PYFW/Versions/Current"
fi
if [ ! -x "$PYHOME_DIR/bin/python3" ]; then
mkdir -p "$PYHOME_DIR/bin"
if [ -x "$PYHOME_DIR/Resources/Python.app/Contents/MacOS/Python" ]; then
ln -sf "../Resources/Python.app/Contents/MacOS/Python" "$PYHOME_DIR/bin/python3"
fi
fi
# 4) Vendor GTK & friends (most-used libs)
for p in glib gtk4 libadwaita gtksourceview5 gdk-pixbuf pango cairo harfbuzz fribidi graphite2 libpng jpeg libtiff libepoxy libffi gettext; do
if [ -d "$BREW_PREFIX/opt/$p/lib" ]; then
mkdir -p "$FRAMEWORKS/$p/lib"
# Copy only runtime libraries; exclude static archives and dev files
rsync -a --prune-empty-dirs \
--include '*/' \
--include '*.dylib' --include '*.dylib.*' \
--include '*.so' --include '*.so.*' \
--exclude '*' \
"$BREW_PREFIX/opt/$p/lib/" "$FRAMEWORKS/$p/lib/"
fi
if [ -d "$BREW_PREFIX/opt/$p/lib/girepository-1.0" ]; then
mkdir -p "$RES/girepository-1.0"
rsync -a "$BREW_PREFIX/opt/$p/lib/girepository-1.0/" "$RES/girepository-1.0/"
fi
if [ -d "$BREW_PREFIX/opt/$p/share" ]; then
mkdir -p "$RES/share/$p"
rsync -a "$BREW_PREFIX/opt/$p/share/" "$RES/share/"
fi
done
# Ensure no static archives slipped in (can break codesign)
find "$FRAMEWORKS" \( -name '*.a' -o -name '*.la' \) -delete || true
# 4b) Vendor PyGObject (gi) and PyCairo into bundled Python path
for SITE in \
"$BREW_PREFIX/lib/python3.13/site-packages" \
"$BREW_PREFIX/opt/pygobject3/lib/python3.13/site-packages" \
"$BREW_PREFIX/opt/py3cairo/lib/python3.13/site-packages"; do
if [ -d "$SITE/gi" ]; then
rsync -a "$SITE/gi" "$RES/python/"
fi
if [ -d "$SITE/cairo" ]; then
rsync -a "$SITE/cairo" "$RES/python/"
fi
done
# 5) Schemas needed by GSettings
mkdir -p "$RES/share/glib-2.0/schemas"
rsync -a "$BREW_PREFIX/opt/glib/share/glib-2.0/schemas/" "$RES/share/glib-2.0/schemas/"
glib-compile-schemas "$RES/share/glib-2.0/schemas"
# 6) Launcher that sets env so app uses bundled runtimes
cat > "$MACOS/ssh-studio" <<'SH'
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
RES="$SCRIPT_DIR/../Resources"
FW="$SCRIPT_DIR/../Frameworks"
export RES
if [ -d "$FW/Python.framework/Versions/3.13" ]; then
export PYTHONHOME="$FW/Python.framework/Versions/3.13"
else
export PYTHONHOME="$FW/Python.framework/Versions/Current"
fi
export PYTHONPATH="$RES/python"
export DYLD_FALLBACK_LIBRARY_PATH="$FW:$FW/glib/lib:$FW/gtk4/lib:$FW/libadwaita/lib:$FW/pango/lib:$FW/cairo/lib:$FW/gtksourceview5/lib"
export GI_TYPELIB_PATH="$RES/girepository-1.0"
export XDG_DATA_DIRS="$RES/share"
export GSETTINGS_SCHEMA_DIR="$RES/share/glib-2.0/schemas"
export GTK_DATA_PREFIX="$RES"
# Register GResource then run app
PYBIN="$PYTHONHOME/bin/python3"
if [ ! -x "$PYBIN" ]; then
# Fallback to framework embedded app binary if bin/python3 is absent
if [ -x "$PYTHONHOME/Resources/Python.app/Contents/MacOS/Python" ]; then
PYBIN="$PYTHONHOME/Resources/Python.app/Contents/MacOS/Python"
fi
fi
"$PYBIN" - <<'PY'
import os, sys
from gi.repository import Gio
res_dir = os.environ.get('RES')
candidates = []
if res_dir:
candidates.append(os.path.join(res_dir, 'ssh-studio-resources.gresource'))
candidates.append(os.path.join(res_dir, 'share', 'io.github.BuddySirJava.SSH-Studio', 'ssh-studio-resources.gresource'))
res_path = next((c for c in candidates if os.path.exists(c)), None)
if not res_path:
raise SystemExit('ssh-studio-resources.gresource not found in expected locations')
Gio.resources_register(Gio.Resource.load(res_path))
if res_dir:
sys.path.insert(0, os.path.join(res_dir, 'python'))
from ssh_studio import main as _main
sys.exit(_main.main())
PY
SH
chmod 0755 "$MACOS/ssh-studio"
# 7) Minimal Info.plist (if you’re not generating it already)
cat > "$APPROOT/Info.plist" <<'PLIST'
<?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>CFBundleIdentifier</key><string>io.github.BuddySirJava.SSH-Studio</string>
<key>CFBundleName</key><string>SSH Studio</string>
<key>CFBundleExecutable</key><string>ssh-studio</string>
<key>CFBundleIconFile</key><string>SSHStudio</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
</dict></plist>
PLIST
- name: List .app contents
run: |
set -euxo pipefail
echo 'self-contained app:' || true
ls -R 'dist/SSH Studio.app/Contents' || true
- name: Ad-hoc codesign app bundle
run: |
set -euxo pipefail
APP="dist/SSH Studio.app"
# Ensure files are writable and clear any quarantine attrs
chmod -R u+rw "$APP"
xattr -cr "$APP" || true
# Sign only Mach-O binaries and libraries to avoid codesign errors on non-bundles
find "$APP/Contents" -type f \
-exec sh -c 'file -b "$1" | grep -q "Mach-O" && codesign --force --sign - --timestamp=none "$1" || true' _ {} \;
# Finally sign the app wrapper (no --deep)
codesign --force --sign - --timestamp=none "$APP"
codesign --verify --verbose=2 "$APP" || (codesign --display --verbose=5 "$APP"; exit 1)
- name: Verify permissions and Info.plist
run: |
set -euxo pipefail
APP="dist/SSH Studio.app"
chmod +x "$APP/Contents/MacOS/ssh-studio"
plutil -lint "$APP/Contents/Info.plist"
# Show signature and linkage (non-fatal)
codesign -dv --verbose=4 "$APP" || true
otool -L "$APP/Contents/MacOS/ssh-studio" || true
- name: Gatekeeper assessment (non-fatal)
run: |
set -euxo pipefail
APP="dist/SSH Studio.app"
spctl --assess --type execute -v "$APP" || true
- name: Developer ID sign app (optional)
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_DEVELOPER_CERT_BASE64: ${{ secrets.APPLE_DEVELOPER_CERT_BASE64 }}
APPLE_DEVELOPER_CERT_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERT_PASSWORD }}
run: |
set -euxo pipefail
APP="dist/SSH Studio.app"
if [ -z "${APPLE_SIGNING_IDENTITY:-}" ] || [ -z "${APPLE_DEVELOPER_CERT_BASE64:-}" ] || [ -z "${APPLE_DEVELOPER_CERT_PASSWORD:-}" ]; then
echo "Signing secrets not provided; skipping Developer ID signing."; exit 0; fi
KEYCHAIN_PATH="$RUNNER_TEMP/build.keychain-db"
KEYCHAIN_PWD="$(openssl rand -hex 12)"
security create-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN_PATH"
echo "$APPLE_DEVELOPER_CERT_BASE64" | base64 --decode > "$RUNNER_TEMP/dev_cert.p12"
security import "$RUNNER_TEMP/dev_cert.p12" -k "$KEYCHAIN_PATH" -P "$APPLE_DEVELOPER_CERT_PASSWORD" -A
security list-keychain -d user -s "$KEYCHAIN_PATH" login.keychain-db
# Re-sign Mach-O components, then the app wrapper (no --deep)
find "$APP/Contents" -type f \
-exec sh -c 'file -b "$1" | grep -q "Mach-O" && codesign --force --options runtime --timestamp --sign "$APPLE_SIGNING_IDENTITY" "$1" || true' _ {} \;
codesign --force --options runtime --timestamp --sign "$APPLE_SIGNING_IDENTITY" "$APP"
codesign --verify --strict --verbose=2 "$APP"
- name: Create DMG
run: |
set -euxo pipefail
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
ARCH=$(uname -m)
mkdir -p dmgroot
# Prefer self-contained app for distribution
cp -R "dist/SSH Studio.app" "dmgroot/SSH Studio.app"
ln -s /Applications dmgroot/Applications
hdiutil create -volname "SSH Studio" -srcfolder dmgroot -ov -fs HFS+ "ssh-studio-${VER}-${ARCH}.dmg"
- name: Developer ID sign DMG (optional)
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_DEVELOPER_CERT_BASE64: ${{ secrets.APPLE_DEVELOPER_CERT_BASE64 }}
APPLE_DEVELOPER_CERT_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERT_PASSWORD }}
run: |
set -euxo pipefail
if [ -z "${APPLE_SIGNING_IDENTITY:-}" ] || [ -z "${APPLE_DEVELOPER_CERT_BASE64:-}" ] || [ -z "${APPLE_DEVELOPER_CERT_PASSWORD:-}" ]; then
echo "Signing secrets not provided; skipping DMG signing."; exit 0; fi
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
ARCH=$(uname -m)
DMG="ssh-studio-${VER}-${ARCH}.dmg"
KEYCHAIN_PATH="$RUNNER_TEMP/build.keychain-db"
if [ ! -f "$RUNNER_TEMP/dev_cert.p12" ]; then
echo "$APPLE_DEVELOPER_CERT_BASE64" | base64 --decode > "$RUNNER_TEMP/dev_cert.p12"
fi
if [ ! -f "$KEYCHAIN_PATH" ]; then
KEYCHAIN_PWD="$(openssl rand -hex 12)"
security create-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN_PATH"
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PWD" "$KEYCHAIN_PATH"
security import "$RUNNER_TEMP/dev_cert.p12" -k "$KEYCHAIN_PATH" -P "$APPLE_DEVELOPER_CERT_PASSWORD" -A
security list-keychain -d user -s "$KEYCHAIN_PATH" login.keychain-db
fi
codesign --force --timestamp --sign "$APPLE_SIGNING_IDENTITY" "$DMG"
spctl --assess --type open -v "$DMG" || true
- name: Notarize DMG with notarytool (API key) (optional)
env:
NOTARYTOOL_KEY_ID: ${{ secrets.NOTARYTOOL_KEY_ID }}
NOTARYTOOL_ISSUER_ID: ${{ secrets.NOTARYTOOL_ISSUER_ID }}
NOTARYTOOL_PRIVATE_KEY: ${{ secrets.NOTARYTOOL_PRIVATE_KEY }}
run: |
set -euxo pipefail
if [ -z "${NOTARYTOOL_KEY_ID:-}" ] || [ -z "${NOTARYTOOL_ISSUER_ID:-}" ] || [ -z "${NOTARYTOOL_PRIVATE_KEY:-}" ]; then
echo "Notary API key secrets not provided; skipping API-key notarization."; exit 0; fi
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
ARCH=$(uname -m)
DMG="ssh-studio-${VER}-${ARCH}.dmg"
KEYFILE="$RUNNER_TEMP/AuthKey.p8"
echo "$NOTARYTOOL_PRIVATE_KEY" > "$KEYFILE"
xcrun notarytool submit "$DMG" \
--key "$KEYFILE" \
--key-id "$NOTARYTOOL_KEY_ID" \
--issuer "$NOTARYTOOL_ISSUER_ID" \
--wait
xcrun stapler staple "$DMG"
- name: Notarize DMG with notarytool (Apple ID) (optional)
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: |
set -euxo pipefail
# Only run if API key secrets are missing but Apple ID-based secrets are present
if [ -n "${NOTARYTOOL_KEY_ID:-}" ] && [ -n "${NOTARYTOOL_ISSUER_ID:-}" ] && [ -n "${NOTARYTOOL_PRIVATE_KEY:-}" ]; then
echo "API key provided; skipping Apple ID notarization path."; exit 0; fi
if [ -z "${APPLE_ID:-}" ] || [ -z "${APPLE_TEAM_ID:-}" ] || [ -z "${APPLE_APP_SPECIFIC_PASSWORD:-}" ]; then
echo "Apple ID notarization secrets not provided; skipping."; exit 0; fi
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
ARCH=$(uname -m)
DMG="ssh-studio-${VER}-${ARCH}.dmg"
xcrun notarytool submit "$DMG" \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_SPECIFIC_PASSWORD" \
--wait
xcrun stapler staple "$DMG"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ssh-studio-dmg-${{ matrix.os }}
path: |
*.dmg