11#! /bin/bash
2- # Build, Developer-ID-sign, notarize and staple Relay into a distributable .app
3- # (+ .zip) that runs warning-free on any Mac.
2+ # Build Relay into a distributable, AD-HOC-signed .app + .dmg for GitHub Releases.
43#
5- # Prerequisites (one-time — see RELEASE.md):
6- # 1. A "Developer ID Application" certificate in your keychain.
7- # 2. Notary credentials stored as a keychain profile named "relay-notary":
8- # xcrun notarytool store-credentials relay-notary \
9- # --apple-id "<your-apple-id>" --team-id ULHJAB7ZT3 --password "<app-specific-password>"
4+ # NOT notarized and tied to no Apple Developer account — like most open-source Mac
5+ # apps. On first launch users approve it once via System Settings → Privacy &
6+ # Security → "Open Anyway" (or right-click → Open on older macOS). Auto-update still
7+ # works: Sparkle verifies the EdDSA-signed appcast, independent of Apple notarization.
108#
119# Usage: scripts/release.sh
1210set -euo pipefail
1311
1412ROOT=" $( cd " $( dirname " $0 " ) /.." && pwd) "
1513cd " $ROOT "
16-
1714DEV=" /Applications/Xcode.app/Contents/Developer"
18- ENT=" $ROOT /RelayNative/RelayNative.entitlements"
19- TEAM=" ULHJAB7ZT3"
20- NOTARY_PROFILE=" relay-notary"
2115DIST=" $ROOT /dist"
2216
23- # --- preflight ---------------------------------------------------------------
24- IDENTITY=$( security find-identity -v -p codesigning \
25- | grep " Developer ID Application" | grep " $TEAM " | head -1 | awk ' {print $2}' )
26- if [ -z " ${IDENTITY:- } " ]; then
27- cat >&2 << EOF
28- error: no "Developer ID Application" certificate for team $TEAM found.
29-
30- Create one first (see RELEASE.md):
31- Xcode → Settings → Accounts → (select your team) → Manage Certificates →
32- + → "Developer ID Application". Then re-run this script.
33- EOF
34- exit 1
35- fi
36- echo " Developer ID identity: $IDENTITY "
37-
38- if ! xcrun notarytool history --keychain-profile " $NOTARY_PROFILE " > /dev/null 2>&1 ; then
39- cat >&2 << EOF
40- error: notary credentials profile "$NOTARY_PROFILE " not found.
41-
42- Store them once (needs an app-specific password from appleid.apple.com):
43- xcrun notarytool store-credentials $NOTARY_PROFILE \\
44- --apple-id "<your-apple-id-email>" --team-id $TEAM --password "<app-specific-password>"
45- EOF
46- exit 1
47- fi
48-
49- # --- build (unsigned) --------------------------------------------------------
5017echo " → Building universal Go helper (arm64 + amd64)…"
5118( cd relay-helper
5219 CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o relay-helper.arm64 .
@@ -58,79 +25,42 @@ echo "→ Generating project + building Release…"
5825xcodegen generate > /dev/null
5926DEVELOPER_DIR=" $DEV " xcodebuild -project Relay.xcodeproj -scheme Relay \
6027 -configuration Release -derivedDataPath build \
61- CODE_SIGNING_ALLOWED=NO build > /dev/null
28+ ARCHS= " arm64 x86_64 " ONLY_ACTIVE_ARCH=NO CODE_SIGNING_ALLOWED=NO build > /dev/null
6229
6330APP_SRC=" build/Build/Products/Release/Relay.app"
6431[ -d " $APP_SRC " ] || { echo " error: build product missing" >&2 ; exit 1; }
65-
6632rm -rf " $DIST " ; mkdir -p " $DIST "
6733APP=" $DIST /Relay.app"
6834cp -R " $APP_SRC " " $APP "
6935
70- # --- bundle the Go backend + sign (hardened runtime + secure timestamp) -------
71- echo " → Bundling helper…"
36+ echo " → Bundling helper + ad-hoc signing (inside-out)…"
7237mkdir -p " $APP /Contents/Resources"
7338cp relay-helper/relay-helper " $APP /Contents/Resources/relay-helper"
74- codesign --force --options runtime --timestamp \
75- --sign " $IDENTITY " " $APP /Contents/Resources/relay-helper"
76-
77- # Sign embedded frameworks + their nested helpers (Sparkle ships Autoupdate,
78- # Updater.app and XPC services that must each be signed from the inside out,
79- # BEFORE the outer app, or notarization rejects the bundle).
39+ codesign --force --sign - " $APP /Contents/Resources/relay-helper"
8040if [ -d " $APP /Contents/Frameworks" ]; then
81- echo " → Signing embedded frameworks…"
82- # Nested helpers first (deepest), at any depth — Sparkle's XPC services live under
83- # Sparkle.framework/Versions/B/XPCServices, plus Autoupdate + Updater.app.
8441 find " $APP /Contents/Frameworks" \( -name " *.xpc" -o -name " *.app" -o -name " Autoupdate" -o -name " *.dylib" \) -print0 \
85- | while IFS= read -r -d ' ' nested; do
86- codesign --force --options runtime --timestamp --sign " $IDENTITY " " $nested "
87- done
88- # Then the frameworks themselves.
42+ | while IFS= read -r -d ' ' n; do codesign --force --sign - " $n " ; done
8943 find " $APP /Contents/Frameworks" -maxdepth 1 -name " *.framework" -print0 \
90- | while IFS= read -r -d ' ' fw; do
91- codesign --force --options runtime --timestamp --sign " $IDENTITY " " $fw "
92- done
44+ | while IFS= read -r -d ' ' fw; do codesign --force --sign - " $fw " ; done
9345fi
46+ codesign --force --sign - " $APP "
47+ codesign --verify --deep --strict " $APP " && echo " ad-hoc signature ok"
9448
95- echo " → Signing app with Developer ID…"
96- codesign --force --options runtime --timestamp \
97- --entitlements " $ENT " --sign " $IDENTITY " " $APP "
98- codesign --verify --deep --strict --verbose=2 " $APP "
49+ VERSION=$( /usr/libexec/PlistBuddy -c " Print :CFBundleShortVersionString" " $APP /Contents/Info.plist" 2> /dev/null || echo " 1.0" )
9950
100- # --- notarize ----------------------------------------------------------------
51+ echo " → Zipping (Sparkle update artifact)… "
10152ZIP=" $DIST /Relay.zip"
102- echo " → Zipping + submitting to Apple notary service (this can take a few minutes)…"
103- ditto -c -k --keepParent " $APP " " $ZIP "
104- xcrun notarytool submit " $ZIP " --keychain-profile " $NOTARY_PROFILE " --wait
105-
106- # --- staple + verify ---------------------------------------------------------
107- echo " → Stapling ticket…"
108- xcrun stapler staple " $APP "
109- spctl -a -t exec -vv " $APP " 2>&1 | sed ' s/^/ /'
110-
111- # refresh the zip with the stapled app (used by Sparkle's appcast)
112- rm -f " $ZIP "
11353ditto -c -k --keepParent " $APP " " $ZIP "
11454
115- # --- build a drag-to-Applications DMG, then notarize + staple it -------------
55+ echo " → Building drag-to-Applications DMG… "
11656DMG=" $DIST /Relay.dmg"
117- echo " → Building DMG…"
118- STAGING=" $DIST /dmg-staging"
119- rm -rf " $STAGING " ; mkdir -p " $STAGING "
57+ STAGING=" $DIST /dmg-staging" ; rm -rf " $STAGING " ; mkdir -p " $STAGING "
12058cp -R " $APP " " $STAGING /Relay.app"
12159ln -s /Applications " $STAGING /Applications"
12260hdiutil create -volname " Relay" -srcfolder " $STAGING " -ov -format UDZO " $DMG " > /dev/null
12361rm -rf " $STAGING "
124- echo " → Notarizing DMG…"
125- xcrun notarytool submit " $DMG " --keychain-profile " $NOTARY_PROFILE " --wait
126- xcrun stapler staple " $DMG "
127- spctl -a -t open --context context:primary-signature -vv " $DMG " 2>&1 | sed ' s/^/ /' || true
128-
129- VERSION=$( /usr/libexec/PlistBuddy -c " Print :CFBundleShortVersionString" " $APP /Contents/Info.plist" 2> /dev/null || echo " 0.1" )
13062
13163# --- Sparkle appcast (EdDSA-signed; private key lives in your Keychain) -------
132- # generate_appcast comes from the Sparkle tools. Set GENAPPCAST, or download the
133- # Sparkle release tarball into .sparkle-tools/ (see RELEASE.md).
13464GENAPPCAST=" ${GENAPPCAST:- $ROOT / .sparkle-tools/ bin/ generate_appcast} "
13565if [ ! -x " $GENAPPCAST " ]; then
13666 GENAPPCAST=$( find " $ROOT /build" -name generate_appcast -type f 2> /dev/null | head -1)
15080fi
15181
15282echo " ✓ Done."
153- echo " Notarized app : $APP "
83+ echo " App : $APP (ad-hoc signed, not notarized) "
15484echo " DMG (direct download): $DMG "
15585echo " Zip (Sparkle update): $ZIP "
15686[ -n " $APPCAST " ] && echo " Appcast (auto-update): $APPCAST "
0 commit comments