-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·71 lines (58 loc) · 2.36 KB
/
Copy pathpackage.sh
File metadata and controls
executable file
·71 lines (58 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Build and package BrowserRouter for distribution
set -eo pipefail
SCHEME="BrowserRouter"
DERIVED_DATA="$(mktemp -d)"
OUTPUT_DIR="$(pwd)/dist"
# Calculate build number: total commit count (monotonically increasing)
BUILD_NUMBER=$(git rev-list --count HEAD)
echo "🔢 Build number: ${BUILD_NUMBER}"
echo "🔨 Building ${SCHEME} (Release)..."
xcodebuild -scheme "$SCHEME" -configuration Release \
-destination 'generic/platform=macOS' \
-derivedDataPath "$DERIVED_DATA" \
ARCHS="arm64 x86_64" \
ONLY_ACTIVE_ARCH=NO \
CURRENT_PROJECT_VERSION="$BUILD_NUMBER" \
build 2>&1 | tail -5
APP_PATH="${DERIVED_DATA}/Build/Products/Release/${SCHEME}.app"
if [ ! -d "$APP_PATH" ]; then
echo "❌ Build failed — ${APP_PATH} not found"
rm -rf "$DERIVED_DATA"
exit 1
fi
# Remove quarantine and extended attributes
echo "🔓 Removing extended attributes..."
xattr -cr "$APP_PATH"
# Get version before cleanup
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${APP_PATH}/Contents/Info.plist" 2>/dev/null || echo "unknown")
echo "📦 Packaging..."
mkdir -p "$OUTPUT_DIR"
ZIP_PATH="${OUTPUT_DIR}/${SCHEME}.zip"
ditto -ck --keepParent "$APP_PATH" "$ZIP_PATH"
# Cleanup build artifacts
rm -rf "$DERIVED_DATA"
SIZE=$(du -h "$ZIP_PATH" | cut -f1)
# Sign update with Sparkle's sign_update tool (if available)
SPARKLE_SIGN="$(find "${HOME}/Library/Developer/Xcode/DerivedData" -path '*/SourcePackages/artifacts/sparkle/Sparkle/bin/sign_update' -print -quit 2>/dev/null || true)"
if [ -n "$SPARKLE_SIGN" ] && [ -x "$SPARKLE_SIGN" ]; then
echo "🔏 Signing update with Sparkle..."
SIGNATURE=$("$SPARKLE_SIGN" "$ZIP_PATH" 2>&1) || true
echo " Signature: ${SIGNATURE}"
else
echo "⚠️ Sparkle sign_update not found — skipping EdDSA signing"
echo " Build once in Xcode to fetch Sparkle artifacts, then re-run."
fi
# Generate SHA256 checksum
SHA256=$(shasum -a 256 "$ZIP_PATH" | awk '{print $1}')
echo "${SHA256} ${SCHEME}.zip" > "${OUTPUT_DIR}/SHA256.txt"
echo ""
echo "✅ Done!"
echo " Version: ${VERSION} (${BUILD_NUMBER})"
echo " Output: ${ZIP_PATH}"
echo " Size: ${SIZE}"
echo " SHA256: ${SHA256}"
echo ""
echo "📤 Upload to GitHub Releases or distribute directly."
echo " Users can install with:"
echo " ./install.sh or manually: unzip → drag to /Applications → xattr -cr /Applications/${SCHEME}.app"