Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatically upload react-native source maps to Bugsnag from Appcenter
#!/usr/bin/env bash
# Prevent send to bugsnag in not selected branches
if [ "$APPCENTER_BRANCH" != "production" ] && [ "$APPCENTER_BRANCH" != "qa" ] && [ "$APPCENTER_BRANCH" != "staging" ]
then
echo "This branch is not in the selected ones:" $APPCENTER_BRANCH
exit
fi
# Set platform
echo "Setting Platform..."
if [ -n "$APPCENTER_ANDROID_VARIANT" ];
then
PLATFORM='android'
else
PLATFORM='ios'
fi
echo "Platform:" $PLATFORM
## Create sourcemaps and bundle
echo "Generating Source Maps..."
npx react-native bundle \
--platform $PLATFORM \
--dev false \
--entry-file index.js \
--bundle-output release.bundle \
--sourcemap-output release.bundle.map
echo "Source Maps Generated..."
## Upload sourcemaps to Bugsnag
echo "Uploading Source Maps..."
curl --http1.1 https://upload.bugsnag.com/react-native-source-map \
-F apiKey=02abfc7cf2e05ed6e203dc5a2639fd46 \
-F $([ "$PLATFORM" == android ] && echo appVersionCode || echo appBundleVersion)=$APPCENTER_BUILD_ID \
-F dev=false \
-F platform=$PLATFORM \
-F sourceMap=@release.bundle.map \
-F bundle=@release.bundle \
-F projectRoot=`pwd`
echo "Source Maps Uploaded..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.