2026-07-28 20:43:46 +08:00

33 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
: "${DROSYNC_APPLE_APPLICATION_IDENTITY:?set DROSYNC_APPLE_APPLICATION_IDENTITY from CI secrets}"
: "${DROSYNC_APPLE_INSTALLER_IDENTITY:?set DROSYNC_APPLE_INSTALLER_IDENTITY from CI secrets}"
: "${DROSYNC_APPLE_NOTARY_PROFILE:?set DROSYNC_APPLE_NOTARY_PROFILE from CI keychain}"
VERSION="${DROSYNC_VERSION:-1.0.0}"
OUTPUT_DIR="${DROSYNC_OUTPUT_DIR:-$ROOT_DIR/dist}"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
APP="$STAGE/Applications/drosync.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Library/LaunchServices" \
"$STAGE/Library/LaunchAgents" "$STAGE/Library/LaunchDaemons" "$STAGE/usr/local/bin" "$OUTPUT_DIR"
cp "$ROOT_DIR/packaging/macos/Info.plist" "$APP/Contents/Info.plist"
cp "$ROOT_DIR/target/release/drosync-gui" "$APP/Contents/MacOS/drosync-gui"
cp "$ROOT_DIR/target/release/drosync" "$APP/Contents/MacOS/drosync"
cp "$ROOT_DIR/target/release/drosync-daemon" "$APP/Contents/MacOS/drosync-daemon"
cp "$ROOT_DIR/packaging/macos/com.drobotics.drosync.agent.plist" "$STAGE/Library/LaunchAgents/"
cp "$ROOT_DIR/packaging/macos/com.drobotics.drosync.daemon.plist" "$STAGE/Library/LaunchDaemons/"
ln -s /Applications/drosync.app/Contents/MacOS/drosync "$STAGE/usr/local/bin/drosync"
for binary in drosync drosync-daemon drosync-gui; do
codesign --force --timestamp --options runtime --entitlements "$ROOT_DIR/packaging/macos/entitlements.plist" \
--sign "$DROSYNC_APPLE_APPLICATION_IDENTITY" "$APP/Contents/MacOS/$binary"
done
codesign --force --timestamp --options runtime --sign "$DROSYNC_APPLE_APPLICATION_IDENTITY" "$APP"
pkgbuild --root "$STAGE" --identifier com.drobotics.drosync --version "$VERSION" \
--install-location / --sign "$DROSYNC_APPLE_INSTALLER_IDENTITY" "$OUTPUT_DIR/drosync-${VERSION}-macos-arm64.pkg"
xcrun notarytool submit "$OUTPUT_DIR/drosync-${VERSION}-macos-arm64.pkg" --keychain-profile "$DROSYNC_APPLE_NOTARY_PROFILE" --wait
xcrun stapler staple "$OUTPUT_DIR/drosync-${VERSION}-macos-arm64.pkg"
spctl --assess --type install --verbose "$OUTPUT_DIR/drosync-${VERSION}-macos-arm64.pkg"