#!/usr/bin/env bash # Builds Musyx.app (release, Developer ID signed) into target/release/bundle/. # tool/bundle-macos.sh # build the bundle # tool/bundle-macos.sh --install # and copy it to /Applications # MUSYX_SIGN_IDENTITY picks another signing identity; "-" signs ad hoc. set -euo pipefail root="$(cd "$(dirname "$0")/.." && pwd)" cd "$root" version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" bundle="target/release/bundle/Musyx.app" identity="${MUSYX_SIGN_IDENTITY:-Developer ID Application: Yuriy Panov (H33L24BGUH)}" cargo build --release -p musyx rm -rf "$bundle" mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources" cp target/release/musyx "$bundle/Contents/MacOS/Musyx" # Icon: every size macOS asks for, from the 1024px master. iconset="$(mktemp -d)/Musyx.iconset" mkdir -p "$iconset" master="crates/musyx/assets/icon/musyx.png" for size in 16 32 128 256 512; do sips -z "$size" "$size" "$master" --out "$iconset/icon_${size}x${size}.png" >/dev/null double=$((size * 2)) sips -z "$double" "$double" "$master" --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null done iconutil -c icns "$iconset" -o "$bundle/Contents/Resources/Musyx.icns" cat > "$bundle/Contents/Info.plist" < CFBundleNameMusyx CFBundleDisplayNameMusyx CFBundleIdentifierit.panov.musyx.desktop CFBundleDevelopmentRegionen CFBundleLocalizationsenru CFBundleExecutableMusyx CFBundleIconFileMusyx CFBundlePackageTypeAPPL CFBundleShortVersionString${version} CFBundleVersion${version} LSMinimumSystemVersion11.0 LSApplicationCategoryTypepublic.app-category.music NSHighResolutionCapable NSHumanReadableCopyrightUnofficial Yandex Music client. Not affiliated with Yandex. PLIST # Developer ID with the hardened runtime and a secure timestamp, as notarization requires. # The identity stays the same across builds, so keychain access to the saved sign-in is # granted once. An ad-hoc signature is a new identity on every build. if [[ "$identity" == "-" ]]; then codesign --force --sign - "$bundle" else codesign --force --options runtime --timestamp --sign "$identity" "$bundle" fi codesign --verify --strict --verbose=2 "$bundle" echo "Built $bundle ($version)" if [[ "${1:-}" == "--install" ]]; then rm -rf "/Applications/Musyx.app" cp -R "$bundle" /Applications/ echo "Installed /Applications/Musyx.app" fi