Skip to content

Instantly share code, notes, and snippets.

@iotashan
Created December 8, 2017 15:31
Show Gist options
  • Save iotashan/528ff315c187706d982424639e878ad6 to your computer and use it in GitHub Desktop.
Save iotashan/528ff315c187706d982424639e878ad6 to your computer and use it in GitHub Desktop.
BuddyBuild script that uploads source maps to BugSnag
#!/usr/bin/env bash
APP_NAME="myapp"
BUGSNAG_KEY="123456"
APP_VER=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$BUDDYBUILD_PRODUCT_DIR/Release-iphoneos/$APP_NAME.app/Info.plist")
COMMIT_MSG="$(git log --format=oneline -n 1)"
echo -e "$APP_VER $COMMIT_MSG"
if [[ "$BUDDYBUILD_BRANCH" =~ "master" ]] || [[ "$BUDDYBUILD_BRANCH" =~ "staging" ]] || [[ "$BUDDYBUILD_BRANCH" =~ "development" ]]; then
echo "$BUDDYBUILD_BRANCH branch, preparing for BugSnag..."
echo "generating sourcemap"
cd $BUDDYBUILD_WORKSPACE
react-native bundle --platform ios --entry-file index.ios.js --dev false --bundle-output ./ios/main.jsbundle --sourcemap-output ./ios/main.jsbundle.map
echo -e "\n[BugSnag] Uploading sourcemap\n"
curl https://upload.bugsnag.com/ -F apiKey=$BUGSNAG_KEY -F appVersion=$APP_VER -F minifiedUrl="main.jsbundle" -F sourceMap=@$BUDDYBUILD_WORKSPACE/ios/main.jsbundle.map -F minifiedFile=@$BUDDYBUILD_WORKSPACE/ios/main.jsbundle -F overwrite=true -F /workspace/app/index.ios.js=@$BUDDYBUILD_WORKSPACE/index.ios.js
echo -e "\n[BugSnag] Done uploading sourcemap\n"
echo -e "\n[BugSnag] Uploading DSYM\n"
curl https://upload.bugsnag.com/ -F dsym=@"$BUDDYBUILD_PRODUCT_DIR/Release-iphoneos/$APP_NAME.app.dSYM/Contents/Resources/DWARF/$APP_NAME"
echo -e "\n[BugSnag] Done uploading DSYM\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment