Skip to content

Commit 7abbd27

Browse files
authored
Update macos-dmg.yml
1 parent 884b0ef commit 7abbd27

File tree

1 file changed

+35
-85
lines changed

1 file changed

+35
-85
lines changed

.github/workflows/macos-dmg.yml

Lines changed: 35 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'meson.build'
1212
- 'data/**'
1313
- 'src/**'
14+
- 'macos/**'
1415

1516
jobs:
1617
build-dmg:
@@ -32,7 +33,7 @@ jobs:
3233
- name: Setup Homebrew and dependencies
3334
run: |
3435
brew update-reset
35-
brew install meson ninja pkg-config glib gtk4 libadwaita pygobject3 gtksourceview5 [email protected]
36+
brew install meson ninja pkg-config glib gtk4 libadwaita pygobject3 gtksourceview5 [email protected] gtk-mac-bundler
3637
brew --version
3738
brew list --versions
3839
@@ -56,95 +57,46 @@ jobs:
5657
meson compile -C build
5758
meson install -C build
5859
59-
- name: Prepare .app bundle
60+
- name: Bundle app with gtk-mac-bundler
6061
run: |
61-
set -euxo pipefail
62-
APP_NAME="SSH Studio"
63-
APP_ID="io.github.BuddySirJava.SSH-Studio"
64-
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
65-
ARCH=$(uname -m)
66-
APP_ROOT="$PWD/dist/${APP_NAME}.app/Contents"
67-
mkdir -p "$APP_ROOT/MacOS" "$APP_ROOT/Resources/python"
68-
69-
# Copy Python sources into bundle
70-
mkdir -p "$APP_ROOT/Resources/python/ssh_studio/ui"
71-
cp -R src/__init__.py "$APP_ROOT/Resources/python/ssh_studio/__init__.py"
72-
cp -R src/main.py "$APP_ROOT/Resources/python/ssh_studio/main.py"
73-
cp -R src/ssh_config_parser.py "$APP_ROOT/Resources/python/ssh_studio/ssh_config_parser.py"
74-
cp -R src/ui/__init__.py "$APP_ROOT/Resources/python/ssh_studio/ui/__init__.py"
75-
cp -R src/ui/*.py "$APP_ROOT/Resources/python/ssh_studio/ui/"
76-
77-
# Copy compiled resources into bundle
78-
cp -R "stage/share/${APP_ID}/ssh-studio-resources.gresource" "$APP_ROOT/Resources/ssh-studio-resources.gresource"
79-
80-
# Generate .icns from existing PNGs
81-
ICON_SRC="data/media/icon_512.png"
82-
ICONSET_DIR="$APP_ROOT/Resources/AppIcon.iconset"
83-
mkdir -p "$ICONSET_DIR"
84-
sips -z 16 16 "$ICON_SRC" --out "$ICONSET_DIR/icon_16x16.png"
85-
sips -z 32 32 "$ICON_SRC" --out "$ICONSET_DIR/[email protected]"
86-
sips -z 32 32 "$ICON_SRC" --out "$ICONSET_DIR/icon_32x32.png"
87-
sips -z 64 64 "$ICON_SRC" --out "$ICONSET_DIR/[email protected]"
88-
sips -z 128 128 "$ICON_SRC" --out "$ICONSET_DIR/icon_128x128.png"
89-
sips -z 256 256 "$ICON_SRC" --out "$ICONSET_DIR/[email protected]"
90-
sips -z 256 256 "$ICON_SRC" --out "$ICONSET_DIR/icon_256x256.png"
91-
sips -z 512 512 "$ICON_SRC" --out "$ICONSET_DIR/[email protected]"
92-
cp "$ICON_SRC" "$ICONSET_DIR/icon_512x512.png"
93-
sips -z 1024 1024 "$ICON_SRC" --out "$ICONSET_DIR/[email protected]"
94-
iconutil -c icns "$ICONSET_DIR" -o "$APP_ROOT/Resources/AppIcon.icns"
95-
rm -rf "$ICONSET_DIR"
96-
97-
# Create launcher (Python) that registers resources then runs main
98-
cat > "$APP_ROOT/Resources/ssh-studio-launch.py" << 'PY'
99-
#!/usr/bin/env python3
100-
import os, sys
101-
from gi.repository import Gio
102-
resource_path = os.path.join(os.path.dirname(__file__), 'ssh-studio-resources.gresource')
103-
Gio.resources_register(Gio.Resource.load(resource_path))
104-
from ssh_studio import main as _main
105-
sys.exit(_main.main())
106-
PY
107-
chmod 0755 "$APP_ROOT/Resources/ssh-studio-launch.py"
108-
109-
# Info.plist
110-
cat > "$APP_ROOT/Info.plist" << PLIST
111-
<?xml version="1.0" encoding="UTF-8"?>
112-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
113-
<plist version="1.0">
114-
<dict>
115-
<key>CFBundleName</key><string>${APP_NAME}</string>
116-
<key>CFBundleIdentifier</key><string>${APP_ID}</string>
117-
<key>CFBundleVersion</key><string>${VER}</string>
118-
<key>CFBundleShortVersionString</key><string>${VER}</string>
119-
<key>CFBundleExecutable</key><string>ssh-studio</string>
120-
<key>CFBundlePackageType</key><string>APPL</string>
121-
<key>CFBundleIconFile</key><string>AppIcon</string>
122-
<key>LSMinimumSystemVersion</key><string>11.0</string>
123-
<key>LSApplicationCategoryType</key><string>public.app-category.developer-tools</string>
124-
</dict>
125-
</plist>
126-
PLIST
127-
128-
# App executable that wires Python and PYTHONPATH
129-
PY_BIN="$(brew --prefix [email protected])/bin/python3"
130-
cat > "$APP_ROOT/MacOS/ssh-studio" << 'SH'
131-
#!/bin/bash
132-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
133-
RES_DIR="${SCRIPT_DIR}/../Resources"
134-
export PYTHONPATH="${RES_DIR}/python"
135-
# Use Homebrew Python 3.13 explicitly
136-
PY_BIN="$(brew --prefix [email protected])/bin/python3"
137-
exec "${PY_BIN}" "${RES_DIR}/ssh-studio-launch.py" "$@"
138-
SH
139-
chmod 0755 "$APP_ROOT/MacOS/ssh-studio"
62+
mkdir -p macos
63+
# Create bundler recipe if not in repo
64+
cat > macos/ssh-studio.bundle << 'XML'
65+
<?xml version="1.0"?>
66+
<app-bundle>
67+
<id>io.github.BuddySirJava.SSH-Studio</id>
68+
<name>SSH Studio</name>
69+
<version>1.0.0</version>
70+
<icon>data/media/icon_512.png</icon>
71+
72+
<main-binary>
73+
<binary>ssh-studio</binary>
74+
</main-binary>
75+
76+
<resources>
77+
<file>stage/share/io.github.BuddySirJava.SSH-Studio/ssh-studio-resources.gresource</file>
78+
<dir>src</dir>
79+
</resources>
80+
81+
<dependencies>
82+
<dep>gtk4</dep>
83+
<dep>libadwaita</dep>
84+
<dep>gtksourceview5</dep>
85+
<dep>pygobject3</dep>
86+
<dep>python3</dep>
87+
</dependencies>
88+
</app-bundle>
89+
XML
90+
91+
gtk-mac-bundler macos/ssh-studio.bundle
14092
14193
- name: Create DMG
14294
run: |
14395
set -euxo pipefail
14496
VER=$(sed -n "s/.*version: '\([^']*\)'.*/\1/p" meson.build | head -n1)
14597
ARCH=$(uname -m)
14698
mkdir -p dmgroot
147-
cp -R "dist/SSH Studio.app" dmgroot/
99+
cp -R "build/ssh-studio.bundle/SSH Studio.app" dmgroot/
148100
ln -s /Applications dmgroot/Applications
149101
hdiutil create -volname "SSH Studio" -srcfolder dmgroot -ov -fs HFS+ "ssh-studio-${VER}-${ARCH}.dmg"
150102
@@ -153,6 +105,4 @@ jobs:
153105
with:
154106
name: ssh-studio-dmg-${{ matrix.os }}
155107
path: |
156-
*.dmg
157-
158-
108+
*.dmg

0 commit comments

Comments
 (0)