adds first version of the app
This commit is contained in:
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
# Usage: scripts/bundle.sh [--install] [--force]
|
||||
# --install copy "build/Plak.app" to ~/Applications
|
||||
# --force let --install replace an app that has a different bundle id
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/env.sh"
|
||||
|
||||
install=false
|
||||
force=false
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--install) install=true ;;
|
||||
--force) force=true ;;
|
||||
*) echo "unknown option: $arg" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
BUNDLE_ID=nl.blijnder.plak
|
||||
VERSION=0.1.0
|
||||
APP="build/Plak.app"
|
||||
|
||||
swift build -c release --product Plak
|
||||
BIN="$(swift build -c release --show-bin-path)"
|
||||
|
||||
rm -rf "$APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
cp "$BIN/Plak" "$APP/Contents/MacOS/Plak"
|
||||
|
||||
# SwiftPM resource bundles go in Contents/Resources: the .app root would break
|
||||
# the code signature.
|
||||
for bundle in "$BIN"/*.bundle; do
|
||||
[[ -e "$bundle" ]] || continue
|
||||
cp -R "$bundle" "$APP/Contents/Resources/"
|
||||
done
|
||||
|
||||
cat > "$APP/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>CFBundleExecutable</key><string>Plak</string>
|
||||
<key>CFBundleIdentifier</key><string>$BUNDLE_ID</string>
|
||||
<key>CFBundleName</key><string>Plak</string>
|
||||
<key>CFBundleDisplayName</key><string>Plak</string>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key><string>$VERSION</string>
|
||||
<key>CFBundleVersion</key><string>$VERSION</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
|
||||
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
||||
<key>LSApplicationCategoryType</key><string>public.app-category.productivity</string>
|
||||
<key>LSUIElement</key><true/>
|
||||
<key>NSHighResolutionCapable</key><true/>
|
||||
<key>NSPrincipalClass</key><string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
|
||||
codesign --force --deep -s - "$APP"
|
||||
codesign --verify --deep --strict "$APP"
|
||||
echo "built $APP"
|
||||
|
||||
if $install; then
|
||||
target="$HOME/Applications/Plak.app"
|
||||
if [[ -d "$target" ]]; then
|
||||
existing="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$target/Contents/Info.plist" 2>/dev/null || true)"
|
||||
if [[ "$existing" != "$BUNDLE_ID" && "$force" != true ]]; then
|
||||
echo "refusing to replace $target (bundle id '$existing'); pass --force to overwrite it" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$target"
|
||||
fi
|
||||
mkdir -p "$HOME/Applications"
|
||||
cp -R "$APP" "$target"
|
||||
echo "installed $target"
|
||||
fi
|
||||
Reference in New Issue
Block a user