forked from atomex-me/atomex.client.desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_osx.sh
executable file
·130 lines (103 loc) · 4.19 KB
/
build_osx.sh
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
#!/bin/bash
BASE_DIR=$PWD
DIST_FOLDER="dist"
APP_NAME="$DIST_FOLDER/Atomex.app"
ZIP_PATH="$DIST_FOLDER/Atomex.zip"
PUBLISH_OUTPUT_DIRECTORY="bin/Release/net5.0/osx-x64/publish/."
INFO_PLIST="Info.plist"
ICON_FILE="logo.icns"
dotnet clean -c Release
dotnet restore
dotnet publish Atomex.Client.Desktop.csproj -r osx-x64 --configuration Release
dotnet tool install --global NetSparkleUpdater.Tools.AppCastGenerator --version 2.0.6
rm -rf "$BASE_DIR/$DIST_FOLDER"
mkdir "$BASE_DIR/$DIST_FOLDER"
mkdir -p "$BASE_DIR/$APP_NAME"
mkdir "$BASE_DIR/$APP_NAME/Contents"
mkdir "$BASE_DIR/$APP_NAME/Contents/MacOS"
mkdir "$BASE_DIR/$APP_NAME/Contents/Resources"
envsubst < $INFO_PLIST > "$BASE_DIR/$APP_NAME/Contents/$INFO_PLIST"
cp "$BASE_DIR/$ICON_FILE" "$BASE_DIR/$APP_NAME/Contents/Resources/$ICON_FILE"
cp -a "$BASE_DIR/$PUBLISH_OUTPUT_DIRECTORY" "$BASE_DIR/$APP_NAME/Contents/MacOS"
echo "[INFO] Signing Code"
ENTITLEMENTS="AtomexEntitlements.entitlements"
SIGNING_IDENTITY="Developer ID Application: ATOMEX OU (BJT6S7XYJV)" # matches Keychain Access certificate name
find "$APP_NAME/Contents/MacOS/"|while read fname; do
if [[ -f $fname ]]; then
echo "[INFO] Signing $fname"
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$fname"
fi
done
echo "[INFO] Signing app file"
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_NAME"
echo "[INFO] Creating ZIP Archive"
rm -f "$BASE_DIR/$ZIP_PATH"
/usr/bin/ditto -c -k --sequesterRsrc --keepParent "$APP_NAME" "$ZIP_PATH"
dev_account="[email protected]"
password="$1"
identifier="com.atomex.osx"
# functions
request_status() { # $1: requestUUID
requestUUID=${1?:"need a request UUID"}
req_status=$(xcrun altool --notarization-info "$requestUUID" \
--username "$dev_account" \
--password "$password" 2>&1 \
| awk -F ': ' '/Status:/ { print $2; }' )
echo "$req_status"
}
notarize_file() { # $1: path to file to notarize, $2: identifier
filepath=${1:?"need a filepath"}
identifier=${2:?"need an identifier"}
# upload file
echo "## uploading $filepath for notarization"
requestUUID=$(xcrun altool --notarize-app \
--primary-bundle-id "$identifier" \
--username "$dev_account" \
--password "$password" \
--file "$filepath" 2>&1 \
| awk '/RequestUUID/ { print $NF; }')
echo "Notarization RequestUUID: $requestUUID"
if [[ $requestUUID == "" ]]; then
echo "could not upload for notarization"
exit 1
fi
# wait for status to be not "in progress" any more
request_status="in progress"
while [[ "$request_status" == "in progress" ]]; do
echo -n "waiting... "
sleep 10
request_status=$(request_status "$requestUUID")
echo "$request_status"
done
# print status information
xcrun altool --notarization-info "$requestUUID" \
--username "$dev_account" \
--password "$password"
echo
if [[ $request_status != "success" ]]; then
echo "## could not notarize $filepath"
exit 1
fi
}
# upload for notarization
notarize_file "$ZIP_PATH" "$identifier"
# staple result
echo "## Stapling $APP_NAME"
xcrun stapler staple "$APP_NAME"
echo "## creating and notarizing DMG"
create-dmg "$APP_NAME" "$DIST_FOLDER"
dmg_file_name=$(find "$DIST_FOLDER" -type f -name "*.dmg")
#notarize_file "$dmg_file_name" "$identifier"
echo "## Stapling $dmg_file_name"
xcrun stapler staple "$dmg_file_name"
export PUB_DATE=$(date -u +"%a, %d %b %Y %T GMT")
export DESCRIPTION="Atomex release ${VER} ${PUB_DATE}"
export SIGNATURE=$(netsparkle-generate-appcast --generate-signature ${ZIP_PATH} | awk '{print $2}')
export ZIP_SIZE=$(ls -la ${ZIP_PATH} | awk '{print $5}')
# todo: remove appcast xml while all clients updated
envsubst < appcast_osx.xml > $DIST_FOLDER/appcast.xml
envsubst < appcast_osx.xml > $DIST_FOLDER/appcast_osx.xml
echo "## ZIP SIGNATURE: ${SIGNATURE}"
echo "## ZIP SIZE: ${ZIP_SIZE}"
rm -rf "$APP_NAME"
echo '## Done!'