#!/bin/sh
cd /Users/macossign/Documents/Sign
-printf "Unlock keychain\n----\n\n"
-security unlock-keychain -p "rntj55bw" /Users/macossign/Library/Keychains/Apple.keychain-db
-printf "Unzip app file\n----\n\n"
-rm -rf "$1.app"
-unzip "$1.app.zip"
-rm -f "$1.app.zip"
-printf "Sign the app\n----\n\n"
-./docodesign3 "$1.app" "Developer ID Application: Cubedesigners (82TNE4UQ7A)"
-printf "Zip the app in order to be notarized\n----\n\n"
-ditto -c -k --sequesterRsrc --keepParent "$1.app" "$1.app.zip"
-printf "Notarize app and wait for confirmation\n----\n\n"
-xcrun notarytool submit --wait --apple-id "contact@cubedesigners.com" --team-id "82TNE4UQ7A" --password "tqwj-saik-dtdl-yrpc" "$1.app.zip"
-printf "Staple the app\n----\n\n"
-xcrun stapler staple "$1.app"
-printf "Rezip the app\n----\n\n"
-rm -f "$1.app.zip"
-ditto -c -k --sequesterRsrc --keepParent "$1.app" "$1.app.zip"
-printf "Remove the app (keep only zip)\n----\n\n"
-rm -rf "$1.app"
-chmod 777 "$1.app.zip"
+printf "Unlock keychain\n----\n\n" > $1.log 2>&1
+security unlock-keychain -p "rntj55bw" /Users/macossign/Library/Keychains/Apple.keychain-db >> $1.log 2>&1
+printf "Unzip app file\n----\n\n" >> $1.log 2>&1
+rm -rf "$1.app" >> $1.log 2>&1
+unzip -o "$1.app.zip" >> $1.log 2>&1
+rm -f "$1.app.zip" >> $1.log 2>&1
+printf "Sign the app\n----\n\n" >> $1.log 2>&1
+./docodesign3 "$1.app" "Developer ID Application: Cubedesigners (82TNE4UQ7A)" >> $1.log 2>&1
+printf "Zip the app in order to be notarized\n----\n\n" >> $1.log 2>&1
+ditto -c -k --sequesterRsrc --keepParent "$1.app" "$1.app.zip" >> $1.log 2>&1
+printf "Notarize app and wait for confirmation\n----\n\n" >> $1.log 2>&1
+xcrun notarytool submit --wait --apple-id "contact@cubedesigners.com" --team-id "82TNE4UQ7A" --password "tqwj-saik-dtdl-yrpc" "$1.app.zip" >> $1.log 2>&1
+printf "Staple the app\n----\n\n" >> $1.log 2>&1
+xcrun stapler staple "$1.app" >> $1.log 2>&1
+printf "Rezip the app\n----\n\n" >> $1.log 2>&1
+rm -f "$1.app.zip" >> $1.log 2>&1
+ditto -c -k --sequesterRsrc --keepParent "$1.app" "$1.app.zip" >> $1.log 2>&1
+printf "Remove the app (keep only zip)\n----\n\n" >> $1.log 2>&1
+rm -rf "$1.app" >> $1.log 2>&1
+chmod 777 "$1.app.zip" >> $1.log 2>&1