forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentry-upload-artifacts.sh
executable file
·90 lines (75 loc) · 2.09 KB
/
sentry-upload-artifacts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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)
--dist-directory <path> The 'dist' directory to use. Defaults to 'dist'.
EOF
}
function upload_sourcemaps {
local release="${1}"; shift
local dist_directory="${1}"; shift
sentry-cli releases files "${release}" upload-sourcemaps "${dist_directory}"/chrome/*.js "${dist_directory}"/sourcemaps/ --rewrite --url-prefix 'metamask'
}
function main {
local release=VERSION
local dist_directory='dist'
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
;;
--dist-directory)
if [[ -z $2 ]]
then
printf "'dist-directory' option requires an argument.\\n" >&2
printf '%s\n' "${__SEE_HELP_MESSAGE__}" >&2
exit 1
fi
dist_directory="${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}" "${dist_directory}"
printf 'all done!\n'
}
main "${@}"