|
| 1 | +#!/usr/bin/env sh |
| 2 | + |
| 3 | +# secure/hidden variable from travis |
| 4 | +#CERTIFICATE_ID="..." |
| 5 | +#USERNAME="..." |
| 6 | +#APP_SPECIFIC_PASSWORD="..." |
| 7 | +#RELEASE_ZIP_FILE="..." |
| 8 | + |
| 9 | +# path to app |
| 10 | +FILE_APP='enduser/macos/app/trackereditor.app' |
| 11 | +PLISTBUDDY_APP='/usr/libexec/PlistBuddy' |
| 12 | + |
| 13 | +if [ ! -x "${PLISTBUDDY_APP}" ] |
| 14 | +then |
| 15 | + echo "Couldn't find PlistBuddy" |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +# copy everything into enduser/macos/app folder |
| 20 | +# |
| 21 | +# Move the executable to the application bundle |
| 22 | +mv enduser/trackereditor enduser/macos/app/trackereditor.app/Contents/MacOS |
| 23 | + |
| 24 | +# Move the trackers list to application bundle |
| 25 | +mv enduser/add_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS |
| 26 | +mv enduser/remove_trackers.txt enduser/macos/app/trackereditor.app/Contents/MacOS |
| 27 | + |
| 28 | +# move all the *.txt file |
| 29 | +mv enduser/*.txt enduser/macos/app |
| 30 | + |
| 31 | +# sign the app. -sign is the developer cetificate ID |
| 32 | +# entitlements does not work at this moment |
| 33 | +#codesign --timestamp --entitlements enduser/macos/entitlements.plist --force --options runtime --deep --sign $CERTIFICATE_ID $FILE_APP |
| 34 | +codesign --timestamp --force --options runtime --deep --sign $CERTIFICATE_ID $FILE_APP |
| 35 | + |
| 36 | +# Check exit code |
| 37 | +exit_code=$? |
| 38 | +if [ "${exit_code}" != "0" ] |
| 39 | +then |
| 40 | + echo "codesign failed: ${exit_code}" |
| 41 | + exit 1 |
| 42 | +fi |
| 43 | + |
| 44 | +#must use ditto to compress the file application folder only for notarize. Zip program will not work! |
| 45 | +/usr/bin/ditto -c -k --keepParent "$FILE_APP" "$RELEASE_ZIP_FILE" |
| 46 | + |
| 47 | +# upload zip to notarize service. for RequestUUID |
| 48 | +# -- username is the normal apple ID. example [email protected] |
| 49 | +# -- password is 'app specific password' generated via apple web site. Security -> app-specific password |
| 50 | +echo "Uploading to notarize server" |
| 51 | +xcrun altool --notarize-app --output-format xml --primary-bundle-id "trackereditor" --username $USERNAME --password $APP_SPECIFIC_PASSWORD --file $RELEASE_ZIP_FILE > "result.plist" |
| 52 | + |
| 53 | +# remove the uploaded zip file. need to be created again later. |
| 54 | +rm $RELEASE_ZIP_FILE |
| 55 | + |
| 56 | + |
| 57 | +# Check exit code |
| 58 | +exit_code=$? |
| 59 | +if [ "${exit_code}" != "0" ] |
| 60 | +then |
| 61 | + echo "notarize-app failed: ${exit_code}" |
| 62 | + cat "result.plist" |
| 63 | + exit 1 |
| 64 | +fi |
| 65 | + |
| 66 | +# Get the RequestUUID |
| 67 | +RequestUUID="$("${PLISTBUDDY_APP}" -c "Print notarization-upload:RequestUUID" "result.plist")" |
| 68 | +echo "RequestUUID: ${RequestUUID}" |
| 69 | + |
| 70 | +# wait till notarize apple server is finish with the processing the zip upload. |
| 71 | +for (( ; ; )) |
| 72 | +do |
| 73 | + |
| 74 | + # get status from apple notarize server |
| 75 | + xcrun altool --output-format xml --notarization-info "${RequestUUID}" -u $USERNAME -p $APP_SPECIFIC_PASSWORD > "result.plist" |
| 76 | + # Check exit code |
| 77 | + exit_code=$? |
| 78 | + if [ "${exit_code}" != "0" ] |
| 79 | + then |
| 80 | + echo "notarization-info failed: ${exit_code}" |
| 81 | + cat "result.plist" |
| 82 | + # print the error in the URL |
| 83 | + LogFileURL="$("${PLISTBUDDY_APP}" -c "Print notarization-info:LogFileURL" "result.plist")" |
| 84 | + if [ ! -z "${LogFileURL}" ] |
| 85 | + then |
| 86 | + curl "${LogFileURL}" |
| 87 | + fi |
| 88 | + exit 1 |
| 89 | + fi |
| 90 | + |
| 91 | + # get the status. |
| 92 | + StatusCode="$("${PLISTBUDDY_APP}" -c "Print notarization-info:Status" "result.plist")" |
| 93 | + echo "Status: ${StatusCode}" |
| 94 | + |
| 95 | + # if no status code present in result then it is still busy |
| 96 | + if [ "${StatusCode}" == "in progress" ] |
| 97 | + then |
| 98 | + sleep 15 |
| 99 | + else |
| 100 | + echo "Finish waiting." |
| 101 | + #cat "result.plist" |
| 102 | + # Check if everything is correct |
| 103 | + StatusCode="$("${PLISTBUDDY_APP}" -c "Print notarization-info:'Status Code'" "result.plist")" |
| 104 | + echo "Status code: ${StatusCode}" |
| 105 | + if [ "${StatusCode}" == "0" ] |
| 106 | + then |
| 107 | + # there are no error. |
| 108 | + break |
| 109 | + else |
| 110 | + # print the error in the URL |
| 111 | + LogFileURL="$("${PLISTBUDDY_APP}" -c "Print notarization-info:LogFileURL" "result.plist")" |
| 112 | + if [ ! -z "${LogFileURL}" ] |
| 113 | + then |
| 114 | + curl "${LogFileURL}" |
| 115 | + fi |
| 116 | + exit 1 |
| 117 | + fi |
| 118 | + fi |
| 119 | +done |
| 120 | + |
| 121 | +# verify sign *.app is succes full |
| 122 | +spctl --assess --type execute --verbose $FILE_APP |
| 123 | +# Check exit code |
| 124 | +exit_code=$? |
| 125 | +if [ "${exit_code}" != "0" ] |
| 126 | +then |
| 127 | + echo "spctl failed: ${exit_code}" |
| 128 | + exit 1 |
| 129 | +fi |
| 130 | + |
| 131 | +# staple the *.app |
| 132 | +xcrun stapler staple $FILE_APP |
| 133 | +# Check exit code |
| 134 | +exit_code=$? |
| 135 | +if [ "${exit_code}" != "0" ] |
| 136 | +then |
| 137 | + echo "spctl stapler: ${exit_code}" |
| 138 | + exit 1 |
| 139 | +fi |
| 140 | + |
| 141 | +# zip only the app folder with extra text file. |
| 142 | +/usr/bin/ditto -c -k "enduser/macos/app" "$RELEASE_ZIP_FILE" |
0 commit comments