This repository was archived by the owner on Nov 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild-and-notarize.sh
More file actions
executable file
·184 lines (152 loc) · 4.65 KB
/
build-and-notarize.sh
File metadata and controls
executable file
·184 lines (152 loc) · 4.65 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
# build-and-notarize.sh - Combined script to build, sign, and notarize the CodeLooper Mac app
# This script provides a single command to go from source code to notarized app
set -euo pipefail
# Get script directory and ensure we're in the right location
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
cd "$SCRIPT_DIR" || { echo "Error: Failed to change directory to $SCRIPT_DIR"; exit 1; }
# Log helper functions with timestamp
log() {
echo "[$(date "+%Y-%m-%d %H:%M:%S")] $1"
}
error() {
log "❌ ERROR: $1"
return 1
}
warning() {
log "⚠️ WARNING: $1"
}
success() {
log "✅ $1"
}
# Process command line arguments
SKIP_BUILD=false
SKIP_NOTARIZE=false
VERBOSE=false
SHOW_HELP=false
SIGN_IDENTITY=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--skip-build)
SKIP_BUILD=true
shift
;;
--skip-notarize)
SKIP_NOTARIZE=true
shift
;;
--identity)
SIGN_IDENTITY="$2"
shift 2
;;
--verbose)
VERBOSE=true
shift
;;
--help)
SHOW_HELP=true
shift
;;
*)
warning "Unknown option: $1"
SHOW_HELP=true
shift
;;
esac
done
# Show help if requested
if [ "$SHOW_HELP" = true ]; then
cat << EOF
CodeLooper Mac App Build and Notarization Script
Usage: $(basename "$0") [options]
Options:
--skip-build Skip the build step (use existing binary)
--skip-notarize Skip the notarization step
--identity STRING Use specific signing identity (defaults to environment APPLE_IDENTITY)
--verbose Enable verbose output
--help Show this help message
Environment Variables (can be used instead of command line arguments):
APPLE_ID Apple ID email for notarization
APPLE_PASSWORD App-specific password for the Apple ID
APPLE_TEAM_ID Apple Developer Team ID
APPLE_IDENTITY Developer ID certificate to use for signing
Example:
./build-and-notarize.sh
./build-and-notarize.sh --skip-build --identity "Developer ID Application: Your Name (TEAM_ID)"
Environment file:
You can also provide these variables in a .env.notarize file in the mac directory
EOF
exit 0
fi
# Track start time for reporting
START_TIME=$(date +%s)
log "Starting CodeLooper Mac app build and notarization process..."
# Set identity if provided
if [ -n "$SIGN_IDENTITY" ]; then
export APPLE_IDENTITY="$SIGN_IDENTITY"
log "Using signing identity: $SIGN_IDENTITY"
fi
# Step 1: Build the app
if [ "$SKIP_BUILD" = false ]; then
log "Building CodeLooper Mac app..."
if [ "$VERBOSE" = true ]; then
./build.sh
else
./build.sh > /dev/null
fi
if [ $? -ne 0 ]; then
error "Build failed. Please check the build output for errors."
exit 1
fi
success "Build completed successfully"
else
log "Skipping build step as requested"
fi
# Step 2: Code sign the app
log "Code signing the app with hardened runtime..."
CODESIGN_ARGS=""
if [ "$VERBOSE" = true ]; then
CODESIGN_ARGS="--verbose"
fi
if [ -n "${APPLE_IDENTITY:-}" ]; then
CODESIGN_ARGS="$CODESIGN_ARGS --identity \"$APPLE_IDENTITY\""
fi
CODESIGN_CMD="./scripts/codesign-app.sh $CODESIGN_ARGS"
if ! eval "$CODESIGN_CMD"; then
error "Code signing failed. Please check the output for errors."
exit 1
fi
success "Code signing completed successfully"
# Step 3: Notarize the app (if not skipped)
if [ "$SKIP_NOTARIZE" = false ]; then
log "Notarizing the app..."
# Build notarization arguments
NOTARIZE_ARGS=""
# Add any additional arguments for notarization
if [ "$VERBOSE" = true ]; then
NOTARIZE_ARGS="$NOTARIZE_ARGS --verbose"
fi
if [ -n "${APPLE_IDENTITY:-}" ]; then
NOTARIZE_ARGS="$NOTARIZE_ARGS --sign-identity \"$APPLE_IDENTITY\""
fi
# Run the notarization script with the built arguments
if ! ./scripts/notarize-mac.sh $NOTARIZE_ARGS; then
error "Notarization failed. Please check the output for errors."
exit 1
fi
success "Notarization completed successfully"
else
log "Skipping notarization step as requested"
fi
# Calculate and show elapsed time
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
MINUTES=$((ELAPSED / 60))
SECONDS=$((ELAPSED % 60))
success "Build and notarization process completed in ${MINUTES}m ${SECONDS}s"
log "Summary:"
log "- App bundle: binary/CodeLooper.app"
log "- Distributable ZIP: binary/CodeLooper-notarized.zip"
log ""
log "The app is now ready for distribution!"