sentry-upload.sh

 1# Uploads debug files to Sentry with retry logic.
 2#
 3# Usage: upload_to_sentry <file1> [file2 ...]
 4#
 5# Requires sentry-cli and SENTRY_AUTH_TOKEN to be available.
 6# Returns non-zero if all attempts fail.
 7upload_to_sentry() {
 8    if [[ $# -eq 0 ]]; then
 9        echo "Error: no files specified for sentry upload" >&2
10        return 1
11    fi
12
13    # note: this uploads the unstripped binary which is needed because it contains
14    # .eh_frame data for stack unwinding. see https://github.com/getsentry/symbolic/issues/783
15    for attempt in 1 2 3; do
16        echo "Sentry upload attempt $attempt/3..."
17        if sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev "$@"; then
18            echo "Sentry upload successful on attempt $attempt"
19            return 0
20        else
21            echo "Sentry upload failed on attempt $attempt"
22            if [ $attempt -eq 3 ]; then
23                echo "All sentry upload attempts failed" >&2
24                return 1
25            fi
26            sleep 5
27        fi
28    done
29}