-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·148 lines (130 loc) · 4.83 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·148 lines (130 loc) · 4.83 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
#!/usr/bin/env bash
# Archive, export, notarize, and package Parcel for public download.
#
# Required environment variables:
# DEVELOPMENT_TEAM — Apple Developer Team ID
# APPLE_ID — Apple ID for notarytool (optional when NOTARYTOOL_PROFILE is set)
# APPLE_APP_PASSWORD — app-specific password (optional when NOTARYTOOL_PROFILE is set)
# NOTARYTOOL_PROFILE — keychain profile for notarytool (optional alternative)
#
# Usage:
# DEVELOPMENT_TEAM=XXXXXXXXXX ./Scripts/release.sh
# SKIP_NOTARIZE=1 DEVELOPMENT_TEAM=XXXXXXXXXX ./Scripts/release.sh # local test build
# UPDATE_APPCAST=1 DEVELOPMENT_TEAM=XXXXXXXXXX ... ./Scripts/release.sh
# NOTARYTOOL_PROFILE=parcel-release DEVELOPMENT_TEAM=XXXXXXXXXX ./Scripts/release.sh
#
# Optional:
# RUN_RELEASE_PREFLIGHT=0 — skip external release-gate preflight
# VERIFY_RELEASE=0 — skip final Website/public/downloads/Parcel.zip verification
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
SCHEME="Parcel"
CONFIG="Release"
ARCHIVE_PATH="$ROOT/build/Parcel.xcarchive"
EXPORT_PATH="$ROOT/build/export"
APP_PATH="$EXPORT_PATH/Parcel.app"
ZIP_PATH="$ROOT/build/Parcel.zip"
WEBSITE_ZIP="$ROOT/Website/public/downloads/Parcel.zip"
if [[ -z "${RUN_RELEASE_PREFLIGHT+x}" ]]; then
if [[ "${SKIP_NOTARIZE:-}" == "1" ]]; then
RUN_RELEASE_PREFLIGHT=0
else
RUN_RELEASE_PREFLIGHT=1
fi
fi
if [[ -z "${VERIFY_RELEASE+x}" ]]; then
if [[ "${SKIP_NOTARIZE:-}" == "1" ]]; then
VERIFY_RELEASE=0
else
VERIFY_RELEASE=1
fi
fi
if [[ "$RUN_RELEASE_PREFLIGHT" == "1" ]]; then
echo "==> Verifying release gates"
"$ROOT/Scripts/verify-release-gates.sh"
else
echo "==> Skipping release gate preflight (RUN_RELEASE_PREFLIGHT=0)"
fi
if [[ -z "${DEVELOPMENT_TEAM:-}" ]]; then
echo "Set DEVELOPMENT_TEAM to your Apple Developer Team ID." >&2
exit 1
fi
echo "==> Generating Xcode project"
xcodegen generate
echo "==> Resolving Swift packages"
xcodebuild -resolvePackageDependencies -project Parcel.xcodeproj -scheme "$SCHEME"
echo "==> Archiving ($CONFIG)"
xcodebuild archive \
-project Parcel.xcodeproj \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
-archivePath "$ARCHIVE_PATH" \
-destination "generic/platform=macOS" \
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
CODE_SIGN_STYLE=Automatic \
CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO
EXPORT_OPTS="$ROOT/build/ExportOptions.plist"
sed "s/\$(DEVELOPMENT_TEAM)/$DEVELOPMENT_TEAM/g" "$ROOT/Scripts/ExportOptions.plist" > "$EXPORT_OPTS"
echo "==> Exporting Developer ID build"
rm -rf "$EXPORT_PATH"
xcodebuild -exportArchive \
-archivePath "$ARCHIVE_PATH" \
-exportPath "$EXPORT_PATH" \
-exportOptionsPlist "$EXPORT_OPTS"
echo "==> Verifying code signature + entitlements"
codesign --verify --deep --strict "$APP_PATH"
if codesign -d --entitlements :- "$APP_PATH" 2>/dev/null | grep -q "get-task-allow"; then
echo "ERROR: Release app still has get-task-allow — refusing to package." >&2
exit 1
fi
if ! codesign -d --entitlements :- "$APP_PATH" 2>/dev/null | grep -q "network.client"; then
echo "ERROR: Release app missing network.client (Sparkle/upload will fail in sandbox)." >&2
exit 1
fi
PUBKEY="$(/usr/libexec/PlistBuddy -c 'Print :SUPublicEDKey' "$APP_PATH/Contents/Info.plist" 2>/dev/null || true)"
if [[ -z "$PUBKEY" || "$PUBKEY" == *REPLACE_WITH* ]]; then
echo "ERROR: SUPublicEDKey is missing or still a placeholder." >&2
exit 1
fi
echo " SUPublicEDKey OK ($PUBKEY)"
echo "==> Creating zip"
rm -f "$ZIP_PATH"
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
if [[ "${SKIP_NOTARIZE:-}" != "1" ]]; then
if [[ -n "${NOTARYTOOL_PROFILE:-}" ]]; then
echo "==> Submitting for notarization with keychain profile"
xcrun notarytool submit "$ZIP_PATH" \
--keychain-profile "$NOTARYTOOL_PROFILE" \
--wait
elif [[ -n "${APPLE_ID:-}" && -n "${APPLE_APP_PASSWORD:-}" ]]; then
echo "==> Submitting for notarization with Apple ID credentials"
xcrun notarytool submit "$ZIP_PATH" \
--apple-id "$APPLE_ID" \
--password "$APPLE_APP_PASSWORD" \
--team-id "$DEVELOPMENT_TEAM" \
--wait
else
echo "Set NOTARYTOOL_PROFILE or APPLE_ID and APPLE_APP_PASSWORD to notarize, or SKIP_NOTARIZE=1." >&2
exit 1
fi
echo "==> Stapling ticket"
xcrun stapler staple "$APP_PATH"
rm -f "$ZIP_PATH"
ditto -c -k --keepParent "$APP_PATH" "$ZIP_PATH"
fi
mkdir -p "$(dirname "$WEBSITE_ZIP")"
cp "$ZIP_PATH" "$WEBSITE_ZIP"
if [[ "${UPDATE_APPCAST:-}" == "1" ]]; then
echo "==> Updating Sparkle appcast"
"$ROOT/Scripts/update-appcast.sh" "$WEBSITE_ZIP"
fi
if [[ "$VERIFY_RELEASE" == "1" ]]; then
echo "==> Verifying public website ZIP"
"$ROOT/Scripts/verify-release.sh" "$WEBSITE_ZIP"
else
echo "==> Skipping final public ZIP verification (VERIFY_RELEASE=0)"
fi
echo "==> Done: $ZIP_PATH"
echo " Website artifact: $WEBSITE_ZIP"
echo "Next: deploy the website after final QA sign-off."