Clearwake / app · clearwake.ai / scripts / package-mac.sh
| 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. |
| 4 | set -e |
| 5 | cd "$(dirname "$0")/.." |
| 6 | rustup target add aarch64-apple-darwin x86_64-apple-darwin >/dev/null |
| 7 | MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target aarch64-apple-darwin |
| 8 | MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target x86_64-apple-darwin |
| 9 | app=dist/Clearwake.app |
| 10 | rm -rf "$app" && mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" |
| 11 | lipo -create -output "$app/Contents/MacOS/Clearwake" target/aarch64-apple-darwin/release/clearwake target/x86_64-apple-darwin/release/clearwake |
| 12 | version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) |
| 13 | cat > "$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> |
| 29 | PLIST |
| 30 | iconset=dist/Clearwake.iconset |
| 31 | rm -rf "$iconset" && mkdir -p "$iconset" |
| 32 | for 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 |
| 35 | done |
| 36 | iconutil -c icns "$iconset" -o "$app/Contents/Resources/Clearwake.icns" |
| 37 | if [ -n "$SIGN_ID" ]; then |
| 38 | codesign --force --options runtime --timestamp --sign "$SIGN_ID" "$app" |
| 39 | else |
| 40 | codesign --force --sign - "$app" |
| 41 | fi |
| 42 | rm -f dist/Clearwake-mac.zip |
| 43 | ditto -c -k --keepParent "$app" dist/Clearwake-mac.zip |
| 44 | if [ -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 |
| 49 | fi |
| 50 | echo dist/Clearwake-mac.zip |