This commit is contained in:
Mark Gregory
2026-10-23 08:21:47 +01:00
parent f1e5463f5d
commit 55bd2be895
5 changed files with 692 additions and 2 deletions
+119 -2
View File
@@ -1,5 +1,7 @@
#!/bin/zsh
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/.." && pwd)"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
APP_NAME=OrionToolbar
@@ -44,8 +46,8 @@ notarize() {
local file="$1" result status
result=$(xcrun notarytool submit "$file" --keychain-profile "$NOTARY_PROFILE" --wait --output-format json)
echo "$result"
status=$(printf '%s' "$result" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("status", ""))')
[[ "$status" == Accepted ]] || { echo "Notarization not accepted for $file: $status" >&2; exit 1; }
notary_status=$(printf '%s' "$result" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("status", ""))')
[[ "$notary_status" == Accepted ]] || { echo "Notarization not accepted for $file: $notary_status" >&2; exit 1; }
}
notarize "$ZIP"
xcrun stapler staple "$APP"
@@ -55,6 +57,121 @@ ditto "$APP" "$WORK/dmg/$APP_NAME.app"
ln -s /Applications "$WORK/dmg/Applications"
rm -f "$DMG"
hdiutil create -volname "$APP_NAME" -srcfolder "$WORK/dmg" -ov -format UDZO "$DMG"
# ============================================================
# ============================================================
# Release paths
# ============================================================
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
BUILD_DIR="$ROOT_DIR/.build/release"
APP_PATH="$BUILD_DIR/export/OrionToolbar.app"
mkdir -p "$ROOT_DIR/dist"
VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$APP_PATH/Contents/Info.plist" 2>/dev/null || echo "1.0")
DMG_PATH="$ROOT_DIR/dist/OrionToolbar-$VERSION.dmg"
# ORION_CUSTOM_DMG_ICON
# Apply a custom Finder icon before signing/notarization.
# ============================================================
echo "=== APPLY CUSTOM DMG ICON ==="
DMG_ICON_SOURCE=""
# Prefer dedicated installer artwork.
for candidate in \
"$ROOT_DIR/OrionToolbar/Assets.xcassets/InstallerIcon.imageset/icon.png" \
"$ROOT_DIR/OrionToolbar/Assets.xcassets/AppIcon.appiconset/icon_512x512.png" \
"$ROOT_DIR/OrionToolbar/Assets.xcassets/AppIcon.appiconset/icon_1024x1024.png"
do
if [[ -f "$candidate" ]]; then
DMG_ICON_SOURCE="$candidate"
break
fi
done
# Fall back to the compiled application icon.
if [[ -z "$DMG_ICON_SOURCE" ]]; then
for candidate in \
"$APP_PATH/Contents/Resources/AppIcon.icns" \
"$BUILD_DIR/export/OrionToolbar.app/Contents/Resources/AppIcon.icns"
do
if [[ -f "$candidate" ]]; then
DMG_ICON_SOURCE="$candidate"
break
fi
done
fi
if [[ -z "$DMG_ICON_SOURCE" ]]; then
echo "ERROR: No installer or application icon found."
exit 1
fi
echo "Icon source: $DMG_ICON_SOURCE"
DMG_ICON_TEMP="$(mktemp -d)"
DMG_ICON_ICNS="$DMG_ICON_TEMP/OrionToolbar.icns"
if [[ "$DMG_ICON_SOURCE" == *.icns ]]; then
cp "$DMG_ICON_SOURCE" "$DMG_ICON_ICNS"
else
ICONSET="$DMG_ICON_TEMP/OrionToolbar.iconset"
mkdir -p "$ICONSET"
for size in 16 32 128 256 512; do
sips -s format png -z "$size" "$size" \
"$DMG_ICON_SOURCE" \
--out "$ICONSET/icon_${size}x${size}.png" >/dev/null
double=$((size * 2))
sips -s format png -z "$double" "$double" \
"$DMG_ICON_SOURCE" \
--out "$ICONSET/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET" -o "$DMG_ICON_ICNS"
fi
DMG_ICON_RESOURCE="$DMG_ICON_TEMP/OrionToolbar.r"
python3 - "$DMG_ICON_ICNS" "$DMG_ICON_RESOURCE" <<'ICONPY'
from pathlib import Path
import sys
icon = Path(sys.argv[1]).read_bytes()
if not icon.startswith(b"icns"):
raise SystemExit("ERROR: Invalid ICNS file.")
hexdata = icon.hex().upper()
with open(sys.argv[2], "w") as output:
output.write("data 'icns' (-16455) {\n")
for index in range(0, len(hexdata), 64):
output.write(
' $"' + hexdata[index:index + 64] + '"\n'
)
output.write("};\n")
ICONPY
REZ="$(xcrun --find Rez)"
SETFILE="$(xcrun --find SetFile)"
"$REZ" -append "$DMG_ICON_RESOURCE" -o "$DMG_PATH"
"$SETFILE" -a C "$DMG_PATH"
rm -rf "$DMG_ICON_TEMP"
echo "Custom DMG icon applied successfully."
codesign --force --timestamp --sign "$SIGNING_IDENTITY" "$DMG"
codesign --verify --verbose=2 "$DMG"
notarize "$DMG"