@@ -14,18 +14,21 @@ PRIVATE_KEY_LOC='LOCATION NOT COMMITTED'
14
14
NIGHTLY_ICON_LOC=/Users/spbuildbot/buildbot/sequel-pro/build/Resources/Images/appIcon.icns
15
15
NIGHTLY_KEYCHAIN_LOC=/Users/spbuildbot/Library/Keychains/spnightly.keychain-db
16
16
NIGHTLY_KEYCHAIN_PASSWORD=' PASSWORD NOT COMMITTED'
17
+ FRAMEWORKS_LIST=" /tmp/sp.frameworks.$$ "
18
+ FILES_TO_SIGN_LIST=" /tmp/sp.filelist.$$ "
19
+ UPLOAD_AUTH_TOKEN=" TOKEN_NOT_COMMITTED"
17
20
18
21
# Ensure a revision hash was passed in
19
22
REVISION_HASH=` echo " $1 " | grep " \([0-9a-f]*\)" `
20
23
if [ " $REVISION_HASH " == " " ]
21
24
then
22
25
echo " Unable to extract revision hash from first argument; cancelling nightly build (git rev-parse HEAD)." >&2
23
26
exit 1
24
- fi
27
+ fi
25
28
SHORT_HASH=${REVISION_HASH: 0: 10}
26
29
27
30
# Build a numeric revision for bundle version etc
28
- svn2git_migration_compensation=480
31
+ svn2git_migration_compensation=779
29
32
cd " $GIT_DIR "
30
33
NUMERIC_REVISION=$(( `git log -- oneline | wc - l` + $svn2git_migration_compensation ))
31
34
44
47
exit 1
45
48
fi
46
49
47
- IBSTRINGSDIR=ibstrings
48
- # XIB_BASE="$GIT_DIR/Interfaces/English.lproj"
50
+ remove_temp_files ()
51
+ {
52
+ rm " $FRAMEWORKS_LIST " & > /dev/null
53
+ rm " $FILES_TO_SIGN_LIST " & > /dev/null
54
+ }
55
+
56
+ dist_sign_framework ()
57
+ {
58
+ codesign -f --keychain " $NIGHTLY_KEYCHAIN_LOC " -s ' Developer ID Application: MJ Media (Y48LQG59RS)' -r " ${GIT_DIR} /Resources/spframeworkrequirement.bin" " $1 " 2> /dev/null
59
+ }
60
+
61
+ dist_sign_resource ()
62
+ {
63
+ codesign -f --keychain " $NIGHTLY_KEYCHAIN_LOC " -s ' Developer ID Application: MJ Media (Y48LQG59RS)' -r " ${GIT_DIR} /Resources/sprequirement.bin" " $1 " 2> /dev/null
64
+ }
65
+
66
+ verify_signing ()
67
+ {
68
+ codesign --verify --deep " $1 " 2>&1
69
+ }
70
+
71
+ dist_code_sign ()
72
+ {
73
+ ERRORS=' '
74
+
75
+ while read FRAMEWORK_TO_SIGN
76
+ do
77
+ dist_sign_framework " ${FRAMEWORK_TO_SIGN} "
78
+
79
+ ERRORS+=$( verify_signing " ${FRAMEWORK_TO_SIGN} " )
80
+ done < " $1 "
81
+
82
+ while read FILE_TO_SIGN
83
+ do
84
+ dist_sign_resource " ${FILE_TO_SIGN} "
85
+
86
+ ERRORS+=$( verify_signing " ${FILE_TO_SIGN} " )
87
+ done < " $2 "
88
+
89
+ echo $ERRORS
90
+ }
91
+
49
92
50
93
echo " Cleaning remains of any previous nightly builds..."
51
94
52
95
# Delete any previous disk images and translation files
53
96
rm -f * .dmg & > /dev/null
97
+ rm -f * .zip & > /dev/null
54
98
rm -rf disttemp & > /dev/null
55
99
rm -f languagetranslations.zip & > /dev/null
56
100
rm -rf languagetranslations & > /dev/null
57
101
rm -rf $IBSTRINGSDIR & > /dev/null
102
+ remove_temp_files
58
103
59
104
# echo "Creating IB strings files for rekeying..."
60
105
# mkdir -p $IBSTRINGSDIR/English.lproj
@@ -92,7 +137,7 @@ rm -rf $IBSTRINGSDIR &> /dev/null
92
137
93
138
# echo "Copying nightly icon"
94
139
95
- # Copy in the nightly icon
140
+ # Copy in the nightly icon - this is currently within this repo so this step isn't really necessary
96
141
# cp -f "$NIGHTLY_ICON_LOC" Sequel\ Pro.app/Contents/Resources/appicon.icns
97
142
98
143
echo " Updating version strings"
@@ -102,66 +147,76 @@ php -r '$infoplistloc = "'$BUILD_DIR'/Sequel Pro.app/Contents/Info.plist";
102
147
$infoplist = file_get_contents($infoplistloc);
103
148
$infoplist = preg_replace("/(\<key\>CFBundleShortVersionString\<\/key\>\s*\n?\r?\s*\<string\>)[^<]*(\<\/string\>)/i", "\\1Nightly build for revision ' $SHORT_HASH ' \\2", $infoplist);
104
149
$infoplist = preg_replace("/(\<key\>CFBundleVersion\<\/key\>\s*\n?\r?\s*)\<string\>[^<]*(\<\/string\>)/i", "\\1<string>' $NUMERIC_REVISION ' \\2", $infoplist);
105
- $infoplist = preg_replace("/(\<key\>NSHumanReadableCopyright\<\/key\>\s*\n?\r?\s*\<string\>)[^<]*(\<\/string\>)/i", "\\1Nightly build for revision ' $SHORT_HASH ' \\2", $infoplist);
106
150
$infoplist = preg_replace("/(\<key\>SUFeedURL\<\/key\>\s*\n?\r?\s*\<string\>)[^<]*(\<\/string\>)/i", "\\1https://sequelpro.com/nightly/nightly-app-releases.php\\2", $infoplist);
107
151
file_put_contents($infoplistloc, $infoplist);'
108
152
109
153
# Update versions in localised string files
110
154
php -r ' $englishstringsloc = "/' $BUILD_DIR ' /Sequel Pro.app/Contents/Resources/English.lproj/InfoPlist.strings";
111
155
$englishstrings = file_get_contents($englishstringsloc);
112
156
$englishstrings = mb_convert_encoding($englishstrings, "UTF-8", "UTF-16");
113
- $englishstrings = preg_replace("/version [^\,\"]+/iu", "nightly build for r ' $SHORT_HASH ' ", $englishstrings);
157
+ $englishstrings = preg_replace("/version [^\,\"]+/iu", "nightly build for ' $SHORT_HASH ' ", $englishstrings);
114
158
$englishstrings = mb_convert_encoding($englishstrings, "UTF-16", "UTF-8");
115
159
file_put_contents($englishstringsloc, $englishstrings);'
116
160
117
161
echo " Signing build..."
118
162
119
163
# Code sign and verify the nightly
164
+ APP_LOC=" Sequel Pro.app"
165
+ ls -d -1 " $APP_LOC /Contents/Frameworks" /** > " $FRAMEWORKS_LIST "
166
+ echo " ${APP_LOC} /Contents/Library/QuickLook/Sequel Pro.qlgenerator" >> " $FILES_TO_SIGN_LIST "
167
+ echo " ${APP_LOC} /Contents/Resources/SequelProTunnelAssistant" >> " $FILES_TO_SIGN_LIST "
168
+ echo " ${APP_LOC} " >> " $FILES_TO_SIGN_LIST "
169
+
120
170
security unlock-keychain -p " $NIGHTLY_KEYCHAIN_PASSWORD " " $NIGHTLY_KEYCHAIN_LOC "
121
- codesign -f --keychain " $NIGHTLY_KEYCHAIN_LOC " -s ' Developer ID Application: MJ Media (Y48LQG59RS)' -r $GIT_DIR " /Resources/spframeworkrequirement.bin" " Sequel Pro.app/Contents/Resources/SequelProTunnelAssistant"
122
- codesign -f --keychain " $NIGHTLY_KEYCHAIN_LOC " -s ' Developer ID Application: MJ Media (Y48LQG59RS)' -r $GIT_DIR " /Resources/sprequirement.bin" " Sequel Pro.app"
171
+ VERIFY_ERRORS=$( dist_code_sign " $FRAMEWORKS_LIST " " $FILES_TO_SIGN_LIST " )
123
172
security lock-keychain " $NIGHTLY_KEYCHAIN_LOC "
124
- VERIFYERRORS=` codesign --verify " Sequel Pro.app" 2>&1 `
125
- VERIFYERRORS+=` codesign --verify " Sequel Pro.app/Contents/Resources/SequelProTunnelAssistant" 2>&1 `
173
+
126
174
if [ " $VERIFYERRORS " != ' ' ]
127
175
then
176
+ remove_temp_files
128
177
echo " Signing verification threw an error: $VERIFYERRORS " >&2
129
178
exit 1
130
179
fi
131
180
132
181
echo " Build signed and verified successfully"
133
- echo " Building disk image ..."
182
+ echo " Compressing ..."
134
183
135
- # Build the disk image
136
- mkdir disttemp
137
- cp -R -p Sequel\ Pro.app disttemp
138
- SetFile -a B disttemp/Sequel\ Pro.app
139
- hdiutil create -fs HFS+ -volname " Sequel Pro Nightly (r" $SHORT_HASH " )" -srcfolder disttemp disttemp.dmg
140
- hdiutil convert disttemp.dmg -format UDBZ -o Sequel_Pro_r" $SHORT_HASH " .dmg
141
- rm -rf disttemp*
184
+ zip -q -r --symlinks " Sequel_Pro_r${SHORT_HASH} .zip" " Sequel Pro.app"
142
185
143
186
# Make sure it was created
144
- if [ ! -e " Sequel_Pro_r${SHORT_HASH} .dmg " ]
187
+ if [ ! -e " Sequel_Pro_r${SHORT_HASH} .zip " ]
145
188
then
146
- echo " Disk image was not built successfully!" >&2
189
+ echo " Zip file was not built successfully!" >&2
147
190
exit 1
148
191
fi
149
192
150
- echo " Signing disk image "
193
+ echo " Signing zip file "
151
194
152
195
# Sign the disk image
153
- SIGNATURE=` openssl dgst -sha1 -binary < " Sequel_Pro_r${SHORT_HASH} .dmg" | openssl dgst -dss1 -sign " $PRIVATE_KEY_LOC " | openssl enc -base64 | tr -d " \n" `
196
+ SIGNATURE=` openssl dgst -sha1 -binary < " Sequel_Pro_r${SHORT_HASH} .zip" | openssl dgst -dss1 -sign " $PRIVATE_KEY_LOC " | openssl enc -base64 | tr -d " \n" `
197
+ URLENCODEDSIGNATURE=$( php -r ' echo urlencode("' $SIGNATURE ' ");' )
198
+
199
+ echo " Zip file ready (hashed as $SIGNATURE )"
200
+
201
+
202
+ echo " Getting ID to upload zip file..."
203
+
204
+ PENDING_BUILD_ID=$( curl ' https://sequelpro.com/api?action=pendingTestBuilds&authToken=' $UPLOAD_AUTH_TOKEN | jq -r ' .releases | map(select(.commit == "' $REVISION_HASH ' ")) | .[0]? | .id?' )
205
+ if [ $PENDING_BUILD_ID == ' null' ]
206
+ then
207
+ echo " Unable to get pending build ID!" >&2
208
+ exit 1
209
+ fi
210
+ echo " Working with pending build ID " $PENDING_BUILD_ID
154
211
155
- echo " Disk image ready (hashed as $SIGNATURE ) "
156
- echo " Uploading disk image..."
212
+ FILESIZE= $( stat -f%z " Sequel_Pro_r " $SHORT_HASH " .zip " )
213
+ echo " Uploading disk image of size ${FILESIZE} ..."
157
214
158
- # Upload the disk image
159
- scp -P 32100 Sequel_Pro_r" $SHORT_HASH " .dmg spnightlyuploader@sequelpro.com:nightlybuilds
215
+ curl ' https://sequelpro.com/api?action=uploadBuild&uploadReleaseId=' $PENDING_BUILD_ID ' &uploadFilesize=' $FILESIZE ' &buildHash=' $URLENCODEDSIGNATURE ' &authToken=' $UPLOAD_AUTH_TOKEN --upload-file Sequel_Pro_r" $SHORT_HASH " .zip
160
216
RETURNVALUE=$?
161
217
if [ $RETURNVALUE -eq 0 ]
162
218
then
163
- echo " Successfully uploaded disk image"
164
- ssh spnightlyuploader@sequelpro.com -p 32100 chmod 666 nightlybuilds/Sequel_Pro_r" $SHORT_HASH " .dmg
219
+ echo " Successfully uploaded zip file"
165
220
fi
166
221
167
222
# Clean up
@@ -176,14 +231,4 @@ then
176
231
exit 1
177
232
fi
178
233
179
- # Use curl to post the signature to the server
180
- echo " Informing nightly server about new build..."
181
- BUILD_ACTIVATE_OUTPUT=` curl --silent -F " filename=Sequel_Pro_r${SHORT_HASH} .dmg" -F " build_hash=$SIGNATURE " -F " build_id=$NUMERIC_REVISION " -F " full_revision=$REVISION_HASH " http://sequelpro.com/nightly/build.php? action=hash-submit`
182
- if [ " $BUILD_ACTIVATE_OUTPUT " != ' Successfully updated.' ]
183
- then
184
- echo " Unexpected status when informing nightly server about new build: "
185
- echo " $BUILD_ACTIVATE_OUTPUT "
186
- exit 1
187
- fi
188
-
189
234
echo " Done!"
0 commit comments