69 lines
2.8 KiB
Bash
Executable File
69 lines
2.8 KiB
Bash
Executable File
#!/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" <<PLIST
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>CFBundleName</key><string>Musyx</string>
|
|
<key>CFBundleDisplayName</key><string>Musyx</string>
|
|
<key>CFBundleIdentifier</key><string>dev.musyx.desktop</string>
|
|
<key>CFBundleExecutable</key><string>Musyx</string>
|
|
<key>CFBundleIconFile</key><string>Musyx</string>
|
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
<key>CFBundleShortVersionString</key><string>${version}</string>
|
|
<key>CFBundleVersion</key><string>${version}</string>
|
|
<key>LSMinimumSystemVersion</key><string>11.0</string>
|
|
<key>LSApplicationCategoryType</key><string>public.app-category.music</string>
|
|
<key>NSHighResolutionCapable</key><true/>
|
|
<key>NSHumanReadableCopyright</key><string>Unofficial Yandex Music client. Not affiliated with Yandex.</string>
|
|
</dict>
|
|
</plist>
|
|
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
|