Skip to content

Commit 60e2613

Browse files
authored
Merge pull request #3789 from StoDevX/fix-sourcemap-association
(Try to) Fix Sentry sourcemap association
2 parents 487af03 + 6e90255 commit 60e2613

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

fastlane/lib/sourcemaps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def upload_sourcemap_to_sentry
5454
'files',
5555
current_bundle_version,
5656
'upload-sourcemaps',
57-
"--dist #{current_bundle_version}",
57+
"--dist #{current_bundle_code}",
5858
"--strip-prefix #{File.expand_path(File.join(__FILE__, '..', '..', '..'))}",
5959
'--rewrite',
6060
args[:sourcemap_output]

fastlane/lib/versions.rb

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
# Gets the version, be it from Travis, Testflight, or Google Play
2-
def current_build_number(**args)
3-
return build_number if build_number
4-
5-
begin
6-
case lane_context[:PLATFORM_NAME]
7-
when :android
8-
(google_play_track_version_codes(track: args[:track]) + 1).to_s
9-
when :ios
10-
(latest_testflight_build_number + 1).to_s
11-
end
12-
rescue StandardError
13-
'1'
14-
end
15-
end
16-
17-
# get the current build number from the environment
18-
def build_number
19-
travis = ENV['TRAVIS_BUILD_NUMBER']
20-
# bring circle's build numbers up to pass Travis'?
21-
circle = (ENV['CIRCLE_BUILD_NUM'].to_i + 3250).to_s
22-
travis || circle
23-
end
24-
251
# Get the current "app bundle" version
262
def current_bundle_version
273
case lane_context[:PLATFORM_NAME]
@@ -35,23 +11,42 @@ def current_bundle_version
3511
end
3612
end
3713

14+
# Get the current "app bundle" version code (mostly for Sentry)
15+
def current_bundle_code
16+
case lane_context[:PLATFORM_NAME]
17+
when :android
18+
get_gradle_version_code(gradle_path: lane_context[:GRADLE_FILE])
19+
when :ios
20+
get_info_plist_value(path: 'ios/AllAboutOlaf/Info.plist',
21+
key: 'CFBundleVersion')
22+
else
23+
raise 'wtf'
24+
end
25+
end
26+
27+
# Generate build number
28+
def generate_build_numbers
29+
build = (ENV['CIRCLE_BUILD_NUM'].to_i + 3250).to_s
30+
31+
# android's build number goes way up because we need to exceed the old build
32+
# numbers generated for the x86 build.
33+
ci_build_num = build
34+
build = ((2 * 1_048_576) + build.to_i).to_s if lane_context[:PLATFORM_NAME] == :android
35+
36+
{ci: ci_build_num, build: build}
37+
end
38+
3839
# Copy the package.json version into the other version locations
3940
def propagate_version(**args)
4041
return unless ENV.key? 'CI'
4142

4243
version = get_package_key(key: :version)
43-
build = current_build_number(track: args[:track] || nil)
4444

4545
UI.message "Propagating version: #{version}"
4646
UI.message 'into the Info.plist and build.gradle files'
4747

48-
UI.message "Setting build number to #{build}"
49-
50-
# android's build number goes way up because we need to exceed the old build
51-
# numbers generated for the x86 build.
52-
ci_build_num = build
53-
build = ((2 * 1_048_576) + build.to_i).to_s if lane_context[:PLATFORM_NAME] == :android
54-
UI.message "Actually setting build number to #{build} because we're on android"
48+
build_numbers = generate_build_numbers
49+
UI.message "Version codes are {CI: #{build_numbers[:ci]}, distribution: #{build_numbers[:build]}}"
5550

5651
version = "#{version.split('-')[0]}-pre" if should_nightly?
5752
UI.message "Actually putting #{version} into the binaries (because we're doing a nightly)"
@@ -60,16 +55,16 @@ def propagate_version(**args)
6055
# never set the "+" into the binaries
6156
unless version.include? '+'
6257
# we always want the CI build number in js-land
63-
set_package_data(data: { version: "#{version}+#{ci_build_num}" })
58+
set_package_data(data: { version: "#{version}+#{build_numbers[:ci]}" })
6459
end
6560

6661
case lane_context[:PLATFORM_NAME]
6762
when :android
6863
set_gradle_version_name(version_name: version, gradle_path: lane_context[:GRADLE_FILE])
69-
set_gradle_version_code(version_code: build, gradle_path: lane_context[:GRADLE_FILE])
64+
set_gradle_version_code(version_code: build_numbers[:build], gradle_path: lane_context[:GRADLE_FILE])
7065
when :ios
7166
# we're splitting here because iTC can't handle versions with dashes in them
7267
increment_version_number(version_number: version.split('-')[0], xcodeproj: ENV['GYM_PROJECT'])
73-
increment_build_number(build_number: build, xcodeproj: ENV['GYM_PROJECT'])
68+
increment_build_number(build_number: build_numbers[:build], xcodeproj: ENV['GYM_PROJECT'])
7469
end
7570
end

0 commit comments

Comments
 (0)