-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·71 lines (62 loc) · 2.81 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·71 lines (62 loc) · 2.81 KB
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
64
65
66
67
68
69
70
71
#!/bin/bash
# Builds, Developer ID-signs (Hardened Runtime), notarizes, staples, and packages
# Minimizer into a distributable Minimizer.dmg.
#
# PREREQUISITES (one-time):
# 1) A "Developer ID Application" certificate in your keychain
# (Xcode → Settings → Accounts → Manage Certificates → + → Developer ID Application).
# 2) A stored notary credential profile named "MinimizerNotary":
# xcrun notarytool store-credentials "MinimizerNotary" \
# --key /path/to/AuthKey_XXXXXX.p8 \
# --key-id YOUR_KEY_ID \
# --issuer YOUR_ISSUER_ID
set -euo pipefail
cd "$(dirname "$0")"
APP_NAME="Minimizer"
BUNDLE="${APP_NAME}.app"
DMG="${APP_NAME}.dmg"
NOTARY_PROFILE="MinimizerNotary"
CONFIG="release"
# --- Resolve the Developer ID Application identity ---
IDENTITY=$(security find-identity -v -p codesigning 2>/dev/null \
| grep "Developer ID Application" | head -1 | sed -E 's/^[[:space:]]*[0-9]+\) [0-9A-F]+ "(.*)"$/\1/')
if [ -z "$IDENTITY" ]; then
echo "ERROR: No 'Developer ID Application' certificate found."
echo "Create one: Xcode → Settings → Accounts → Manage Certificates → + → Developer ID Application."
exit 1
fi
echo "==> Signing identity: $IDENTITY"
# --- Build + assemble the .app (reuses the SwiftPM build) ---
echo "==> Building (${CONFIG})..."
swift build -c "$CONFIG"
BIN_PATH="$(swift build -c "$CONFIG" --show-bin-path)/$APP_NAME"
echo "==> Assembling ${BUNDLE}..."
rm -rf "$BUNDLE"
mkdir -p "$BUNDLE/Contents/MacOS" "$BUNDLE/Contents/Resources"
cp "$BIN_PATH" "$BUNDLE/Contents/MacOS/$APP_NAME"
cp "Resources/Info.plist" "$BUNDLE/Contents/Info.plist"
cp "Resources/Minimizer.icns" "$BUNDLE/Contents/Resources/Minimizer.icns"
# --- Sign with Hardened Runtime + secure timestamp (required for notarization) ---
echo "==> Codesigning (Developer ID, Hardened Runtime)…"
codesign --force --options runtime --timestamp \
--sign "$IDENTITY" "$BUNDLE"
codesign --verify --strict --verbose=2 "$BUNDLE"
# --- Build the DMG (drag-to-Applications) ---
echo "==> Building ${DMG}..."
rm -rf "$DMG" dmg_staging
mkdir dmg_staging
cp -R "$BUNDLE" dmg_staging/
ln -s /Applications dmg_staging/Applications
hdiutil create -volname "$APP_NAME" -srcfolder dmg_staging -ov -format UDZO "$DMG"
rm -rf dmg_staging
codesign --force --sign "$IDENTITY" "$DMG"
# --- Notarize + staple ---
echo "==> Submitting to Apple notary service (this can take a few minutes)..."
xcrun notarytool submit "$DMG" --keychain-profile "$NOTARY_PROFILE" --wait
echo "==> Stapling..."
xcrun stapler staple "$DMG"
xcrun stapler staple "$BUNDLE" || true
spctl --assess --type open --context context:primary-signature -v "$DMG" || true
echo "==> Done: $(pwd)/$DMG"
echo " Verify on a clean machine: download, open the .dmg, drag to Applications,"
echo " launch — Gatekeeper should allow it with no warnings."