mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Improve Sentry publish script (#7417)
The script will now throw an error if it fails to upload build artifacts, rather than failing silently.
This commit is contained in:
parent
63bd422840
commit
e060e4c71f
@ -27,11 +27,7 @@ async function start () {
|
|||||||
const versionHasArtifacts = versionAlreadyExists && await checkIfVersionHasArtifacts()
|
const versionHasArtifacts = versionAlreadyExists && await checkIfVersionHasArtifacts()
|
||||||
if (!versionHasArtifacts) {
|
if (!versionHasArtifacts) {
|
||||||
// upload sentry source and sourcemaps
|
// upload sentry source and sourcemaps
|
||||||
console.log(`uploading source files Sentry release "${VERSION}"...`)
|
await exec(`./development/sentry-upload-artifacts.sh --release ${VERSION}`)
|
||||||
await exec(`for FILEPATH in ./dist/chrome/*.js; do [ -e $FILEPATH ] || continue; export FILE=\`basename $FILEPATH\` && echo uploading $FILE && sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload $FILEPATH metamask/$FILE; done;`)
|
|
||||||
console.log(`uploading sourcemaps Sentry release "${VERSION}"...`)
|
|
||||||
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps'`)
|
|
||||||
console.log('all done!')
|
|
||||||
} else {
|
} else {
|
||||||
console.log(`Version "${VERSION}" already has artifacts on Sentry, skipping sourcemap upload`)
|
console.log(`Version "${VERSION}" already has artifacts on Sentry, skipping sourcemap upload`)
|
||||||
}
|
}
|
||||||
|
97
development/sentry-upload-artifacts.sh
Executable file
97
development/sentry-upload-artifacts.sh
Executable file
@ -0,0 +1,97 @@
|
|||||||
|
#!/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_bundles {
|
||||||
|
local release="${1}"; shift
|
||||||
|
|
||||||
|
for filepath in ./dist/chrome/*.js
|
||||||
|
do
|
||||||
|
if [[ -f $filepath ]]
|
||||||
|
then
|
||||||
|
upload_bundle "${release}" "${filepath}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function upload_bundle {
|
||||||
|
local release="${1}"; shift
|
||||||
|
local filepath="${1}"; shift
|
||||||
|
local filename
|
||||||
|
|
||||||
|
filename="$( basename "${filepath}" )"
|
||||||
|
|
||||||
|
printf 'Uploading %s\n' "${filename}"
|
||||||
|
sentry-cli releases --org 'metamask' --project 'metamask' files "${release}" upload "${filepath}" "metamask/${filename}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function upload_sourcemaps {
|
||||||
|
local release="${1}"; shift
|
||||||
|
|
||||||
|
sentry-cli releases --org 'metamask' --project 'metamask' files "${release}" upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps'
|
||||||
|
}
|
||||||
|
|
||||||
|
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'
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf 'uploading source files Sentry release "%s"...\n' "${release}"
|
||||||
|
upload_bundles "${release}"
|
||||||
|
printf 'uploading sourcemaps Sentry release "%s"...\n' "${release}"
|
||||||
|
upload_sourcemaps "${release}"
|
||||||
|
printf 'all done!\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
Loading…
x
Reference in New Issue
Block a user