#!/usr/bin/env sh # Builds Kaleido for macOS: the .app, a .dmg for first installs and the signed updater # archive, renamed Kaleido__.app.tar.gz for the release. # sh scripts/build.sh # release build # sh scripts/build.sh --debug # faster unoptimized build set -eu root=$(cd "$(dirname "$0")/.." && pwd) cd "$root" profile=release [ "${1:-}" = "--debug" ] && profile=debug sh scripts/fetch-libmpv.sh # The bundled libraries decide the oldest macOS Kaleido runs on (Homebrew builds them # for the macOS of the machine that installed them). minos=$(for f in vendor/mpv/macos/*.dylib; do otool -l "$f" | awk '/LC_BUILD_VERSION/{b=1} b&&/minos/{print $2; b=0}'; done | sort -V | tail -1) # Signing with one lasting certificate keeps the app's identity across updates, so the # Keychain keeps trusting it with the Plex token (ad hoc signatures change every build). # "Kaleido Self-Signed" lives in the login keychain; .tools/macos-signing.p12 backs it up. identity=${KALEIDO_SIGNING_IDENTITY:-Kaleido Self-Signed} if security find-identity -p codesigning | grep -q "\"$identity\""; then codesign --force --sign "$identity" vendor/mpv/macos/*.dylib 2>/dev/null else echo "warning: no \"$identity\" signing certificate; signing ad hoc (the Keychain will ask again after updates)." >&2 identity=- fi # The updater signing key stays outside git (.tools/), as on Windows. updater=true if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then if [ -f .tools/updater.key ]; then TAURI_SIGNING_PRIVATE_KEY=$(cat .tools/updater.key) TAURI_SIGNING_PRIVATE_KEY_PASSWORD=${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-} export TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PASSWORD else echo "warning: no updater signing key (.tools/updater.key); building without update artifacts." >&2 updater=false fi fi config="{\"bundle\":{\"createUpdaterArtifacts\":$updater,\"macOS\":{\"minimumSystemVersion\":\"$minos\",\"signingIdentity\":\"$identity\"}}}" [ -d node_modules ] || npm ci if [ "$profile" = debug ]; then npx tauri build --debug --config "$config"; else npx tauri build --config "$config"; fi version=$(node -p "require('./package.json').version") arch=$(uname -m | sed 's/arm64/aarch64/; s/x86_64/x64/') bundle="src-tauri/target/$profile/bundle" if [ -f "$bundle/macos/Kaleido.app.tar.gz" ]; then cp "$bundle/macos/Kaleido.app.tar.gz" "$bundle/macos/Kaleido_${version}_${arch}.app.tar.gz" cp "$bundle/macos/Kaleido.app.tar.gz.sig" "$bundle/macos/Kaleido_${version}_${arch}.app.tar.gz.sig" fi echo "Built for macOS $minos or later:" ls -l "$bundle/dmg" "$bundle/macos"