From 645d9c8276fcd75edef31c42082c3ddb31160b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 12 Apr 2023 13:59:53 +0200 Subject: [PATCH] ci: fix handling of stdout in MacOS notarization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we get failures like: ``` parse error: Invalid numeric literal at line 1, column 11 ``` Which results in `stderr` logs being included in `$OUT`. Signed-off-by: Jakub SokoĊ‚owski --- scripts/notarize-macos-pkg.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/notarize-macos-pkg.sh b/scripts/notarize-macos-pkg.sh index 5a7d57a645..58f5c223e8 100755 --- a/scripts/notarize-macos-pkg.sh +++ b/scripts/notarize-macos-pkg.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -e +set -eof pipefail [[ $(uname) != 'Darwin' ]] && { echo 'This only works on macOS.' >&2; exit 1; } [[ $# -ne 1 ]] && { echo 'notarize-macos-pkg.sh ' >&2; exit 1; } @@ -17,16 +16,28 @@ CHECK_INTERVAL_SEC="${CHECK_INTERVAL_SEC:-30}" CHECK_RETRY_LIMIT="${CHECK_RETRY_LIMIT:-20}" # Unique ID of MacOS application. MACOS_BUNDLE_ID="${MACOS_BUNDLE_ID:-im.status.ethereum.desktop}" -# Log file path -NOTARIZATION_LOG="${NOTARIZATION_LOG:-${PWD}/notarization.log}" +# Xcode altool log file paths +NOTARIZATION_ERR_LOG="${NOTARIZATION_ERR_LOG:-${PWD}/notarization.out.log}" +NOTARIZATION_OUT_LOG="${NOTARIZATION_OUT_LOG:-${PWD}/notarization.err.log}" + +function show_xcrun_altool_logs() { + echo "FAILURE!" + echo "STDERR:" + cat "${NOTARIZATION_ERR_LOG}" + echo "STDOUT:" + cat "${NOTARIZATION_OUT_LOG}" +} +trap show_xcrun_altool_logs ERR function xcrun_altool() { + # STDERR goes to /dev/null so we can capture just the JSON. xcrun altool "${@}" \ --team-id "${MACOS_NOTARIZE_TEAM_ID}" \ --username "${MACOS_NOTARIZE_USERNAME}" \ --password "${MACOS_NOTARIZE_PASSWORD}" \ --output-format "json" \ - 2>&1 | tee -a "${NOTARIZATION_LOG}" + > >(tee -a "${NOTARIZATION_OUT_LOG}") \ + 2> >(tee -a "${NOTARIZATION_ERR_LOG}" >/dev/null) } # Submit app for notarization. Should take 5-10 minutes.