Skip to content

Commit e71a936

Browse files
committed
[platf,react] fix double-upload of source maps, template-ize webpack config
1 parent 29d5bdc commit e71a936

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

bin/sentry-release.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Create release and upload sourcemaps to Sentry
44
# Must be run within project directory (e.g. './react/')
55

6-
USAGE="Usage: ./sentry-release.sh ENV RELEASE"
6+
USAGE="Usage: ./sentry-release.sh ENV RELEASE UPLOAD_SOURCEMAPS \
7+
UPLOAD_SOURCEMAPS = false | true"
78

89
set -e # exit immediately if any command exits with a non-zero status
910

@@ -12,7 +13,8 @@ echo "$0: Creating release and uploading source maps with sentry-cli..."
1213
# Parse and validate command-line arguments
1314
env="$1"
1415
release="$2"
15-
if [[ "$env" == "" || "$release" == "" ]]; then
16+
upload_sourcemaps="$3"
17+
if [[ "$env" == "" || "$release" == "" || "$upload_sourcemaps" == "" ]]; then
1618
echo "$0: [error] missing required command-line arguments."
1719
echo $USAGE
1820
exit 1
@@ -32,5 +34,7 @@ fi
3234
sentry-cli releases -o $SENTRY_ORG new -p $sentry_project $release
3335
sentry-cli releases -o $SENTRY_ORG finalize -p $sentry_project $release
3436
sentry-cli releases -o $SENTRY_ORG -p $sentry_project set-commits --auto $release --ignore-missing
35-
sentry-cli releases -o $SENTRY_ORG -p $sentry_project files $release upload-sourcemaps --url-prefix "$sourcemaps_url_prefix" --validate "$sourcemaps_dir"
37+
if [ "$upload_sourcemaps" == "true" ]; then
38+
sentry-cli releases -o $SENTRY_ORG -p $sentry_project files $release upload-sourcemaps --url-prefix "$sourcemaps_url_prefix" --validate "$sourcemaps_dir"
39+
fi
3640
sentry-cli deploys -o $SENTRY_ORG new -p $sentry_project -r $release -e $env -n $env

deploy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function cleanup {
102102
rm -f $top/spring-boot/src/main/appengine/app.yaml
103103
rm -f $top/spring-boot/src/main/resources/application.properties
104104
rm -f $top/crons-python/crontab
105+
rm -f $top/react/config-overrides.js
105106
if [ "$generated_envs" != "" ]; then
106107
rm -f $generated_envs # bash only (passed as separate args)
107108
fi
@@ -165,7 +166,12 @@ for proj in $projects; do # bash only
165166
./build.sh
166167

167168
if [[ "$fe_projects" = *"$proj "* ]]; then # project is frontend
168-
sentry-release.sh $env $RELEASE
169+
if [[ "$proj" == "react" ]]; then
170+
upload_sourcemaps="false" # using webpack plugin
171+
else
172+
upload_sourcemaps="true"
173+
fi
174+
sentry-release.sh $env $RELEASE $upload_sourcemaps
169175
# NOTE: Sentry may create releases from events even without this step
170176
fi
171177

react/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
set -e # exit immediately if any command exits with a non-zero status
66

7+
envsubst < config-overrides.js.template > config-overrides.js
8+
79
rm -rf build
810
# npm ci does not update minor versions ->
911
# (1) less chance of breaking (2) less noise in PR from package-lock.json
1012
npm ci
1113
npm run build # defined in 'scripts' in package.json
14+

react/config-overrides.js renamed to react/config-overrides.js.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module.exports = function override(config, env) {
1313
SentryWebpackPlugin.sentryWebpackPlugin({
1414
authToken: process.env.SENTRY_AUTH_TOKEN,
1515
include: '.',
16-
org: 'demo',
17-
project: 'react',
16+
org: '${SENTRY_ORG}',
17+
project: '${REACT_SENTRY_PROJECT}',
1818
ignoreFile: '.sentrycliignore',
1919
ignore: ['webpack.config.js'],
2020
configFile: 'sentry.properties',

0 commit comments

Comments
 (0)