#!/usr/bin/env bash # Build a local, unnotarised DMG from the Release build. For testing/internal sharing only; use # scripts/release.sh for a Developer ID signed and notarised distribution image. set -euo pipefail cd "$(dirname "$0")/.." app="Sprachmittler" release_app=".build/xcode-release/Build/Products/Release/$app.app" dist="${DMG_DIR:-dist}" [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]] \ || { echo "error: Sprachmittler requires an Apple Silicon Mac" >&2; exit 1; } [[ -d "$release_app" ]] || { echo "error: $release_app not found — run 'make release-build'" >&2; exit 1; } step() { printf '\n\033[1m▶ %s\033[0m\n' "$*"; } check_app() { local candidate="$1" scripts/check-signature.sh "$candidate" install } step "Check Release build" check_app "$release_app" version=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$release_app/Contents/Info.plist") [[ -n "$version" ]] || { echo "error: cannot read CFBundleShortVersionString" >&2; exit 1; } dmg="$dist/$app-$version-local.dmg" stage=$(mktemp -d) mountpoint=$(mktemp -d) mounted=0 cleanup() { if [[ $mounted -eq 1 ]]; then hdiutil detach "$mountpoint" -quiet || true; fi rm -rf "$stage" "$mountpoint" } trap cleanup EXIT step "Stage $app $version" ditto "$release_app" "$stage/$app.app" ln -s /Applications "$stage/Applications" step "Create $dmg" mkdir -p "$dist" rm -f "$dmg" if diskutil image create from --help >/dev/null 2>&1; then if ! output=$(diskutil image create from "$stage" "$dmg" --volumeName "$app" --format UDZO 2>&1); then printf '%s\n' "$output" >&2 exit 1 fi else hdiutil create -volname "$app" -srcfolder "$stage" -ov -format UDZO "$dmg" >/dev/null fi hdiutil verify "$dmg" >/dev/null step "Verify mounted image" hdiutil attach "$dmg" -readonly -nobrowse -noautoopen -quiet -mountpoint "$mountpoint" mounted=1 check_app "$mountpoint/$app.app" [[ -L "$mountpoint/Applications" ]] \ || { echo "error: Applications link missing from the image" >&2; exit 1; } hdiutil detach "$mountpoint" -quiet mounted=0 printf '\n\033[32m✔ %s\033[0m\n' "$dmg" printf ' size %s\n' "$(du -h "$dmg" | cut -f1)" printf ' sha256 %s\n' "$(shasum -a 256 "$dmg" | cut -d' ' -f1)" cat <<'TXT' Ad-hoc signed and not notarised: this image is for testing and internal sharing only. On another Mac, open it via right-click ▸ Open (or System Settings ▸ Privacy & Security ▸ Open Anyway). For distribution use scripts/release.sh with a Developer ID identity and a notarytool profile. TXT