-
Notifications
You must be signed in to change notification settings - Fork 120
/
package_macos.sh
executable file
·77 lines (69 loc) · 1.54 KB
/
package_macos.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
#!/bin/sh
# submit a package to be notarized
# returns: notarization uuid
notary_submit() {
xcrun altool -f release/decrediton-${VERSION}.zip \
--notarize-app \
--primary-bundle-id org.Electron.Decrediton \
--asc-provider ${IDENTITY} \
-p @keychain:${KEYCHAIN} 2>&1 \
| perl -ne 'print if s/^RequestUUID = //'
}
# check notarization status after successful submission
# arg 1: uuid
# returns: altool output
notary_status() {
local _uuid=$1
xcrun altool --notarization-info ${_uuid} -p @keychain:${KEYCHAIN} 2>&1
}
[ $(uname) = Darwin ] || {
echo "$0 must be run from darwin" 2>&1
exit 1
}
[ $# = 3 ] || {
echo "usage: $0 version identity arch" 2>&1
exit 2
}
VERSION=$1
IDENTITY=$2
ARCH=$3
KEYCHAIN=${KEYCHAIN:-signer}
NODE_MODULES=node_modules
YARNCACHE=.yarncache
set -ex
[ -d ${NODE_MODULES} ] && rm -rf ${NODE_MODULES}
[ -d ${YARNCACHE} ] && rm -rf ${YARNCACHE}
mkdir -p ${YARNCACHE}
# prepare directory with package files
yarn install --cache-folder ${YARNCACHE}
yarn rebuild-natives
yarn package-mac-${ARCH}
# submit notarization
_uuid=$(notary_submit)
# poll notarization status until no longer in-progress
set +ex
while :; do
sleep 60
_date=$(date)
_output=$(notary_status ${_uuid})
_status=$(echo "${_output}" | perl -ne 'print if s/^\s*Status: //')
echo "check at ${_date}: Status: ${_status}"
case ${_status} in
"in progress")
continue
;;
"success")
# move on to stapling
break
;;
"")
echo "warn: unknown status -- full output:\n${_output}" 2>&1
continue
;;
*)
echo "${_output}" 2>&1
exit 1
;;
esac
done
set -ex