65 lines
1.8 KiB
Bash
65 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
APP_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
WORKSPACE_ROOT="$(cd "$APP_ROOT/../../.." && pwd)"
|
|
|
|
CONFIGURATION="${CONFIGURATION:-release}"
|
|
APP_NAME="AIWorkspace"
|
|
BUILD_DIR="$APP_ROOT/.build/$CONFIGURATION"
|
|
OUTPUT_DIR="$APP_ROOT/dist"
|
|
APP_BUNDLE="$OUTPUT_DIR/$APP_NAME.app"
|
|
INSTALL_DIR="${INSTALL_DIR:-$HOME/Applications}"
|
|
|
|
INSTALL=0
|
|
if [[ "${1:-}" == "--install" ]]; then
|
|
INSTALL=1
|
|
fi
|
|
|
|
swift build --package-path "$APP_ROOT" -c "$CONFIGURATION"
|
|
|
|
rm -rf "$APP_BUNDLE"
|
|
mkdir -p "$APP_BUNDLE/Contents/MacOS" "$APP_BUNDLE/Contents/Resources"
|
|
cp "$BUILD_DIR/$APP_NAME" "$APP_BUNDLE/Contents/MacOS/$APP_NAME"
|
|
|
|
cat > "$APP_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>CFBundleDevelopmentRegion</key>
|
|
<string>en</string>
|
|
<key>CFBundleExecutable</key>
|
|
<string>$APP_NAME</string>
|
|
<key>CFBundleIdentifier</key>
|
|
<string>com.aiworkspace.menu</string>
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
<string>6.0</string>
|
|
<key>CFBundleName</key>
|
|
<string>AI Workspace</string>
|
|
<key>CFBundlePackageType</key>
|
|
<string>APPL</string>
|
|
<key>CFBundleShortVersionString</key>
|
|
<string>0.1.0</string>
|
|
<key>CFBundleVersion</key>
|
|
<string>1</string>
|
|
<key>LSMinimumSystemVersion</key>
|
|
<string>13.0</string>
|
|
<key>LSUIElement</key>
|
|
<true/>
|
|
<key>NSHumanReadableCopyright</key>
|
|
<string>Local AI Workspace utility.</string>
|
|
</dict>
|
|
</plist>
|
|
PLIST
|
|
|
|
echo "Built $APP_BUNDLE"
|
|
|
|
if [[ "$INSTALL" == "1" ]]; then
|
|
mkdir -p "$INSTALL_DIR"
|
|
rm -rf "$INSTALL_DIR/$APP_NAME.app"
|
|
cp -R "$APP_BUNDLE" "$INSTALL_DIR/$APP_NAME.app"
|
|
echo "Installed $INSTALL_DIR/$APP_NAME.app"
|
|
fi
|