Branchwell

Clearwake / app · clearwake.ai / scripts / package-mac.sh

Raw 2.4 KB on 85fd7484362aeeaf8dbc19b2d6ddb6a3999a141b
1#!/bin/sh
2# Mac app (Apple Silicon + Intel), signed with Developer ID and notarized when
3# SIGN_ID and NOTARY_PROFILE are set. Run on a Mac.
4set -e
5cd "$(dirname "$0")/.."
6rustup target add aarch64-apple-darwin x86_64-apple-darwin >/dev/null
7MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target aarch64-apple-darwin
8MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target x86_64-apple-darwin
9app=dist/Clearwake.app
10rm -rf "$app" && mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
11lipo -create -output "$app/Contents/MacOS/Clearwake" target/aarch64-apple-darwin/release/clearwake target/x86_64-apple-darwin/release/clearwake
12version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
13cat > "$app/Contents/Info.plist" <<PLIST
14<?xml version="1.0" encoding="UTF-8"?>
15<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
16<plist version="1.0"><dict>
17<key>CFBundleName</key><string>Clearwake</string>
18<key>CFBundleDisplayName</key><string>Clearwake</string>
19<key>CFBundleIdentifier</key><string>ai.clearwake.Clearwake</string>
20<key>CFBundleExecutable</key><string>Clearwake</string>
21<key>CFBundleIconFile</key><string>Clearwake</string>
22<key>CFBundlePackageType</key><string>APPL</string>
23<key>CFBundleShortVersionString</key><string>$version</string>
24<key>CFBundleVersion</key><string>$version</string>
25<key>LSMinimumSystemVersion</key><string>11.0</string>
26<key>NSHighResolutionCapable</key><true/>
27<key>LSApplicationCategoryType</key><string>public.app-category.productivity</string>
28</dict></plist>
29PLIST
30iconset=dist/Clearwake.iconset
31rm -rf "$iconset" && mkdir -p "$iconset"
32for s in 16 32 128 256 512; do
33 sips -z $s $s assets/icon-1024.png --out "$iconset/icon_${s}x${s}.png" >/dev/null
34 d=$((s*2)); sips -z $d $d assets/icon-1024.png --out "$iconset/icon_${s}x${s}@2x.png" >/dev/null
35done
36iconutil -c icns "$iconset" -o "$app/Contents/Resources/Clearwake.icns"
37if [ -n "$SIGN_ID" ]; then
38 codesign --force --options runtime --timestamp --sign "$SIGN_ID" "$app"
39else
40 codesign --force --sign - "$app"
41fi
42rm -f dist/Clearwake-mac.zip
43ditto -c -k --keepParent "$app" dist/Clearwake-mac.zip
44if [ -n "$SIGN_ID" ] && [ -n "$NOTARY_PROFILE" ]; then
45 xcrun notarytool submit dist/Clearwake-mac.zip --keychain-profile "$NOTARY_PROFILE" --wait
46 xcrun stapler staple "$app"
47 rm -f dist/Clearwake-mac.zip
48 ditto -c -k --keepParent "$app" dist/Clearwake-mac.zip
49fi
50echo dist/Clearwake-mac.zip