Skip to content

Commit

Permalink
feat(ci): switch sentry sourcemap upload to wizard management
Browse files Browse the repository at this point in the history
  • Loading branch information
QcFe committed Feb 27, 2025
1 parent 4cf319d commit f1a5405
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 59 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,35 @@ jobs:
run: |
echo "${{ secrets.SUPPLY_GOOGLE_JSON_SECRET }}" | base64 -d > ${SUPPLY_GOOGLE_JSON_PATH}
echo "${{ secrets.ANDROID_KEYSTORE_B64 }}" | base64 -d > ${KEYSTORE_PATH}
echo "${{ secrets.SENTRY_DOT_PROPERTIES }}" | base64 -d > sentry.properties
chmod 600 ${KEYSTORE_PATH} ${SUPPLY_GOOGLE_JSON_PATH}
- name: Fastlane VERIFY lane
if: needs.configure.outputs.push_to_playstore == 'false'
working-directory: ./android
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
run: bundle exec fastlane verify
- name: Fastlane RELEASE lane
id: fastlane_release_android
if: contains(fromJSON('["internal", "beta", "production"]'), needs.configure.outputs.push_to_playstore)
working-directory: ./android
env:
STORE_TRACK: ${{ needs.configure.outputs.push_to_playstore }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
run: bundle exec fastlane release
- name: Fastlane RELEASE lane [without Sentry]
if: steps.fastlane_release_android.outcome == 'failure'
working-directory: ./android
run: bundle exec fastlane release
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
- name: Fastlane APK lane
if: |
(github.event_name == 'push' && github.ref_type == 'tag') ||
github.event.inputs.create_release == 'true'
run: bundle exec fastlane apk
working-directory: ./android
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
- name: Upload Artifacts
if: |
(github.event_name == 'push' && github.ref_type == 'tag') ||
Expand Down Expand Up @@ -293,21 +302,27 @@ jobs:
echo "${{ secrets.MATCH_GIT_AUTH_PK }}" > ${MATCH_GIT_PRIVATE_KEY}
chmod 600 ${MATCH_GIT_PRIVATE_KEY}
echo "${{ secrets.SUPPLY_GOOGLE_SERVICE_INFO_PLIST }}" | base64 -d > ${SUPPLY_GOOGLE_SERVICE_INFO_PLIST_PATH}
echo "${{ secrets.SENTRY_DOT_PROPERTIES }}" | base64 -d > sentry.properties
chmod 600 ${MATCH_GIT_PRIVATE_KEY} ${SUPPLY_GOOGLE_SERVICE_INFO_PLIST_PATH}
- name: Fastlane VERIFY lane
if: needs.configure.outputs.push_to_testflight == 'false'
working-directory: ./ios
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
run: |
bundle exec fastlane verify
- name: Fastlane RELEASE lane
id: fastlane_release_ios
if: needs.configure.outputs.push_to_testflight == 'true'
working-directory: ./ios
run: bundle exec fastlane release
continue-on-error: true
- name: Fastlane RELEASE lane [without Sentry]
if: steps.fastlane_release_ios.outcome == 'failure'
working-directory: ./ios
run: bundle exec fastlane release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
run: |
bundle exec fastlane release
SENTRY_DISABLE_AUTO_UPLOAD: "true"

create-release:
name: Create GitHub Release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ npm-debug.*
/ios/fastlane/report.xml

.npmrc
android/sentry.properties
ios/sentry.properties
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.20.2
18.20.7
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-sentry (1.27.1)
os (~> 1.1, >= 1.1.4)
fastlane-plugin-versioning_android (0.1.1)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
Expand Down Expand Up @@ -295,7 +293,6 @@ DEPENDENCIES
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
concurrent-ruby (< 1.3.4)
fastlane
fastlane-plugin-sentry
fastlane-plugin-versioning_android
xcodeproj (< 1.26.0)

Expand Down
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def enableProguardInReleaseBuilds = false
*/
def jscFlavor = 'org.webkit:android-jsc:+'

apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")

android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
Expand Down
28 changes: 7 additions & 21 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ buildProps = {
}

platform :android do

desc "Build and sign bundle"
lane :verify do
gradle(
Expand All @@ -43,31 +42,18 @@ platform :android do
properties: buildProps,
)

upload_to_play_store(
track: ENV['STORE_TRACK'],
release_status: "draft",
)

source_map_path = 'app/build/generated/sourcemaps/react/release/index.android.bundle.map'
bundle_path = 'app/build/generated/assets/createBundleReleaseJsAndAssets/index.android.bundle'
upload_to_play_store(
track: ENV['STORE_TRACK'],
release_status: "draft",
)

begin
sentry_upload_sourcemap(
auth_token: ENV['SENTRY_AUTH_TOKEN'],
org_slug: ENV['SENTRY_ORG'],
project_slug: ENV['SENTRY_PROJECT'],
version: 'it.polito.students@' + ENV['APP_VERSION'],
dist: ENV['BUILD_NO'],
sourcemap: [bundle_path, source_map_path],
rewrite: true
)
rescue => e
UI.important("Sentry sourcemap upload failed => #{e.message}")
end
end

desc "Assemble signed Android APK"
lane :apk do
android_set_version_name(version_name: ENV['APP_VERSION'])
android_set_version_code(version_code: ENV['BUILD_NO'])

gradle(
task: "assembleRelease",
properties: buildProps,
Expand Down
1 change: 0 additions & 1 deletion android/fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-versioning_android'
gem 'fastlane-plugin-sentry'
15 changes: 0 additions & 15 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ platform :ios do
apple_id: "6443913305",
)

source_map_path = '../../main.jsbundle.map'

begin
sentry_upload_sourcemap(
auth_token: ENV['SENTRY_AUTH_TOKEN'],
org_slug: ENV['SENTRY_ORG'],
project_slug: ENV['SENTRY_PROJECT'],
version: 'it.polito.students@' + ENV['APP_VERSION'],
dist: ENV['BUILD_NO'],
sourcemap: [source_map_path],
rewrite: true
)
rescue => e
UI.important("Sentry sourcemap upload failed => #{e.message}")
end
end

lane :verify do
Expand Down
1 change: 0 additions & 1 deletion ios/fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!
gem 'fastlane-plugin-sentry'
2 changes: 1 addition & 1 deletion ios/students.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export SOURCEMAP_FILE=\"../main.jsbundle.map\";\n\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\"\"\n";
};
085B7CE994A953E0D75AFD27 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
8 changes: 6 additions & 2 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const { withSentryConfig } = require('@sentry/react-native/metro');

/**
* Metro configuration
Expand All @@ -8,4 +10,6 @@ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
*/
const config = {};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
module.exports = withSentryConfig(
mergeConfig(getDefaultConfig(__dirname), config),
);
10 changes: 4 additions & 6 deletions src/utils/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { APP_BUILD, APP_VERSION } from '@env';
import * as Sentry from '@sentry/react-native';

import { isEnvProduction } from './env';

export const routingInstrumentation =
new Sentry.ReactNavigationInstrumentation();
export const routingInstrumentation = Sentry.reactNavigationIntegration({
enableTimeToInitialDisplay: true,
});

export const initSentry = () => {
Sentry.init({
dsn: 'https://0b3fe6c2fc0bd91481a14b1ad5c6b00d@sentry.k8s.polito.it/3',
enabled: isEnvProduction,
enableNative: true,
integrations: [
new Sentry.ReactNativeTracing({
Sentry.reactNativeTracingIntegration({
routingInstrumentation,
}),
],
release: `it.polito.students@${APP_VERSION}`,
dist: APP_BUILD,
environment: process.env.NODE_ENV,
tracesSampleRate: 1.0,
});
Expand Down

0 comments on commit f1a5405

Please sign in to comment.