Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

feat: overhaul landing page and add Sparkle auto-update pipeline

Tobide9b5bda5e9b
diff --git a/.gitignore b/.gitignore
index 6b40daa..8d3af58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,4 +97,5 @@ windows/vendor/
# Generated version header — written by build-unpackaged.ps1 -Version
# from the CI tag, falls back to 0.0.0-dev locally via __has_include.
-windows/Gridex/GridexVersion.generated.h
\ No newline at end of file
+windows/Gridex/GridexVersion.generated.h
+dist
\ No newline at end of file
diff --git a/.wrangler/cache/wrangler-account.json b/.wrangler/cache/wrangler-account.json
new file mode 100644
index 0000000..2cdf060
--- /dev/null
+++ b/.wrangler/cache/wrangler-account.json
@@ -0,0 +1,6 @@
+{
+ "account": {
+ "id": "04285282d537ae420d72fa21d0de38af",
+ "name": "[email protected]'s Account"
+ }
+}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 648437f..3e63888 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
# Changelog
-All notable changes to Gridex (formerly DataBridge) are documented in this file.
+All notable changes to Gridex are documented in this file. Gridex ships native apps for **macOS** (Swift/AppKit) and **Windows** (C++/WinUI 3). Unless noted otherwise, changes apply to both platforms.
## [0.23.0] - 2026-04-12
@@ -585,10 +585,9 @@ The old `exportSQL(data:table:to:)` is kept for backward compatibility but `Expo
## [0.0.1] - 2026-04-01
### Added
-- Initial release
+- Initial release — macOS (Swift/AppKit) and Windows (C++/WinUI 3)
- Connection management (PostgreSQL, MySQL, SQLite) with SSH tunnel support
- Database browser with sidebar tree (schemas, tables, views, functions)
- Data grid with pagination, sorting, filtering
- Query editor with syntax highlighting
- AI chat integration (Anthropic/OpenAI/Ollama)
-- MCP server for external AI agents
diff --git a/Package.swift b/Package.swift
index cf59cc9..083b057 100644
--- a/Package.swift
+++ b/Package.swift
@@ -25,6 +25,8 @@ let package = Package(
.package(url: "https://github.com/orlandos-nl/MongoKitten.git", from: "7.9.0"),
// MSSQL driver (TDS 7.4, pure Swift NIO, no FreeTDS)
.package(url: "https://github.com/vkuttyp/CosmoSQLClient-Swift.git", branch: "main"),
+ // Sparkle — macOS auto-update framework
+ .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.6.0"),
],
targets: [
.executableTarget(
@@ -37,6 +39,7 @@ let package = Package(
.product(name: "CosmoMSSQL", package: "CosmoSQLClient-Swift"),
.product(name: "NIOSSL", package: "swift-nio-ssl"),
.product(name: "NIOSSH", package: "swift-nio-ssh"),
+ .product(name: "Sparkle", package: "Sparkle"),
],
path: "macos",
exclude: [
diff --git a/macos/App/Lifecycle/GridexApp.swift b/macos/App/Lifecycle/GridexApp.swift
index 2550bf0..4466433 100644
--- a/macos/App/Lifecycle/GridexApp.swift
+++ b/macos/App/Lifecycle/GridexApp.swift
@@ -10,6 +10,7 @@ import SwiftData
struct GridexApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@FocusedObject private var focusedAppState: AppState?
+ @ObservedObject private var updater = UpdaterService.shared
private var currentAppState: AppState? { focusedAppState ?? AppState.active }
@@ -28,6 +29,13 @@ struct GridexApp: App {
.keyboardShortcut(",", modifiers: .command)
}
+ CommandGroup(after: .appInfo) {
+ Button("Check for Updates…") {
+ updater.checkForUpdates()
+ }
+ .disabled(!updater.canCheckForUpdates)
+ }
+
CommandGroup(after: .newItem) {
// Cmd+N → default WindowGroup "New Window" (opens a fresh connection picker)
diff --git a/macos/Resources/Info.plist b/macos/Resources/Info.plist
index bdbade6..b77a14c 100644
--- a/macos/Resources/Info.plist
+++ b/macos/Resources/Info.plist
@@ -32,9 +32,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.22.1</string>
+ <string>0.0.1</string>
<key>CFBundleVersion</key>
- <string>2</string>
+ <string>1</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>NSAppTransportSecurity</key>
@@ -50,5 +50,15 @@
<string></string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
+ <key>SUFeedURL</key>
+ <string>https://cdn.gridex.app/macos/appcast.xml</string>
+ <key>SUPublicEDKey</key>
+ <string>4/cJL5efe7LF8thRAWjaLJui1cdzIxRPf0bgt3Waxas=</string>
+ <key>SUEnableAutomaticChecks</key>
+ <true/>
+ <key>SUScheduledCheckInterval</key>
+ <integer>86400</integer>
+ <key>SUAutomaticallyUpdate</key>
+ <false/>
</dict>
</plist>
diff --git a/macos/Services/Updater/UpdaterService.swift b/macos/Services/Updater/UpdaterService.swift
new file mode 100644
index 0000000..6239885
--- /dev/null
+++ b/macos/Services/Updater/UpdaterService.swift
@@ -0,0 +1,38 @@
+// UpdaterService.swift
+// Gridex
+//
+// Thin wrapper around Sparkle's SPUStandardUpdaterController.
+// Reads SUFeedURL and SUPublicEDKey from Info.plist.
+// Exposes @Published canCheckForUpdates so menu items can disable themselves
+// while Sparkle is busy.
+
+import Foundation
+import SwiftUI
+import Sparkle
+
+@MainActor
+final class UpdaterService: ObservableObject {
+ static let shared = UpdaterService()
+
+ private let controller: SPUStandardUpdaterController
+
+ @Published var canCheckForUpdates: Bool = true
+
+ var updater: SPUUpdater { controller.updater }
+
+ private init() {
+ controller = SPUStandardUpdaterController(
+ startingUpdater: true,
+ updaterDelegate: nil,
+ userDriverDelegate: nil
+ )
+
+ controller.updater.publisher(for: \.canCheckForUpdates)
+ .receive(on: RunLoop.main)
+ .assign(to: &$canCheckForUpdates)
+ }
+
+ func checkForUpdates() {
+ controller.checkForUpdates(nil)
+ }
+}
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index 09b7ded..ed8380e 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -26,6 +26,7 @@ ICON="$RESOURCES_DIR/AppIcon.icns"
XCASSETS="$RESOURCES_DIR/Assets.xcassets"
NOTARIZE="${NOTARIZE:-1}"
ARCH="${ARCH:-$(uname -m)}"
+SKIP_SIGN="${SKIP_SIGN:-0}"
# 1. Build
echo "→ Building ($MODE, $ARCH)..."
@@ -97,6 +98,24 @@ if [ -d "$BUNDLE_RESOURCE" ]; then
fi
fi
+# 7b. Embed Sparkle.framework (for in-app auto-update).
+# Located in SPM binary artifacts: .build/artifacts/sparkle/Sparkle/Sparkle.xcframework/macos-arm64_x86_64/
+SPARKLE_FRAMEWORK=$(find "$PROJECT_DIR/.build/artifacts" -type d -name "Sparkle.framework" 2>/dev/null | grep "macos-" | head -1)
+if [ -z "$SPARKLE_FRAMEWORK" ]; then
+ # Fallback to per-arch build output (symlinked from xcframework)
+ SPARKLE_FRAMEWORK="$BUILD_DIR/Sparkle.framework"
+fi
+if [ -d "$SPARKLE_FRAMEWORK" ]; then
+ echo "→ Embedding Sparkle.framework..."
+ FRAMEWORKS_DIR="$CONTENTS/Frameworks"
+ mkdir -p "$FRAMEWORKS_DIR"
+ # Copy preserving symlinks (Sparkle uses Versions/B + Current symlink)
+ rm -rf "$FRAMEWORKS_DIR/Sparkle.framework"
+ cp -R "$SPARKLE_FRAMEWORK" "$FRAMEWORKS_DIR/Sparkle.framework"
+else
+ echo "⚠ Sparkle.framework not found — auto-update will be disabled in this build."
+fi
+
# 8. Generate runtime entitlements (strip Xcode-only macros)
RUNTIME_ENT="$OUTPUT_DIR/runtime.entitlements"
/usr/libexec/PlistBuddy -c "Clear dict" "$RUNTIME_ENT" 2>/dev/null || plutil -create xml1 "$RUNTIME_ENT"
@@ -109,8 +128,9 @@ RUNTIME_ENT="$OUTPUT_DIR/runtime.entitlements"
# - Debug: ad-hoc signature so the app runs locally without a network round-trip.
# - Release: full sign + notarize + staple + verify via sign-notarize.sh (which also
# handles inside-out signing when Sparkle.framework is embedded in the future).
+# - SKIP_SIGN=1: skip signing entirely (used by release-all.sh before lipo merge).
-if [ "$MODE" = "release" ]; then
+if [ "$MODE" = "release" ] && [ "$SKIP_SIGN" != "1" ]; then
echo "→ Release sign + notarize pipeline..."
# Keep runtime.entitlements alongside the .app so sign-notarize.sh can pick it up
# (it sits at $(dirname .app)/runtime.entitlements).
@@ -120,30 +140,14 @@ if [ "$MODE" = "release" ]; then
"$SCRIPT_DIR/sign-notarize.sh" "$APP_BUNDLE"
else
# Sign only, skip notarize (useful during iteration).
+ # Delegate to sign-notarize.sh with SKIP_NOTARIZE=1 so Sparkle inside-out
+ # signing stays consistent across the NOTARIZE=1 and NOTARIZE=0 paths.
echo "→ Signing only (NOTARIZE=0)..."
- # Resolve SIGN_IDENTITY the same way sign-notarize.sh does
- if [ -z "${SIGN_IDENTITY:-}" ] && [ -f "$PROJECT_DIR/.env" ]; then
- SIGN_IDENTITY=$(grep -E "^SIGN_IDENTITY=" "$PROJECT_DIR/.env" | cut -d= -f2- | tr -d '"')
- fi
- if [ -z "${SIGN_IDENTITY:-}" ]; then
- echo "✗ SIGN_IDENTITY not set. Add it to .env or export it."
- rm -f "$RUNTIME_ENT"
- exit 1
- fi
- cs_out=$(codesign --force --deep --options runtime --timestamp \
- --sign "$SIGN_IDENTITY" \
- --entitlements "$RUNTIME_ENT" \
- --generate-entitlement-der \
- "$APP_BUNDLE" 2>&1) || {
- echo "✗ Signing failed"
- echo "$cs_out"
- rm -f "$RUNTIME_ENT"
- exit 1
- }
- echo "$cs_out" | grep -v "unsealed contents" || true
- codesign --verify --deep --strict --verbose=2 "$APP_BUNDLE"
+ SKIP_NOTARIZE=1 "$SCRIPT_DIR/sign-notarize.sh" "$APP_BUNDLE"
fi
rm -f "$RUNTIME_ENT"
+elif [ "$MODE" = "release" ] && [ "$SKIP_SIGN" = "1" ]; then
+ echo "→ Skipping sign (SKIP_SIGN=1) — entitlements kept at $RUNTIME_ENT"
else
echo "→ Ad-hoc signing (debug)..."
cs_out=$(codesign --force --deep --sign - \
diff --git a/scripts/publish.sh b/scripts/publish.sh
new file mode 100755
index 0000000..244863a
--- /dev/null
+++ b/scripts/publish.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+# publish.sh — Generate Sparkle appcast and upload release artifacts to Cloudflare R2.
+#
+# Usage:
+# ./scripts/publish.sh # Publishes everything in dist/*.dmg
+# DRY_RUN=1 ./scripts/publish.sh # Generates appcast locally, skips upload
+# SKIP_APPCAST=1 ./scripts/publish.sh # Uploads existing artifacts, no appcast regen
+#
+# Env:
+# R2_BUCKET Cloudflare R2 bucket name (default: gridex-downloads)
+# R2_PREFIX Path prefix in bucket (default: macos)
+# FEED_BASE_URL Public URL where the DMGs are served (default: https://cdn.gridex.app/macos)
+# DRY_RUN 1 = generate appcast locally, skip R2 upload
+# SKIP_APPCAST 1 = skip appcast regeneration (re-upload only)
+#
+# Requirements:
+# • generate_appcast from Sparkle (found automatically under .build/artifacts)
+# • wrangler CLI (npm i -g wrangler) with `wrangler login` completed
+# • EdDSA private key previously generated via `generate_keys` (stored in Keychain)
+#
+# Flow:
+# 1. Find generate_appcast in SPM artifacts
+# 2. Run generate_appcast against dist/ → signs each DMG with EdDSA, emits appcast.xml
+# 3. Upload every .dmg + appcast.xml to R2 under $R2_BUCKET/$R2_PREFIX/
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
+DIST_DIR="$PROJECT_DIR/dist"
+
+R2_BUCKET="${R2_BUCKET:-gridex}"
+R2_PREFIX="${R2_PREFIX:-macos}"
+FEED_BASE_URL="${FEED_BASE_URL:-https://cdn.gridex.app/macos}"
+DRY_RUN="${DRY_RUN:-0}"
+SKIP_APPCAST="${SKIP_APPCAST:-0}"
+
+echo "═══════════════════════════════════════════"
+echo " Publish to Cloudflare R2"
+echo " Bucket: $R2_BUCKET"
+echo " Prefix: $R2_PREFIX"
+echo " Feed: $FEED_BASE_URL"
+[ "$DRY_RUN" = "1" ] && echo " Mode: DRY RUN (no upload)"
+echo "═══════════════════════════════════════════"
+
+if [ ! -d "$DIST_DIR" ] || [ -z "$(ls -A "$DIST_DIR"/*.dmg 2>/dev/null)" ]; then
+ echo "✗ No .dmg files in $DIST_DIR"
+ echo " Run ./scripts/release.sh or ./scripts/release-all.sh first."
+ exit 1
+fi
+
+# 1. Locate generate_appcast
+if [ "$SKIP_APPCAST" != "1" ]; then
+ GENERATE_APPCAST=$(find "$PROJECT_DIR/.build/artifacts" -type f -name "generate_appcast" 2>/dev/null | head -1)
+ if [ -z "$GENERATE_APPCAST" ]; then
+ echo "✗ generate_appcast not found. Run 'swift build' at least once to fetch Sparkle artifacts."
+ exit 1
+ fi
+
+ echo "→ Generating appcast.xml via $GENERATE_APPCAST..."
+ # --download-url-prefix tells Sparkle where to fetch DMGs from at update time.
+ "$GENERATE_APPCAST" \
+ --download-url-prefix "$FEED_BASE_URL/" \
+ "$DIST_DIR"
+ echo "✓ Appcast generated: $DIST_DIR/appcast.xml"
+fi
+
+if [ "$DRY_RUN" = "1" ]; then
+ echo ""
+ echo "Dry run complete. Artifacts ready in $DIST_DIR:"
+ ls -lh "$DIST_DIR"/*.dmg "$DIST_DIR"/appcast.xml 2>/dev/null || true
+ exit 0
+fi
+
+# 2. Check for wrangler
+if ! command -v wrangler >/dev/null 2>&1; then
+ echo "✗ wrangler not found. Install with: npm i -g wrangler"
+ exit 1
+fi
+
+# 3. Upload DMGs
+echo "→ Uploading DMGs to R2..."
+for dmg in "$DIST_DIR"/*.dmg; do
+ [ -f "$dmg" ] || continue
+ name=$(basename "$dmg")
+ echo " ↑ $name"
+ wrangler r2 object put "$R2_BUCKET/$R2_PREFIX/$name" \
+ --file "$dmg" \
+ --content-type "application/x-apple-diskimage" \
+ --remote
+done
+
+# 4. Upload appcast.xml (cache-control short so updates propagate fast)
+if [ -f "$DIST_DIR/appcast.xml" ]; then
+ echo " ↑ appcast.xml"
+ wrangler r2 object put "$R2_BUCKET/$R2_PREFIX/appcast.xml" \
+ --file "$DIST_DIR/appcast.xml" \
+ --content-type "application/xml" \
+ --cache-control "public, max-age=300" \
+ --remote
+fi
+
+echo ""
+echo "═══════════════════════════════════════════"
+echo " ✓ Published to R2"
+echo " Appcast: $FEED_BASE_URL/appcast.xml"
+echo "═══════════════════════════════════════════"
diff --git a/scripts/release-all.sh b/scripts/release-all.sh
index f814dc9..214bf69 100755
--- a/scripts/release-all.sh
+++ b/scripts/release-all.sh
@@ -1,36 +1,89 @@
#!/bin/bash
-# release-all.sh — Build, sign, and package DMGs for both architectures.
+# release-all.sh — Build a universal (arm64 + x86_64) Gridex release via lipo.
#
# Usage:
# ./scripts/release-all.sh
#
# Produces:
-# dist/Gridex-<version>-arm64.dmg (Apple Silicon)
-# dist/Gridex-<version>-x86_64.dmg (Intel)
+# dist/Gridex-<version>-universal.dmg
+#
+# Flow:
+# 1. Build arm64 .app bundle (unsigned, frameworks embedded)
+# 2. Swift cross-compile x86_64 executable
+# 3. lipo both executables → universal binary inside the .app
+# 4. Sign + notarize the universal .app
+# 5. Package + sign + notarize DMG
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
+
+VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$PROJECT_DIR/macos/Resources/Info.plist")
+APP_BUNDLE="$PROJECT_DIR/dist/Gridex.app"
echo ""
echo "╔═══════════════════════════════════════════╗"
-echo "║ Gridex — Multi-Arch Release ║"
+echo "║ Gridex — Universal Release ║"
echo "╚═══════════════════════════════════════════╝"
+echo " Version: $VERSION"
+echo ""
+
+# 1. Build arm64 .app bundle (no sign yet — we lipo first)
+echo "━━━ Step 1: Build arm64 .app (unsigned) ━━━"
+echo ""
+ARCH=arm64 SKIP_SIGN=1 "$SCRIPT_DIR/build-app.sh" release
+
+ARM64_BIN="$PROJECT_DIR/.build/arm64-apple-macosx/release/Gridex"
+if [ ! -f "$ARM64_BIN" ]; then
+ echo "✗ arm64 executable not found: $ARM64_BIN"
+ exit 1
+fi
+# 2. Cross-compile x86_64 executable
echo ""
-echo "━━━ Building for Apple Silicon (arm64) ━━━"
+echo "━━━ Step 2: Cross-compile x86_64 executable ━━━"
echo ""
-ARCH=arm64 "$SCRIPT_DIR/release.sh"
+swift build -c release --arch x86_64 --package-path "$PROJECT_DIR" 2>&1 | tail -3
+X86_BIN="$PROJECT_DIR/.build/x86_64-apple-macosx/release/Gridex"
+if [ ! -f "$X86_BIN" ]; then
+ echo "✗ x86_64 executable not found: $X86_BIN"
+ exit 1
+fi
+
+# 3. Merge into universal binary
echo ""
-echo "━━━ Building for Intel (x86_64) ━━━"
+echo "━━━ Step 3: lipo → universal binary ━━━"
echo ""
-ARCH=x86_64 "$SCRIPT_DIR/release.sh"
+lipo -create \
+ "$ARM64_BIN" \
+ "$X86_BIN" \
+ -output "$APP_BUNDLE/Contents/MacOS/Gridex"
+echo "✓ Universal binary:"
+lipo -info "$APP_BUNDLE/Contents/MacOS/Gridex"
+
+# 4. Sign + notarize the universal .app
+echo ""
+echo "━━━ Step 4: Sign + Notarize .app ━━━"
+echo ""
+# runtime.entitlements was left in dist/ by build-app.sh (SKIP_SIGN=1)
+"$SCRIPT_DIR/sign-notarize.sh" "$APP_BUNDLE"
+
+# 5. Package + sign + notarize DMG (named -universal)
+echo ""
+echo "━━━ Step 5: Package universal DMG ━━━"
+echo ""
+ARCH=universal "$SCRIPT_DIR/make-dmg.sh"
echo ""
echo "╔═══════════════════════════════════════════╗"
-echo "║ ✓ All builds complete ║"
+echo "║ ✓ Universal release complete ║"
echo "╚═══════════════════════════════════════════╝"
echo ""
echo "Artifacts:"
-ls -lh "$(cd "$SCRIPT_DIR/.." && pwd)/dist/"*.dmg 2>/dev/null || true
+ls -lh "$PROJECT_DIR/dist/"*.dmg 2>/dev/null || true
+
+echo ""
+echo "Next: generate Sparkle appcast and upload to R2"
+echo " ./scripts/publish.sh"
diff --git a/scripts/sign-notarize.sh b/scripts/sign-notarize.sh
index ba814d8..e3cfa6f 100755
--- a/scripts/sign-notarize.sh
+++ b/scripts/sign-notarize.sh
@@ -1,18 +1,20 @@
#!/bin/bash
-# sign-notarize.sh — Sign + Notarize a macOS .app or .dmg for distribution
+# sign-notarize.sh — Sign + Notarize a macOS .app or .dmg for distribution.
+# Handles inside-out signing when Sparkle.framework is embedded.
#
# Usage:
# ./scripts/sign-notarize.sh <path-to-app-or-dmg>
#
# Env:
-# SIGN_IDENTITY SHA-1 or full name of Developer ID Application cert.
-# Defaults to the Gridex production cert (16/4/26, team W3C6S577FM).
-# NOTARY_PROFILE notarytool keychain profile name (default: gridex-notarize).
-# SKIP_SIGN=1 Skip resigning (useful when already signed, just notarize).
+# SIGN_IDENTITY SHA-1 or common name of Developer ID Application cert.
+# NOTARY_PROFILE notarytool keychain profile (default: gridex-notarize).
+# SKIP_SIGN=1 Skip resigning (notarize only).
+# SKIP_NOTARIZE=1 Skip Apple Notary submission (sign only).
#
-# Flow:
-# .app → sign (inside-out if Sparkle present) → zip → submit → wait → staple → verify
-# .dmg → sign → submit → wait → staple → verify
+# Flow for .app:
+# 1. Sparkle inside-out: XPCServices → Autoupdate → Updater.app → Sparkle.framework
+# 2. Sign main app bundle with runtime entitlements
+# 3. Verify → zip → submit → wait → staple → Gatekeeper check
set -euo pipefail
@@ -28,9 +30,6 @@ if [ ! -e "$TARGET" ]; then
exit 1
fi
-# SIGN_IDENTITY: SHA-1 fingerprint or common name of your Developer ID Application cert.
-# Not a secret — certs are public. Set via .env or export before running.
-# Fall back to "-" (ad-hoc) if unset, so forks can build without an Apple account.
SIGN_IDENTITY="${SIGN_IDENTITY:-${GRIDEX_SIGN_IDENTITY:-}}"
if [ -z "$SIGN_IDENTITY" ] && [ -f "$(dirname "$0")/../.env" ]; then
SIGN_IDENTITY=$(grep -E "^SIGN_IDENTITY=" "$(dirname "$0")/../.env" | cut -d= -f2- | tr -d '"')
@@ -44,51 +43,92 @@ fi
NOTARY_PROFILE="${NOTARY_PROFILE:-gridex-notarize}"
SKIP_SIGN="${SKIP_SIGN:-0}"
+SKIP_NOTARIZE="${SKIP_NOTARIZE:-0}"
echo "═══════════════════════════════════════════"
echo " Sign + Notarize"
echo " Target: $TARGET"
echo " Identity: $SIGN_IDENTITY"
echo " Profile: $NOTARY_PROFILE"
+[ "$SKIP_NOTARIZE" = "1" ] && echo " Mode: SIGN ONLY (SKIP_NOTARIZE=1)"
echo "═══════════════════════════════════════════"
EXT="${TARGET##*.}"
-sign_app() {
- local app="$1"
+# Helper: codesign wrapper that filters "unsealed contents" warnings but
+# still catches real failures (works around pipefail interaction with grep -v).
+sign() {
+ local out
+ out=$(codesign --force --options runtime --timestamp \
+ --sign "$SIGN_IDENTITY" "$@" 2>&1) || {
+ echo "✗ codesign failed for: $*"
+ echo "$out"
+ exit 1
+ }
+ echo "$out" | grep -v "unsealed contents" || true
+}
+
+sign_with_entitlements() {
+ local ent="$1"
+ shift
+ local out
+ out=$(codesign --force --options runtime --timestamp \
+ --sign "$SIGN_IDENTITY" \
+ --entitlements "$ent" \
+ --generate-entitlement-der \
+ "$@" 2>&1) || {
+ echo "✗ codesign failed for: $*"
+ echo "$out"
+ exit 1
+ }
+ echo "$out" | grep -v "unsealed contents" || true
+}
- # Inside-out: if Sparkle.framework is embedded, sign its nested helpers first
+sign_sparkle() {
+ local app="$1"
local sparkle="$app/Contents/Frameworks/Sparkle.framework"
- if [ -d "$sparkle/Versions/B" ]; then
- echo "→ Signing Sparkle helpers (inside-out)..."
- codesign --force --options runtime --timestamp \
- --sign "$SIGN_IDENTITY" \
- "$sparkle/Versions/B/Autoupdate" \
- "$sparkle/Versions/B/Updater.app" 2>&1 | grep -v "unsealed contents" || true
- codesign --force --options runtime --timestamp \
- --sign "$SIGN_IDENTITY" \
- "$sparkle" 2>&1 | grep -v "unsealed contents" || true
+ [ -d "$sparkle" ] || return 0
+
+ echo "→ Signing Sparkle inside-out..."
+ local versions_dir="$sparkle/Versions/B"
+ [ -d "$versions_dir" ] || versions_dir="$sparkle/Versions/A"
+
+ # 1. XPC services (Downloader.xpc, Installer.xpc)
+ if [ -d "$versions_dir/XPCServices" ]; then
+ for xpc in "$versions_dir/XPCServices"/*.xpc; do
+ [ -d "$xpc" ] || continue
+ sign "$xpc"
+ done
fi
- # Entitlements live alongside the runtime (generated by build-app.sh)
- local ent_arg=""
- local runtime_ent="$(dirname "$app")/runtime.entitlements"
- if [ -f "$runtime_ent" ]; then
- ent_arg="--entitlements $runtime_ent --generate-entitlement-der"
+ # 2. Autoupdate helper binary
+ [ -f "$versions_dir/Autoupdate" ] && sign "$versions_dir/Autoupdate"
+
+ # 3. Updater.app (sign inner binary first, then bundle)
+ if [ -d "$versions_dir/Updater.app" ]; then
+ local updater_bin="$versions_dir/Updater.app/Contents/MacOS/Updater"
+ [ -f "$updater_bin" ] && sign "$updater_bin"
+ sign "$versions_dir/Updater.app"
fi
+ # 4. Sparkle.framework itself
+ sign "$sparkle"
+}
+
+sign_app() {
+ local app="$1"
+
+ sign_sparkle "$app"
+
+ # Entitlements live alongside the .app (generated by build-app.sh)
+ local ent_path="$(dirname "$app")/runtime.entitlements"
+
echo "→ Signing app bundle..."
- local cs_output
- # shellcheck disable=SC2086
- cs_output=$(codesign --force --deep --options runtime --timestamp \
- --sign "$SIGN_IDENTITY" \
- $ent_arg \
- "$app" 2>&1) || {
- echo "✗ codesign failed"
- echo "$cs_output"
- exit 1
- }
- echo "$cs_output" | grep -v "unsealed contents" || true
+ if [ -f "$ent_path" ]; then
+ sign_with_entitlements "$ent_path" "$app"
+ else
+ sign "$app"
+ fi
}
verify_app() {
@@ -115,6 +155,12 @@ if [ "$EXT" = "app" ]; then
fi
verify_app "$APP_PATH"
+ if [ "$SKIP_NOTARIZE" = "1" ]; then
+ echo ""
+ echo "✓ Signed (not notarized): $APP_PATH"
+ exit 0
+ fi
+
ZIP_PATH="$(dirname "$APP_PATH")/$(basename "$APP_PATH" .app).zip"
echo "→ Creating zip for notarization..."
rm -f "$ZIP_PATH"
@@ -140,6 +186,12 @@ elif [ "$EXT" = "dmg" ]; then
codesign --force --sign "$SIGN_IDENTITY" --timestamp "$DMG_PATH"
fi
+ if [ "$SKIP_NOTARIZE" = "1" ]; then
+ echo ""
+ echo "✓ Signed (not notarized): $DMG_PATH"
+ exit 0
+ fi
+
notarize "$DMG_PATH"
echo "→ Stapling notarization ticket..."