1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/development/sentry-upload-artifacts.sh
Mark Stacey 5f538f7ab2 Migrate Sentry settings to environment variables (#11085)
Sentry is now configured with environment variables, rather than with
hard-coded values. This makes it easier to test Sentry functionality
using a different Sentry account, as we did recently during QA of
v9.5.1.

The only change for the normal build process is the introduction of the
`SENTRY_DSN_DEV` variable, which can be set via `.metamaskrc` or via an
environment variable. This determines where error reports are sent. It
still defaults to our team Sentry account's `metamask-testing` project.

The `sentry:publish` script now requires SENTRY_ORG and SENTRY_PROJECT
to be set in order to publish release artifacts. The CircleCI
configuration has been updated with these values, so it should act the
same as it did before. Previously we had used a CLI flag to specify the
organization and project, but Sentry already natively supports these
environment variables [1].

[1]: https://docs.sentry.io/product/cli/configuration/#configuration-values
2021-06-07 10:30:50 -02:30

79 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -x
set -e
set -u
set -o pipefail
readonly __SCRIPT_NAME__="${0##*/}"
readonly __SEE_HELP_MESSAGE__="See '${__SCRIPT_NAME__} --help' for more information."
function die {
local message="${1}"
printf 'ERROR: %s\n' "${message}" >&2
exit 1
}
function show_help {
cat << EOF
${__SCRIPT_NAME__}"
Upload JavaScript bundles and sourcemaps to Sentry
Options:
-h, --help Show help text
-r, --release <release> Sentry release to upload files to (defaults to 'VERSION' environment variable)
EOF
}
function upload_sourcemaps {
local release="${1}"; shift
sentry-cli releases files "${release}" upload-sourcemaps ./dist/chrome/*.js ./dist/sourcemaps/ --rewrite --url-prefix 'metamask'
}
function main {
local release=VERSION
while :; do
case "${1-default}" in
-h|--help)
show_help
exit
;;
-r|--release)
if [[ -z $2 ]]
then
printf "'release' option requires an argument.\\n" >&2
printf '%s\n' "${__SEE_HELP_MESSAGE__}" >&2
exit 1
fi
release="${2}"
shift
;;
*)
break
esac
shift
done
if [[ -z $release ]]
then
die 'Required parameter "release" missing; either include parameter or set VERSION environment variable'
elif [[ -z $SENTRY_ORG ]]
then
die 'Required environment variable "SENTRY_ORG" missing'
elif [[ -z $SENTRY_PROJECT ]]
then
die 'Required environment variable "SENTRY_PROJECT" missing'
fi
printf 'uploading source files and sourcemaps for Sentry release "%s"...\n' "${release}"
upload_sourcemaps "${release}"
printf 'all done!\n'
}
main "${@}"