Skip to content

Commit f25038e

Browse files
committed
Fix DMG creation when ImageMagick is not available
- Check if background.png exists before trying to set it in AppleScript - Provide separate AppleScript for with/without custom background - Use default macOS background when ImageMagick is not installed - Prevents AppleScript error -10006 in CI environments The DMG will now work perfectly with or without ImageMagick: - With ImageMagick: custom background with arrow and instructions - Without ImageMagick: clean default macOS appearance Fixes CI build failure where ImageMagick is not installed.
1 parent cd23a75 commit f25038e

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

create-dmg.sh

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,16 @@ hdiutil attach "$TEMP_DMG" -readwrite -noverify -noautoopen
141141
# Wait for mount
142142
sleep 2
143143

144+
# Check if background image exists
145+
BACKGROUND_EXISTS=false
146+
if [ -f "$STAGING_DIR/.background/background.png" ]; then
147+
BACKGROUND_EXISTS=true
148+
fi
149+
144150
# Run AppleScript to set window properties
145-
osascript <<EOF
151+
if [ "$BACKGROUND_EXISTS" = true ]; then
152+
echo " Setting custom background..."
153+
osascript <<EOF
146154
tell application "Finder"
147155
tell disk "$VOLUME_NAME"
148156
open
@@ -171,6 +179,37 @@ tell application "Finder"
171179
end tell
172180
end tell
173181
EOF
182+
else
183+
echo " Using default background (no ImageMagick)..."
184+
osascript <<EOF
185+
tell application "Finder"
186+
tell disk "$VOLUME_NAME"
187+
open
188+
set current view of container window to icon view
189+
set toolbar visible of container window to false
190+
set statusbar visible of container window to false
191+
set the bounds of container window to {100, 100, 700, 500}
192+
set viewOptions to the icon view options of container window
193+
set arrangement of viewOptions to not arranged
194+
set icon size of viewOptions to 72
195+
set shows item info of viewOptions to false
196+
set shows icon preview of viewOptions to true
197+
198+
-- Position icons (wait for them to appear)
199+
delay 1
200+
set position of item "$APP_NAME.app" of container window to {150, 200}
201+
set position of item "Applications" of container window to {450, 200}
202+
203+
-- Force update
204+
close
205+
open
206+
update without registering applications
207+
delay 2
208+
close
209+
end tell
210+
end tell
211+
EOF
212+
fi
174213

175214
# Ensure .DS_Store is written
176215
echo "💾 Saving Finder settings..."

0 commit comments

Comments
 (0)