mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 20:02:58 +01:00
3540a5b4d4
The function we were using to run shell commands during the `sentry:publish` script were swallowing the CLI output. We also weren't correctly detecting the process exit in some cases. The `run-command` module originally written for `auto-changelog` (introduced in #10782 and replaced in #10993) has been resurrected for running commands where we don't care about the output, or where we want to use the output for something. A second function (`runInShell`) has been added for running commands with the same STDOUT and STDERR streams, so that the output is sent directly to the CLI. This ensures that the console output from the shell script we run gets correctly output to the CLI.
78 lines
1.6 KiB
Bash
Executable File
78 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
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 "${@}"
|