diff --git a/fastlane/Fastfile b/fastlane/Fastfile index dee9596da..0886ce4bd 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -187,6 +187,32 @@ lane :configure do configured = true end +desc 'Set Sentry upload properties' +lane :link_sentry do |options| + if ENV['SENTRY_ENABLED'] == 'true' + os_type = options[:os_type].downcase + if os_type == 'ios' + project_dir = 'ios/' + sentry_project = ENV['SENTRY_PROJECT_IOS'] + elsif os_type == 'android' + project_dir = 'android/' + sentry_project = ENV['SENTRY_PROJECT_ANDROID'] + end + url = ENV['SENTRY_URL'] || 'https://sentry.io' + File.open("../#{project_dir}sentry.properties", 'w+') do |f| + UI.message('Creating sentry.properties from environment') + f.write( + "defaults.url=#{url}\n"\ + "defaults.org=#{ENV['SENTRY_ORG']}\n"\ + "defaults.project=#{sentry_project}\n"\ + "auth.token=#{ENV['SENTRY_AUTH_TOKEN']}\n" + ) + end + else + UI.message('Not creating sentry.properties because Sentry is disabled') + end +end + desc 'Upload file to s3' lane :upload_file_to_s3 do |options| os_type = options[:os_type].downcase @@ -347,6 +373,7 @@ platform :ios do end update_identifiers replace_assets + link_sentry({:os_type => "ios"}) build_ios upload_file_to_s3({:os_type => "ios"}) end @@ -586,7 +613,7 @@ platform :ios do config_mode = ENV['BUILD_FOR_RELEASE'] == 'true' ? 'Release' : 'Debug' method = ENV['IOS_BUILD_EXPORT_METHOD'].nil? || ENV['IOS_BUILD_EXPORT_METHOD'].empty? ? 'ad-hoc' : ENV['IOS_BUILD_EXPORT_METHOD'] - # Need to add xcargs to only notification and + # Need to add xcargs to only notification and share extensions xcargs = ENV['SENTRY_ENABLED'] == 'true' ? "SENTRY_DSN_IOS='#{ENV['SENTRY_DSN_IOS']}' SENTRY_ENABLED='#{ENV['SENTRY_ENABLED']}'" : '' setup_code_signing @@ -604,7 +631,7 @@ platform :ios do signingStyle: 'manual', iCloudContainerEnvironment: 'Production' }, - xcargs:xcargs + xcargs: xcargs ) end @@ -636,7 +663,7 @@ platform :android do end update_identifiers replace_assets - link_sentry_android + link_sentry({:os_type => "android"}) build_android move_android_to_root upload_file_to_s3({:os_type => "android"}) @@ -849,23 +876,6 @@ platform :android do UI.message("AAB PATH \"#{new_aab_path}\"") end end - - def link_sentry_android - if ENV['SENTRY_ENABLED'] == 'true' - url = 'https://sentry.io' - File.open('../android/sentry.properties', 'w+') do |f| - UI.message('Creating sentry.properties from environment') - f.write( - "defaults.url=#{url}\n"\ - "defaults.org=#{ENV['SENTRY_ORG']}\n"\ - "defaults.project=#{ENV['SENTRY_PROJECT_ANDROID']}\n"\ - "auth.token=#{ENV['SENTRY_AUTH_TOKEN']}\n" - ) - end - else - UI.message('Not creating sentry.properties because Sentry is disabled') - end - end end def load_config_json(json_path) diff --git a/fastlane/env_vars_example b/fastlane/env_vars_example index a3d535b36..2d9b33f4e 100644 --- a/fastlane/env_vars_example +++ b/fastlane/env_vars_example @@ -63,6 +63,7 @@ export SUBMIT_ANDROID_TO_GOOGLE_PLAY=false ############ OPTIONAL ############ #export SENTRY_ENABLED= +#export SENTRY_URL= #export SENTRY_ORG= #export SENTRY_PROJECT_IOS= #export SENTRY_DSN_IOS= diff --git a/ios/bundleReactNative.sh b/ios/bundleReactNative.sh index 250ef1d5d..7bd2256f7 100755 --- a/ios/bundleReactNative.sh +++ b/ios/bundleReactNative.sh @@ -9,8 +9,6 @@ export ENTRY_FILE="index.ts" if [[ "${SENTRY_ENABLED}" = "true" ]]; then echo "Sentry native integration is enabled" - ./makeSentryProperties.sh - export SENTRY_PROPERTIES=sentry.properties ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \ ../node_modules/react-native/scripts/react-native-xcode.sh diff --git a/ios/makeSentryProperties.sh b/ios/makeSentryProperties.sh deleted file mode 100755 index 3fd2596ab..000000000 --- a/ios/makeSentryProperties.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -sentry_properties="defaults.url=https://sentry.io -defaults.org=${SENTRY_ORG} -defaults.project=${SENTRY_PROJECT_IOS} -auth.token=${SENTRY_AUTH_TOKEN} -cli.executable=../node_modules/@sentry/cli/bin/sentry-cli" - -if [[ "${SENTRY_ENABLED}" = "true" ]]; then - if [[ ! -f "sentry.properties" ]]; then - echo "Creating sentry.properties from environment" - - echo "${sentry_properties}" > sentry.properties - else - echo "sentry.properties already exists" - fi -else - echo "Not creating sentry.properties because Sentry is disabled" -fi diff --git a/ios/uploadDebugSymbols.sh b/ios/uploadDebugSymbols.sh index 348deb8d9..7cdde24f4 100755 --- a/ios/uploadDebugSymbols.sh +++ b/ios/uploadDebugSymbols.sh @@ -3,10 +3,8 @@ if [[ "${SENTRY_ENABLED}" = "true" ]]; then echo "Uploading debugging symbols to Sentry" - ./makeSentryProperties.sh - export SENTRY_PROPERTIES=sentry.properties -../node_modules/@sentry/cli/bin/sentry-cli upload-dif "$DWARF_DSYM_FOLDER_PATH" + ../node_modules/@sentry/cli/bin/sentry-cli upload-dif "$DWARF_DSYM_FOLDER_PATH" else echo "Not uploading debugging symbols to Sentry because Sentry is disabled"