|
| 1 | +#!/bin/bash |
| 2 | +# print commands before executing them and stop on first error |
| 3 | +set -x -e |
| 4 | + |
| 5 | +echo "warning: uploading debug symbols - set SENTRY_SKIP_DSYM_UPLOAD=true to skip this" |
| 6 | + |
| 7 | +NODE_BINARY=$(command -v node || echo "") |
| 8 | +export NODE_BINARY |
| 9 | + |
| 10 | +IOS_PROJ_PATH=$(pwd) |
| 11 | + |
| 12 | +# Override the default with the global environment |
| 13 | +ENV_PATH="$IOS_PROJ_PATH/.xcode.env" |
| 14 | +if [ -f "$ENV_PATH" ]; then |
| 15 | + source "$ENV_PATH" |
| 16 | +fi |
| 17 | + |
| 18 | +# Override the global with the local environment |
| 19 | +LOCAL_ENV_PATH="${ENV_PATH}.local" |
| 20 | +if [ -f "$LOCAL_ENV_PATH" ]; then |
| 21 | + source "$LOCAL_ENV_PATH" |
| 22 | +fi |
| 23 | + |
| 24 | +if [ -z "$NODE_BINARY" ]; then |
| 25 | + echo "warning: Node path was not found on \`.xcode.env\` and \`.xcode.env.local.\`. " \ |
| 26 | + "You can quickly fix this by going to the path \`${IOS_PROJ_PATH}\` and running the following script: " \ |
| 27 | + " \`echo export NODE_BINARY=\$(command -v node) > .xcode.env\` " \ |
| 28 | + " Node is required for correctly build your project with Sentry." >&2 |
| 29 | + exit 0 |
| 30 | +else |
| 31 | + echo "Using Node.js from ${NODE_BINARY}" |
| 32 | +fi |
| 33 | + |
| 34 | +# SETUP SENTRY_PROPERTIES |
| 35 | +if [ -z "$SENTRY_PROPERTIES" ]; then |
| 36 | + # Check if the script is running in the root directory |
| 37 | + if [ -f "./sentry.properties" ]; then |
| 38 | + export SENTRY_PROPERTIES=sentry.properties |
| 39 | + elif [ -f "../../sentry.properties" ]; then |
| 40 | + export SENTRY_PROPERTIES=../../sentry.properties |
| 41 | + else |
| 42 | + echo "warning: SENTRY: sentry.properties file not found! Skipping symbol upload." |
| 43 | + exit 0 |
| 44 | + fi |
| 45 | +fi |
| 46 | + |
| 47 | +echo "sentry properties found at : $(readlink -f ${SENTRY_PROPERTIES})" |
| 48 | +$NODE_BINARY --version |
| 49 | + |
| 50 | +# SETUP SENTRY CLI |
| 51 | +[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_PACKAGE_PATH=$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/cli/package.json'))") |
| 52 | +[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="${SENTRY_CLI_PACKAGE_PATH}/bin/sentry-cli" |
| 53 | + |
| 54 | +SENTRY_COMMAND="\"$SENTRY_CLI_EXECUTABLE\" upload-dsym" |
| 55 | + |
| 56 | +# UPLOAD DEBUG SYMBOLS |
| 57 | +if [ "$SENTRY_SKIP_DSYM_UPLOAD" != true ]; then |
| 58 | + # 'warning:' triggers a warning in Xcode, 'error:' triggers an error |
| 59 | + set +x +e # disable printing commands otherwise we might print `error:` by accident and allow continuing on error |
| 60 | + SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "$NODE_BINARY $SENTRY_COMMAND" 2>&1) |
| 61 | + if [ $? -eq 0 ]; then |
| 62 | + echo "$SENTRY_XCODE_COMMAND_OUTPUT" | awk '{print "output: sentry-cli - " $0}' |
| 63 | + else |
| 64 | + echo "error: sentry-cli - To disable debug symbols upload, set SENTRY_SKIP_DSYM_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true" |
| 65 | + echo "error: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT" |
| 66 | + fi |
| 67 | + set -x -e # re-enable |
| 68 | +else |
| 69 | + echo "SENTRY_SKIP_DSYM_UPLOAD=true, skipping debug symbols upload" |
| 70 | +fi |
0 commit comments