Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload Dsyms to Sentry when building Alpha #6413

Merged
merged 7 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
DIAWI_API_TOKEN: ${{ secrets.DIAWI_API_TOKEN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

- name: Add or update PR comment with Ad-hoc release informations
uses: NejcZdovc/comment-pr@v1
Expand Down
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
brew "xcodegen"
brew "mint"
brew "getsentry/tools/sentry-cli"
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ GEM
fastlane-plugin-brew (0.1.1)
fastlane-plugin-diawi (2.1.0)
rest-client (>= 2.0.0)
fastlane-plugin-sentry (1.12.1)
fastlane-plugin-versioning (0.5.0)
fastlane-plugin-xcodegen (1.1.0)
fastlane-plugin-brew (~> 0.1.1)
Expand Down Expand Up @@ -310,10 +311,11 @@ DEPENDENCIES
cocoapods (~> 1.11.2)
fastlane
fastlane-plugin-diawi
fastlane-plugin-sentry
fastlane-plugin-versioning
fastlane-plugin-xcodegen
slather
xcode-install

BUNDLED WITH
2.3.9
2.3.14
1 change: 1 addition & 0 deletions changelog.d/pr-6413.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sentry: Upload Dsyms to Sentry when building Alpha
54 changes: 37 additions & 17 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ platform :ios do

desc "Builds an Alpha ipa for pull request branches"
lane :alpha do
# Check we have all the tokens and tools necessary
UI.user_error!("'DIAWI_API_TOKEN' environment variable should be set to use this lane") unless !ENV["DIAWI_API_TOKEN"].to_s.empty?
UI.user_error!("'SENTRY_AUTH_TOKEN' environment variable should be set to use this lane") unless !ENV["SENTRY_AUTH_TOKEN"].to_s.empty?
sentry_check_cli_installed

# Generate the "Alpha" app variant
setup_app_variant(name: "Alpha")
# Builds an Ad Hoc IPA
adhoc
# Upload to Diawi
upload_to_diawi

upload_dsyms_to_sentry
end

desc "Upload IPA to Diawi"
Expand Down Expand Up @@ -242,7 +247,7 @@ platform :ios do

# Clear derived data
clear_derived_data(derived_data_path: ENV["DERIVED_DATA_PATH"])

# Setup project provisioning profiles
download_provisioning_profiles(adhoc: adhoc)
disable_automatic_code_signing
Expand Down Expand Up @@ -441,6 +446,21 @@ platform :ios do
UI.command_output("Content of modified Podfile:\n" + podfile_content)
end

desc "Upload dsym files to Sentry to symbolicate crashes"
private_lane :upload_dsyms_to_sentry do
UI.user_error!("'SENTRY_AUTH_TOKEN' environment variable should be set to use this lane") unless !ENV["SENTRY_AUTH_TOKEN"].to_s.empty?

dsym_path = "#{ENV["BUILD_OUTPUT_DIRECTORY"]}/#{ENV["IPA_NAME"]}.app.dSYM.zip"

sentry_upload_dif(
auth_token: ENV["SENTRY_AUTH_TOKEN"],
org_slug: 'element',
project_slug: 'element-ios',
url: 'https://sentry.tools.element.io/',
path: dsym_path,
)
end

# git_branch can return an empty screen with some CI tools (like GH actions)
# The CI build script needs to define MX_GIT_BRANCH with the right branch.
def mx_git_branch
Expand All @@ -463,21 +483,21 @@ platform :ios do
end
end

# Update an arbitrary file by applying some RegExp replacements to its content
#
# @param [String] file The path to the file that needs replacing
# @param [Hash<RegExp, String>] replacements A list of replacements to apply
#
def update_file_content(file, replacements)
content = File.read(file)
replacements.each do |pattern, replacement|
content.gsub!(pattern, replacement)
end
File.write(file, content)
# Update an arbitrary file by applying some RegExp replacements to its content
#
# @param [String] file The path to the file that needs replacing
# @param [Hash<RegExp, String>] replacements A list of replacements to apply
#
def update_file_content(file, replacements)
content = File.read(file)
replacements.each do |pattern, replacement|
content.gsub!(pattern, replacement)
end
File.write(file, content)
end

# Generates a new build number based on timestamp
def generate_build_number()
require 'date'
return DateTime.now.strftime("%Y%m%d%H%M%S")
end
# Generates a new build number based on timestamp
def generate_build_number()
require 'date'
return DateTime.now.strftime("%Y%m%d%H%M%S")
end
2 changes: 2 additions & 0 deletions fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
gem 'fastlane-plugin-versioning'
gem 'fastlane-plugin-xcodegen'
gem 'fastlane-plugin-diawi'
gem 'fastlane-plugin-sentry'