|
| 1 | +# altool credentials. |
| 2 | +# AC_PASSWORD is the name of the keychain item with App Connect password |
| 3 | +# Grant access to Xcode if prompted by Xcode. |
| 4 | +AC_USERNAME="$APPLEID" |
| 5 | +AC_PASSWORD="$APPLE_PASSWORD" |
| 6 | + |
| 7 | +if [[ $AC_USERNAME == "" ]]; then |
| 8 | + echo "error: no username" |
| 9 | + exit 1 |
| 10 | + break |
| 11 | +fi |
| 12 | + |
| 13 | +if [[ $AC_PASSWORD == "" ]]; then |
| 14 | + echo "error: no pass" |
| 15 | + exit 1 |
| 16 | + break |
| 17 | +fi |
| 18 | + |
| 19 | +# Do all of the work in a subdirectory of /tmp, and use a |
| 20 | +# unique ID so that there's no collision with previous builds. |
| 21 | +PRODUCT_NAME="YPaste" |
| 22 | +SCRIPTROOT=$(cd "$(dirname "$0")";pwd) |
| 23 | +SRCROOT=$(dirname "$SCRIPTROOT") |
| 24 | +ARCHIVE_PATH="$SRCROOT/archive-YPaste.xcarchive" |
| 25 | +EXPORT_PATH="$SRCROOT/apps" |
| 26 | +APP_PATH="$EXPORT_PATH/$PRODUCT_NAME.app" |
| 27 | +DMG_ROOT="$EXPORT_PATH/dmg" |
| 28 | +DMG_PATH="$DMG_ROOT/$PRODUCT_NAME.dmg" |
| 29 | +PRODUCT_BUNDLE_IDENTIFIER="com.qwertyyb.YPaste" |
| 30 | + |
| 31 | +echo $SRCROOT |
| 32 | + |
| 33 | +echo "clean build fold" |
| 34 | +rm -rf "$EXPORT_PATH" |
| 35 | + |
| 36 | +echo "build archive" |
| 37 | +xcodebuild archive -workspace YPaste.xcworkspace -scheme YPaste -archivePath "$SRCROOT/archive-YPaste" -configuration Release || { echo "Archive and Notarization Failed : xcodebuild archive action failed"; exit 1; } |
| 38 | + |
| 39 | +# Xcode doesn't show run script errors in build log. |
| 40 | +# Uncomment to save any messages aside. |
| 41 | +# exec > "/tmp/Xcode run script.log" 2>&1 |
| 42 | + |
| 43 | +# Ask xcodebuild(1) to export the app. Use the export options |
| 44 | +# from a previous manual export that used a Developer ID. |
| 45 | + |
| 46 | +echo "export archive" |
| 47 | +/usr/bin/xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportOptionsPlist "$SRCROOT/scripts/ExportOptions.plist" -exportPath "$EXPORT_PATH" || { echo "Export Archive Failed : xcodebuild exportArchive action failed"; exit 1; } |
| 48 | + |
| 49 | +# Create a UDIF bzip2-compressed disk image. |
| 50 | +cd "$EXPORT_PATH/" |
| 51 | +mkdir dmg |
| 52 | +# mv "$APP_PATH" "$PRODUCT_NAME" |
| 53 | + |
| 54 | +# /usr/bin/hdiutil create -srcfolder "$PRODUCT_NAME" -format UDBZ "$DMG_PATH" |
| 55 | + |
| 56 | +echo "use appdmg create DMG file" |
| 57 | +appdmg "$SRCROOT/scripts/appdmg.json" "$DMG_PATH" |
| 58 | + |
| 59 | +# Submit the finished deliverables for notarization. The "--primary-bundle-id" |
| 60 | +# argument is only used for the response email. |
| 61 | +echo "notarize app" |
| 62 | +xcrun altool --notarize-app --primary-bundle-id ${PRODUCT_BUNDLE_IDENTIFIER}.dmg -u "$AC_USERNAME" -p "$AC_PASSWORD" -f "$DMG_PATH" > "NotarizationUUIDs.log" |
| 63 | + |
| 64 | +uuid=`cat $EXPORT_PATH/NotarizationUUIDs.log | grep -Eo '\w{8}-(\w{4}-){3}\w{12}$'` |
| 65 | +echo "uuid=$uuid" |
| 66 | +while true; do |
| 67 | + echo "checking for notarization..." |
| 68 | + |
| 69 | + xcrun altool --notarization-info "$uuid" --username "$AC_USERNAME" --password "$AC_PASSWORD" &> check.log |
| 70 | + r=`cat check.log` |
| 71 | + t=`echo "$r" | grep "success"` |
| 72 | + f=`echo "$r" | grep "invalid"` |
| 73 | + if [[ "$t" != "" ]]; then |
| 74 | + echo "notarization done!" |
| 75 | + xcrun stapler staple "$APP_PATH" |
| 76 | + xcrun stapler staple "$DMG_PATH" |
| 77 | + echo "stapler done!" |
| 78 | + break |
| 79 | + fi |
| 80 | + if [[ "$f" != "" ]]; then |
| 81 | + echo "$r" |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + echo "not finish yet, sleep 2m then check again..." |
| 85 | + sleep 120 |
| 86 | +done |
| 87 | + |
| 88 | +APPCAST_PATH="$DMG_ROOT/appcast.xml" |
| 89 | +echo "generate appcast.xml" |
| 90 | +"$SRCROOT/bin/generate_appcast" -s $sparkle_key "$DMG_ROOT" |
| 91 | + |
| 92 | +echo "update appcast.xml download url" |
| 93 | +appcast=$(cat "$DMG_ROOT/appcast.xml") |
| 94 | +echo "$appcast" | sed -e "s/url[^ ]*/url=\"https:\/\/github.com\/qwertyyb\/YPaste\/releases\/latest\/download\/YPaste.dmg\"/g" > "$EXPORT_PATH/appcast.xml" |
0 commit comments