Files
downterm/scripts/build-release-dmg.sh

64 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PROJECT_DIR="$APP_ROOT/CommandNotch"
if ! command -v xcodegen >/dev/null 2>&1; then
echo "error: xcodegen is required. Install it with: brew install xcodegen" >&2
exit 1
fi
if ! command -v create-dmg >/dev/null 2>&1; then
echo "error: create-dmg is required. Install it with: brew install create-dmg" >&2
exit 1
fi
timestamp="$(date '+%Y-%m-%d %H-%M-%S')"
release_dir="$APP_ROOT/releases/CommandNotch $timestamp"
archive_path="/tmp/CommandNotch-$timestamp.xcarchive"
staging_dir="$(mktemp -d)"
app_path="$release_dir/CommandNotch.app"
dmg_path="$release_dir/CommandNotch.dmg"
cleanup() {
rm -rf "$staging_dir"
}
trap cleanup EXIT
mkdir -p "$release_dir"
cd "$PROJECT_DIR"
xcodegen generate --spec project.yml
DEVELOPER_DIR="${DEVELOPER_DIR:-/Applications/Xcode.app/Contents/Developer}" \
xcodebuild archive \
-project CommandNotch.xcodeproj \
-scheme CommandNotch \
-configuration Release \
-destination 'generic/platform=macOS' \
-archivePath "$archive_path"
ditto "$archive_path/Products/Applications/CommandNotch.app" "$app_path"
ditto "$app_path" "$staging_dir/CommandNotch.app"
ln -s /Applications "$staging_dir/Applications"
create-dmg \
--volname "CommandNotch" \
--window-pos 200 120 \
--window-size 720 420 \
--icon-size 128 \
--icon "CommandNotch.app" 180 210 \
--icon "Applications" 540 210 \
--hide-extension "CommandNotch.app" \
--app-drop-link 540 210 \
"$dmg_path" \
"$staging_dir"
echo "Created:"
echo " $app_path"
echo " $dmg_path"