@@ -14,18 +14,21 @@ PRIVATE_KEY_LOC='LOCATION NOT COMMITTED'
1414NIGHTLY_ICON_LOC=/Users/spbuildbot/buildbot/sequel-pro/build/Resources/Images/appIcon.icns
1515NIGHTLY_KEYCHAIN_LOC=/Users/spbuildbot/Library/Keychains/spnightly.keychain-db
1616NIGHTLY_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"
1720
1821# Ensure a revision hash was passed in
1922REVISION_HASH=` echo " $1 " | grep " \([0-9a-f]*\)" `
2023if [ " $REVISION_HASH " == " " ]
2124then
2225 echo " Unable to extract revision hash from first argument; cancelling nightly build (git rev-parse HEAD)." >&2
2326 exit 1
24- fi
27+ fi
2528SHORT_HASH=${REVISION_HASH: 0: 10}
2629
2730# Build a numeric revision for bundle version etc
28- svn2git_migration_compensation=480
31+ svn2git_migration_compensation=779
2932cd " $GIT_DIR "
3033NUMERIC_REVISION=$(( `git log -- oneline | wc - l` + $svn2git_migration_compensation ))
3134
4447 exit 1
4548fi
4649
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+
4992
5093echo " Cleaning remains of any previous nightly builds..."
5194
5295# Delete any previous disk images and translation files
5396rm -f * .dmg & > /dev/null
97+ rm -f * .zip & > /dev/null
5498rm -rf disttemp & > /dev/null
5599rm -f languagetranslations.zip & > /dev/null
56100rm -rf languagetranslations & > /dev/null
57101rm -rf $IBSTRINGSDIR & > /dev/null
102+ remove_temp_files
58103
59104# echo "Creating IB strings files for rekeying..."
60105# mkdir -p $IBSTRINGSDIR/English.lproj
@@ -92,7 +137,7 @@ rm -rf $IBSTRINGSDIR &> /dev/null
92137
93138# echo "Copying nightly icon"
94139
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
96141# cp -f "$NIGHTLY_ICON_LOC" Sequel\ Pro.app/Contents/Resources/appicon.icns
97142
98143echo " Updating version strings"
@@ -102,66 +147,76 @@ php -r '$infoplistloc = "'$BUILD_DIR'/Sequel Pro.app/Contents/Info.plist";
102147 $infoplist = file_get_contents($infoplistloc);
103148 $infoplist = preg_replace("/(\<key\>CFBundleShortVersionString\<\/key\>\s*\n?\r?\s*\<string\>)[^<]*(\<\/string\>)/i", "\\1Nightly build for revision ' $SHORT_HASH ' \\2", $infoplist);
104149 $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);
106150 $infoplist = preg_replace("/(\<key\>SUFeedURL\<\/key\>\s*\n?\r?\s*\<string\>)[^<]*(\<\/string\>)/i", "\\1https://sequelpro.com/nightly/nightly-app-releases.php\\2", $infoplist);
107151 file_put_contents($infoplistloc, $infoplist);'
108152
109153# Update versions in localised string files
110154php -r ' $englishstringsloc = "/' $BUILD_DIR ' /Sequel Pro.app/Contents/Resources/English.lproj/InfoPlist.strings";
111155 $englishstrings = file_get_contents($englishstringsloc);
112156 $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);
114158 $englishstrings = mb_convert_encoding($englishstrings, "UTF-16", "UTF-8");
115159 file_put_contents($englishstringsloc, $englishstrings);'
116160
117161echo " Signing build..."
118162
119163# 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+
120170security 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 " )
123172security 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+
126174if [ " $VERIFYERRORS " != ' ' ]
127175then
176+ remove_temp_files
128177 echo " Signing verification threw an error: $VERIFYERRORS " >&2
129178 exit 1
130179fi
131180
132181echo " Build signed and verified successfully"
133- echo " Building disk image ..."
182+ echo " Compressing ..."
134183
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"
142185
143186# Make sure it was created
144- if [ ! -e " Sequel_Pro_r${SHORT_HASH} .dmg " ]
187+ if [ ! -e " Sequel_Pro_r${SHORT_HASH} .zip " ]
145188then
146- echo " Disk image was not built successfully!" >&2
189+ echo " Zip file was not built successfully!" >&2
147190 exit 1
148191fi
149192
150- echo " Signing disk image "
193+ echo " Signing zip file "
151194
152195# 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
154211
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} ..."
157214
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
160216RETURNVALUE=$?
161217if [ $RETURNVALUE -eq 0 ]
162218then
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"
165220fi
166221
167222# Clean up
@@ -176,14 +231,4 @@ then
176231 exit 1
177232fi
178233
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-
189234echo " Done!"
0 commit comments