-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-dmg.sh
executable file
·63 lines (53 loc) · 1.73 KB
/
build-dmg.sh
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
#!/bin/bash
APP_NAME="WalkingPad Controller"
BUNDLE_ID="dev.timoster.walkingpad-controller"
APP_DIR="dist/$APP_NAME.app"
DMG_NAME="$APP_NAME.dmg"
OUTPUT_DIR="dist"
STAGING_DIR="$OUTPUT_DIR/dmg_staging"
# Ensure output directory exists
mkdir -p "$OUTPUT_DIR"
# Create the .app bundle structure
mkdir -p "$APP_DIR/Contents/MacOS"
mkdir -p "$APP_DIR/Contents/Resources"
echo "APPL????" > "$APP_DIR/Contents/PkgInfo"
# Copy your binary into the app bundle
go build -o "$APP_DIR/Contents/MacOS/$APP_NAME"
# Add an Info.plist file
cat > "$APP_DIR/Contents/Info.plist" <<EOF
<?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>CFBundleExecutable</key>
<string>$APP_NAME</string>
<key>CFBundleIdentifier</key>
<string>$BUNDLE_ID</string>
<key>CFBundleName</key>
<string>$APP_NAME</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSUIElement</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Used to connect to Walking Pads.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Used to connect to Walking Pads.</string>
</dict>
</plist>
EOF
# Prepare the DMG staging directory
mkdir -p "$STAGING_DIR"
cp -R "$APP_DIR" "$STAGING_DIR"
# Create a symbolic link to the Applications folder
ln -s /Applications "$STAGING_DIR/Applications"
# Create the DMG file
hdiutil create -volname "$APP_NAME Installer" \
-srcfolder "$STAGING_DIR" \
-ov -format UDZO "$OUTPUT_DIR/$DMG_NAME"
# Cleanup
rm -rf "$STAGING_DIR"
rm -rf "$APP_DIR"
echo "Installer DMG created at $OUTPUT_DIR/$DMG_NAME"