#!/bin/sh # Mac app (Apple Silicon + Intel), signed with Developer ID and notarized when # SIGN_ID and NOTARY_PROFILE are set. Run on a Mac. set -e cd "$(dirname "$0")/.." rustup target add aarch64-apple-darwin x86_64-apple-darwin >/dev/null MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target aarch64-apple-darwin MACOSX_DEPLOYMENT_TARGET=11.0 cargo build -p clearwake --release --target x86_64-apple-darwin app=dist/Clearwake.app rm -rf "$app" && mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" lipo -create -output "$app/Contents/MacOS/Clearwake" target/aarch64-apple-darwin/release/clearwake target/x86_64-apple-darwin/release/clearwake version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) cat > "$app/Contents/Info.plist" < CFBundleNameClearwake CFBundleDisplayNameClearwake CFBundleIdentifierai.clearwake.Clearwake CFBundleExecutableClearwake CFBundleIconFileClearwake CFBundlePackageTypeAPPL CFBundleShortVersionString$version CFBundleVersion$version LSMinimumSystemVersion11.0 NSHighResolutionCapable LSApplicationCategoryTypepublic.app-category.productivity PLIST iconset=dist/Clearwake.iconset rm -rf "$iconset" && mkdir -p "$iconset" for s in 16 32 128 256 512; do sips -z $s $s assets/icon-1024.png --out "$iconset/icon_${s}x${s}.png" >/dev/null d=$((s*2)); sips -z $d $d assets/icon-1024.png --out "$iconset/icon_${s}x${s}@2x.png" >/dev/null done iconutil -c icns "$iconset" -o "$app/Contents/Resources/Clearwake.icns" if [ -n "$SIGN_ID" ]; then codesign --force --options runtime --timestamp --sign "$SIGN_ID" "$app" else codesign --force --sign - "$app" fi rm -f dist/Clearwake-mac.zip ditto -c -k --keepParent "$app" dist/Clearwake-mac.zip if [ -n "$SIGN_ID" ] && [ -n "$NOTARY_PROFILE" ]; then xcrun notarytool submit dist/Clearwake-mac.zip --keychain-profile "$NOTARY_PROFILE" --wait xcrun stapler staple "$app" rm -f dist/Clearwake-mac.zip ditto -c -k --keepParent "$app" dist/Clearwake-mac.zip fi echo dist/Clearwake-mac.zip