Last active
April 11, 2025 12:45
-
-
Save kopiro/7b77b2a6d3dfc2c5359ff0f25667747b to your computer and use it in GitHub Desktop.
Create MY DMG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# brew install create-dmg | |
# xcrun notarytool store-credentials "AC_PASSWORD" --apple-id $EMAIL --team-id $TEAM_ID | |
set -exu | |
APP_BUNDLE="$1" | |
if [[ ! -d "$APP_BUNDLE" ]]; then | |
echo "Usage: $0 <app-bundle-path>" | |
exit 1 | |
fi | |
# Extract version and name from the app bundle | |
INFO_PLIST="$APP_BUNDLE/Contents/Info.plist" | |
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFO_PLIST") | |
if [[ -z "$VERSION" ]]; then | |
echo "Error: Could not determine version from Info.plist" | |
exit 1 | |
fi | |
APPNAME=$(/usr/libexec/PlistBuddy -c "Print CFBundleName" "$INFO_PLIST") | |
if [[ -z "$APPNAME" ]]; then | |
echo "Error: Could not determine name from Info.plist" | |
exit 1 | |
fi | |
IDENTITY=$(security find-identity -v -p codesigning | grep "Distribution" | head -n 1 | awk '{print $2}') | |
if [[ -z "$IDENTITY" ]]; then | |
echo "Error: Could not determine signing identity" | |
exit 1 | |
fi | |
DMG_NAME="$APPNAME-$VERSION.dmg" | |
DMG_PATH="./$DMG_NAME" | |
echo "Creating DMG for $APPNAME $VERSION -> $DMG_PATH" | |
[[ -f "${DMG_PATH}" ]] && rm "${DMG_PATH}" | |
# Create DMG (using create-dmg) | |
create-dmg \ | |
--codesign "$IDENTITY" \ | |
--notarize AC_PASSWORD \ | |
--volname "$APPNAME $VERSION" \ | |
--volicon "$APP_BUNDLE/Contents/Resources/AppIcon.icns" \ | |
--window-pos 200 120 \ | |
--window-size 800 400 \ | |
--icon-size 100 \ | |
--icon "${APPNAME}.app" 200 190 \ | |
--hide-extension "${APPNAME}.app" \ | |
--app-drop-link 600 185 \ | |
"$DMG_PATH" \ | |
"$APP_BUNDLE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment