This commit is contained in:
Mark Gregory
2026-10-23 07:52:57 +01:00
parent 46bd60d497
commit 9bca20cf60
11 changed files with 1115 additions and 1200 deletions
-200
View File
@@ -1,200 +0,0 @@
#!/bin/bash
set -euo pipefail
APP_NAME="OrionToolbar"
SCHEME="OrionToolbar"
PROJECT="OrionToolbar.xcodeproj"
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
BUILD_DIR="$ROOT_DIR/.build"
LOG_DIR="$ROOT_DIR/build-logs"
CONFIGURATION="Release"
LAUNCH=false
RUN_TESTS=true
for arg in "$@"; do
case "$arg" in
--launch)
LAUNCH=true
;;
--no-tests)
RUN_TESTS=false
;;
*)
echo "Unknown argument: $arg"
echo "Usage: $0 [--launch] [--no-tests]"
exit 2
;;
esac
done
mkdir -p "$BUILD_DIR" "$LOG_DIR"
LOG_FILE="$LOG_DIR/build-test-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee -a "$LOG_FILE") 2>&1
echo
echo "============================================================"
echo " ORION TOOLBAR - RELEASE BUILD AND TEST"
echo "============================================================"
echo
cd "$ROOT_DIR"
echo "==> Environment"
xcodebuild -version
swift --version
echo
echo "==> Checking project"
test -d "$PROJECT" || {
echo "ERROR: Xcode project not found."
exit 1
}
echo
echo "==> Checking Parallels"
PRLCTL=""
for candidate in \
/usr/local/bin/prlctl \
"/Applications/Parallels Desktop.app/Contents/MacOS/prlctl"
do
if [ -x "$candidate" ]; then
PRLCTL="$candidate"
break
fi
done
if [ -n "$PRLCTL" ]; then
echo "Parallels CLI: $PRLCTL"
echo
echo "==> Discovering virtual machines"
"$PRLCTL" list -a -j | python3 -c '
import json
import sys
machines = json.load(sys.stdin)
print(f"Discovered {len(machines)} virtual machines")
print()
for machine in machines:
print(
f"{machine.get('name', 'Unknown'):<35} "
f"{machine.get('status', 'unknown'):<12} "
f"{machine.get('uuid', '')}"
)
'
else
echo "WARNING: Parallels CLI not found."
fi
echo
echo "==> Building Release configuration"
xcodebuild \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-destination "generic/platform=macOS" \
-derivedDataPath "$BUILD_DIR" \
CODE_SIGNING_ALLOWED=NO \
clean build
APP_PATH="$BUILD_DIR/Build/Products/$CONFIGURATION/$APP_NAME.app"
if [ ! -d "$APP_PATH" ]; then
echo "ERROR: Built application not found."
exit 1
fi
echo
echo "==> Validating application bundle"
plutil -lint "$APP_PATH/Contents/Info.plist"
echo
echo "==> Application information"
defaults read "$APP_PATH/Contents/Info" \
CFBundleIdentifier || true
defaults read "$APP_PATH/Contents/Info" \
CFBundleShortVersionString || true
defaults read "$APP_PATH/Contents/Info" \
CFBundleVersion || true
echo
echo "==> Checking executable"
EXECUTABLE=$(
/usr/libexec/PlistBuddy \
-c "Print CFBundleExecutable" \
"$APP_PATH/Contents/Info.plist"
)
test -x "$APP_PATH/Contents/MacOS/$EXECUTABLE"
file "$APP_PATH/Contents/MacOS/$EXECUTABLE"
echo
echo "==> Checking available test targets"
if [ "$RUN_TESTS" = true ]; then
TEST_OUTPUT="$LOG_DIR/test-targets.txt"
xcodebuild \
-list \
-project "$PROJECT" > "$TEST_OUTPUT"
if grep -Eq '^[[:space:]]+.*Tests$' "$TEST_OUTPUT"; then
echo "Test targets detected."
xcodebuild \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-destination "platform=macOS" \
-derivedDataPath "$BUILD_DIR" \
CODE_SIGNING_ALLOWED=NO \
test
else
echo "No test targets detected; skipping XCTest."
fi
fi
echo
echo "==> Build size"
du -sh "$APP_PATH"
if [ "$LAUNCH" = true ]; then
echo
echo "==> Launching OrionToolbar"
open "$APP_PATH"
fi
echo
echo "============================================================"
echo " BUILD AND TEST COMPLETE"
echo "============================================================"
echo
echo "Application:"
echo "$APP_PATH"
echo
echo "Log:"
echo "$LOG_FILE"
echo
+24
View File
@@ -0,0 +1,24 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
APP_NAME=OrionToolbar
DERIVED="$ROOT/.build"
CONFIGURATION="${CONFIGURATION:-Debug}"
[[ "$CONFIGURATION" == Debug || "$CONFIGURATION" == Release ]] || { echo 'CONFIGURATION must be Debug or Release' >&2; exit 2; }
mkdir -p "$ROOT/build-logs"
LOG="$ROOT/build-logs/build-${CONFIGURATION}-$(date +%Y%m%d-%H%M%S).log"
echo "Building $APP_NAME ($CONFIGURATION)"
set -o pipefail
xcodebuild -project "$ROOT/OrionToolbar.xcodeproj" -scheme "$APP_NAME" -configuration "$CONFIGURATION" -derivedDataPath "$DERIVED" CODE_SIGNING_ALLOWED=NO build 2>&1 | tee "$LOG"
APP="$DERIVED/Build/Products/$CONFIGURATION/$APP_NAME.app"
[[ -d "$APP" ]] || { echo "Missing application: $APP" >&2; exit 1; }
plutil -lint "$APP/Contents/Info.plist"
EXE=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$APP/Contents/Info.plist")
[[ -x "$APP/Contents/MacOS/$EXE" ]] || { echo 'Application executable missing' >&2; exit 1; }
echo "Build complete: $APP"
echo "Log: $LOG"
if [[ "${1:-}" == '--launch' ]]; then
pkill -x "$APP_NAME" 2>/dev/null || true
open "$APP"
fi
+65 -316
View File
@@ -1,318 +1,67 @@
#!/bin/bash
#!/bin/zsh
set -euo pipefail
# ============================================================
# OrionToolbar - Developer ID Release
# ============================================================
APP_NAME="OrionToolbar"
SCHEME="OrionToolbar"
PROJECT="OrionToolbar.xcodeproj"
SIGNING_IDENTITY="B99D353C88996866C49E4389B375645F76870A3F"
TEAM_ID="39R6U3437D"
NOTARY_PROFILE="orion-notary"
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
BUILD_DIR="$ROOT_DIR/build"
LOG_DIR="$ROOT_DIR/build-logs"
ARCHIVE_PATH="$BUILD_DIR/$APP_NAME.xcarchive"
EXPORT_DIR="$BUILD_DIR/export"
DMG_STAGE="$BUILD_DIR/dmg"
DMG_PATH="$ROOT_DIR/$APP_NAME.dmg"
EXPORT_OPTIONS="$BUILD_DIR/ExportOptions.plist"
mkdir -p "$LOG_DIR"
LOG_FILE="$LOG_DIR/release-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee -a "$LOG_FILE") 2>&1
echo
echo "============================================================"
echo " ORION TOOLBAR - DIRECT DISTRIBUTION"
echo "============================================================"
echo
cd "$ROOT_DIR"
# ------------------------------------------------------------
# Prerequisites
# ------------------------------------------------------------
echo "==> Checking signing identity"
security find-identity -v -p codesigning
if ! security find-identity -v -p codesigning | \
grep -q "$SIGNING_IDENTITY"; then
echo "ERROR: Developer ID signing identity unavailable."
exit 1
fi
echo
echo "==> Checking notarization profile"
xcrun notarytool history \
--keychain-profile "$NOTARY_PROFILE" \
>/dev/null
echo "Notarization profile available."
# ------------------------------------------------------------
# Clean
# ------------------------------------------------------------
echo
echo "==> Cleaning previous release"
rm -rf "$BUILD_DIR"
rm -f "$DMG_PATH"
mkdir -p \
"$BUILD_DIR" \
"$EXPORT_DIR" \
"$DMG_STAGE"
# ------------------------------------------------------------
# Export options
# ------------------------------------------------------------
cat > "$EXPORT_OPTIONS" <<EOF
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
APP_NAME=OrionToolbar
PROJECT="$ROOT/OrionToolbar.xcodeproj"
DERIVED="$ROOT/.build"
WORK="$ROOT/.build/release"
DIST="$ROOT/dist"
SIGNING_IDENTITY="${SIGNING_IDENTITY:-B99D353C88996866C49E4389B375645F76870A3F}"
TEAM_ID="${TEAM_ID:-39R6U3437D}"
NOTARY_PROFILE="${NOTARY_PROFILE:-orion-notary}"
mkdir -p "$ROOT/build-logs" "$DIST"
LOG="$ROOT/build-logs/release-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee "$LOG") 2>&1
command -v xcodebuild >/dev/null
command -v hdiutil >/dev/null
security find-identity -v -p codesigning | grep -q "$SIGNING_IDENTITY" || { echo 'Developer ID identity missing' >&2; exit 1; }
xcrun notarytool history --keychain-profile "$NOTARY_PROFILE" >/dev/null
rm -rf "$WORK"
mkdir -p "$WORK/export" "$WORK/dmg"
cat > "$WORK/ExportOptions.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>method</key>
<string>developer-id</string>
<key>signingStyle</key>
<string>automatic</string>
<key>teamID</key>
<string>$TEAM_ID</string>
</dict>
</plist>
EOF
# ------------------------------------------------------------
# Archive
# ------------------------------------------------------------
echo
echo "==> Creating Release archive"
xcodebuild \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration Release \
-destination "generic/platform=macOS" \
-archivePath "$ARCHIVE_PATH" \
clean archive
echo
echo "==> Archive created"
# ------------------------------------------------------------
# Export
# ------------------------------------------------------------
echo
echo "==> Exporting Developer ID application"
xcodebuild \
-exportArchive \
-archivePath "$ARCHIVE_PATH" \
-exportPath "$EXPORT_DIR" \
-exportOptionsPlist "$EXPORT_OPTIONS"
APP_PATH="$EXPORT_DIR/$APP_NAME.app"
if [ ! -d "$APP_PATH" ]; then
echo "ERROR: Exported application not found."
exit 1
fi
# ------------------------------------------------------------
# Verify signature
# ------------------------------------------------------------
echo
echo "==> Verifying application signature"
codesign \
--verify \
--deep \
--strict \
--verbose=2 \
"$APP_PATH"
echo
echo "==> Checking signing team"
ACTUAL_TEAM=$(
codesign -dv --verbose=4 "$APP_PATH" 2>&1 |
sed -n 's/^TeamIdentifier=//p'
)
if [ "$ACTUAL_TEAM" != "$TEAM_ID" ]; then
echo "ERROR: Incorrect signing team: $ACTUAL_TEAM"
exit 1
fi
echo "Signing team verified: $ACTUAL_TEAM"
# ------------------------------------------------------------
# Notarize application
# ------------------------------------------------------------
echo
echo "==> Creating notarization ZIP"
APP_ZIP="$BUILD_DIR/$APP_NAME.zip"
ditto \
-c \
-k \
--keepParent \
"$APP_PATH" \
"$APP_ZIP"
echo
echo "==> Notarizing application"
xcrun notarytool submit \
"$APP_ZIP" \
--keychain-profile "$NOTARY_PROFILE" \
--wait
echo
echo "==> Stapling application"
xcrun stapler staple "$APP_PATH"
echo
echo "==> Validating application ticket"
xcrun stapler validate "$APP_PATH"
echo
echo "==> Gatekeeper application verification"
spctl \
--assess \
--type execute \
--verbose=4 \
"$APP_PATH"
# ------------------------------------------------------------
# Prepare DMG
# ------------------------------------------------------------
echo
echo "==> Preparing DMG"
rm -rf "$DMG_STAGE"
mkdir -p "$DMG_STAGE"
ditto "$APP_PATH" "$DMG_STAGE/$APP_NAME.app"
ln -s /Applications "$DMG_STAGE/Applications"
# ------------------------------------------------------------
# Create DMG
# ------------------------------------------------------------
echo
echo "==> Creating DMG"
hdiutil create \
-volname "$APP_NAME" \
-srcfolder "$DMG_STAGE" \
-ov \
-format UDZO \
"$DMG_PATH"
# ------------------------------------------------------------
# Sign DMG
# ------------------------------------------------------------
echo
echo "==> Signing DMG"
codesign \
--force \
--timestamp \
--sign "$SIGNING_IDENTITY" \
"$DMG_PATH"
echo
echo "==> Verifying DMG signature"
codesign \
--verify \
--verbose=2 \
"$DMG_PATH"
# ------------------------------------------------------------
# Notarize DMG
# ------------------------------------------------------------
echo
echo "==> Notarizing DMG"
xcrun notarytool submit \
"$DMG_PATH" \
--keychain-profile "$NOTARY_PROFILE" \
--wait
echo
echo "==> Stapling DMG"
xcrun stapler staple "$DMG_PATH"
echo
echo "==> Validating DMG ticket"
xcrun stapler validate "$DMG_PATH"
# ------------------------------------------------------------
# Final verification
# ------------------------------------------------------------
echo
echo "==> Final Gatekeeper verification"
spctl \
--assess \
--type open \
--context context:primary-signature \
--verbose=4 \
"$DMG_PATH"
echo
echo "==> Final DMG information"
ls -lh "$DMG_PATH"
echo
echo "==> SHA-256"
shasum -a 256 "$DMG_PATH"
echo
echo "============================================================"
echo " RELEASE BUILD COMPLETE"
echo "============================================================"
echo
echo "DMG:"
echo "$DMG_PATH"
echo
echo "Build log:"
echo "$LOG_FILE"
echo
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>method</key><string>developer-id</string>
<key>signingStyle</key><string>automatic</string>
<key>teamID</key><string>$TEAM_ID</string>
</dict></plist>
PLIST
xcodebuild -project "$PROJECT" -scheme "$APP_NAME" -configuration Release -destination 'generic/platform=macOS' -archivePath "$WORK/$APP_NAME.xcarchive" archive
xcodebuild -exportArchive -archivePath "$WORK/$APP_NAME.xcarchive" -exportPath "$WORK/export" -exportOptionsPlist "$WORK/ExportOptions.plist"
APP="$WORK/export/$APP_NAME.app"
[[ -d "$APP" ]] || { echo 'Exported app missing' >&2; exit 1; }
codesign --verify --deep --strict --verbose=2 "$APP"
ACTUAL_TEAM=$(codesign -dv --verbose=4 "$APP" 2>&1 | sed -n 's/^TeamIdentifier=//p')
[[ "$ACTUAL_TEAM" == "$TEAM_ID" ]] || { echo "Unexpected team: $ACTUAL_TEAM" >&2; exit 1; }
VERSION=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")
[[ -n "$VERSION" ]] || { echo 'Missing marketing version' >&2; exit 1; }
DMG="$DIST/$APP_NAME-$VERSION.dmg"
ZIP="$WORK/$APP_NAME.zip"
ditto -c -k --keepParent "$APP" "$ZIP"
notarize() {
local file="$1" result status
result=$(xcrun notarytool submit "$file" --keychain-profile "$NOTARY_PROFILE" --wait --output-format json)
echo "$result"
status=$(printf '%s' "$result" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("status", ""))')
[[ "$status" == Accepted ]] || { echo "Notarization not accepted for $file: $status" >&2; exit 1; }
}
notarize "$ZIP"
xcrun stapler staple "$APP"
xcrun stapler validate "$APP"
spctl --assess --type execute --verbose=4 "$APP"
ditto "$APP" "$WORK/dmg/$APP_NAME.app"
ln -s /Applications "$WORK/dmg/Applications"
rm -f "$DMG"
hdiutil create -volname "$APP_NAME" -srcfolder "$WORK/dmg" -ov -format UDZO "$DMG"
codesign --force --timestamp --sign "$SIGNING_IDENTITY" "$DMG"
codesign --verify --verbose=2 "$DMG"
notarize "$DMG"
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
spctl --assess --type open --context context:primary-signature --verbose=4 "$DMG"
shasum -a 256 "$DMG" | tee "$DMG.sha256"
echo "Release complete: $DMG"
echo "Checksum: $DMG.sha256"
echo "Log: $LOG"
+41
View File
@@ -0,0 +1,41 @@
#!/bin/zsh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
mkdir -p "$ROOT/build-logs"
LOG="$ROOT/build-logs/test-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee "$LOG") 2>&1
print '=== OrionToolbar tests ==='
# A successful compile is the minimum regression check.
"$ROOT/Scripts/build.sh"
APP="$ROOT/.build/Build/Products/Debug/OrionToolbar.app"
plutil -lint "$APP/Contents/Info.plist"
# Verify that the Parallels executable and JSON discovery work independently of SwiftUI.
PRLCTL=''
for candidate in /usr/local/bin/prlctl '/Applications/Parallels Desktop.app/Contents/MacOS/prlctl'; do
if [[ -x "$candidate" ]]; then PRLCTL="$candidate"; break; fi
done
if [[ -n "$PRLCTL" ]]; then
"$PRLCTL" list -a -j | python3 -c '
import json,sys
v=json.load(sys.stdin)
assert isinstance(v,list), "Expected Parallels JSON array"
for item in v:
assert isinstance(item,dict), "Invalid VM record"
assert item.get("name"), "VM without name"
assert item.get("uuid"), "VM without UUID"
print("Parallels discovery OK: {} VM(s)".format(len(v)))
'
else
echo 'SKIP: Parallels CLI not installed'
fi
if [[ -d "$ROOT/tests" ]] && find "$ROOT/tests" -name 'test_*.py' -print -quit | grep -q .; then
python3 -m unittest discover -s "$ROOT/tests" -v
fi
# Run Xcode tests only if a test plan is configured for this scheme.
if [[ "${RUN_XCODE_TESTS:-0}" == 1 ]]; then
xcodebuild -project "$ROOT/OrionToolbar.xcodeproj" -scheme OrionToolbar -configuration Debug -destination 'platform=macOS' -derivedDataPath "$ROOT/.build" CODE_SIGNING_ALLOWED=NO test
else
echo 'XCTest not run (set RUN_XCODE_TESTS=1 if the scheme has a test target).'
fi
print "Tests complete. Log: $LOG"