#!/usr/bin/env bash # Wrap the tray GUI in a macOS application bundle, so it can be installed as an # app (a Homebrew cask, or dragging it to /Applications) instead of being a bare # executable. # # Usage: build-app.sh # the built tsunagi-tray executable # the release version (the tag without its leading v) # the bundle to create; replaced if it exists # # It is a menu-bar app: LSUIElement keeps it out of the Dock and the app # switcher, and the tray starts the window as a second process of the same # executable, which inherits that. The bundle is signed ad hoc where `codesign` # exists (the macOS runner), because arm64 will not run unsigned code; it is not # notarised, so a downloaded copy needs its quarantine flag cleared, which the # cask does. set -euo pipefail tray="$1" version="$2" app="$3" # CFBundleShortVersionString is dotted numbers only; 0.1.0-rc.22 becomes 0.1.0. short="${version%%-*}" rm -rf "$app" mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" install -m 0755 "$tray" "$app/Contents/MacOS/tsunagi-tray" cat > "$app/Contents/Info.plist" < CFBundleName Tsunagi CFBundleDisplayName Tsunagi CFBundleIdentifier cy.hexor.tsunagi.tray CFBundleExecutable tsunagi-tray CFBundlePackageType APPL CFBundleVersion ${short} CFBundleShortVersionString ${short} LSMinimumSystemVersion 11.0 LSUIElement NSHighResolutionCapable PLIST if command -v codesign >/dev/null 2>&1; then codesign --force --deep --sign - "$app" fi echo "built $app"