forked from kasper/phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·152 lines (102 loc) · 2.83 KB
/
release
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
#!/bin/bash
app='Phoenix'
# Exit on error
trap 'exit' ERR
# Unset arguments
unset code_sign_identity
unset dsa_signature_key_path
unset output_directory
# Helpers
help() {
echo -e >&2 "\
\033[1mUsage:\033[0m $(basename $0) -s code-sign-identity -d dsa-signature-key-path -o output-directory
Arguments:
-s code-sign-identity used to sign the app
-d dsa-signature-key-path used to create the DSA-signature
-o output-directory where the app archive is created"
}
missing_argument() {
echo >&2 "Option -$1 requires an argument."
}
non_existent_path() {
echo >&2 "Path “$1” does not exist."
}
describe() {
echo -e "\n\033[1m\033[34m$1\033[0m\n"
}
get_app_property() {
/usr/libexec/PlistBuddy -c "Print $1" $app/Info.plist
}
# Parse arguments
while getopts ':s:d:o:' opt; do
case $opt in
s)
code_sign_identity=$OPTARG
;;
d)
dsa_signature_key_path=$OPTARG
;;
o)
output_directory=$OPTARG
;;
:)
missing_argument $OPTARG
exit 1
;;
?)
help
exit 1
;;
esac
done
# Invalid arguments
if [ ! "$code_sign_identity" ] || [ ! "$dsa_signature_key_path" ] || [ ! "$output_directory" ]; then
help
exit 1
fi
# Verify paths
if [ ! -f "$dsa_signature_key_path" ]; then
non_existent_path "$dsa_signature_key_path"
exit 1
fi
if [ ! -d "$output_directory" ]; then
non_existent_path "$output_directory"
exit 1
fi
# Build app
version=$(get_app_property 'CFBundleShortVersionString')
build_number=$(get_app_property 'CFBundleVersion')
archive="phoenix-$version.tar.gz"
if [ -f "$output_directory/$archive" ]; then
echo "Archive “"$archive"” already exists. Exiting..."
exit 1
fi
describe "Building $app..."
xcodebuild -workspace $app.xcworkspace \
-scheme $app \
-configuration Release \
SYMROOT="$PWD/build/" \
CODE_SIGN_IDENTITY="$code_sign_identity" \
clean build
# Verify app
describe 'Verifying signed app...'
cd build/Release
codesign --verbose=4 --verify $app.app
spctl --verbose=4 --assess --type execute $app.app
# Archive app
describe 'Archiving app...'
tar czf "$output_directory/$archive" $app.app
echo "Archived to “"$output_directory/$archive"”."
cd $output_directory
# Create DSA-signature
describe 'Creating DSA-signature for archive...'
signature=$(openssl dgst -sha1 -binary < $archive | openssl dgst -dss1 -sign "$dsa_signature_key_path" | openssl enc -base64)
echo "DSA: $signature"
# Collect information
describe 'Collecting release information...'
echo "Date: $(LANG=en date '+%a, %d %b %Y %T %z')"
echo "Version: $version ($build_number)"
echo "Archive: $archive"
echo "Size: $(stat -f '%z' $archive)"
echo "Signature: $signature"
describe 'Done.'