Skip to content

Commit b745e23

Browse files
authored
[Tooling] Allow update_rollouts to specify the track to update (#3488)
1 parent f25255d commit b745e23

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

fastlane/Fastfile

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,35 +297,44 @@ platform :android do
297297
end
298298
end
299299

300-
# Update the rollout of all 3 variants (app, automotive, wear) of the current version to the given value
300+
# Update the rollout of all 3 variants/form-factors (app, automotive, wear) of the latest builds of the given Google Play track to the given % value
301301
#
302302
# @param percent [Float] The rollout percentage, between 0 and 1
303+
# @param track [String] The Google Play track for which to update the rollout of. Must be either `beta` or `production`.
303304
#
304-
lane :update_rollouts do |percent:|
305-
version = version_name_current
306-
build_code = build_code_current
307-
is_beta = beta_version?(version)
305+
lane :update_rollouts do |percent:, track:|
306+
UI.user_error!('percent parameter must be between 0.0 and 1.0') if percent.to_f.negative? || percent.to_f > 1
307+
UI.user_error!('track parameter must be either `beta` or `production`') unless %w[beta production].include?(track)
308+
309+
is_beta = track == 'beta'
310+
# Use Google Play API to find the latest versionCode for the requested track
311+
prod_version_codes = google_play_track_version_codes(
312+
package_name: APP_PACKAGE_NAME,
313+
track: track,
314+
json_key: UPLOAD_TO_PLAY_STORE_JSON_KEY
315+
)
316+
base_version_code = prod_version_codes.max # Use the latest (as there's likely to be 2: the previous one already at 100%, and the latest one with partial rollout)
308317

309318
not_found_variants = []
310319
APPS.each do |app|
311-
track = play_store_track(app: app, is_beta: is_beta)
312-
version_code = version_code_for_app(app: app, version_code: build_code)
320+
variant_track = play_store_track(app: app, is_beta: is_beta)
321+
variant_version_code = version_code_for_app(app: app, version_code: base_version_code)
313322
upload_to_play_store(
314323
**UPLOAD_TO_PLAY_STORE_COMMON_OPTIONS,
315324
skip_upload_aab: true,
316-
track: track,
317-
version_code: version_code,
325+
track: variant_track,
326+
version_code: variant_version_code,
318327
release_status: percent.to_f < 1.0 ? 'inProgress' : 'completed',
319328
rollout: percent.to_s
320329
)
321330
rescue FastlaneCore::Interface::FastlaneError => e
322331
raise unless e.message =~ /Unable to find the requested release on track/
323332

324-
not_found_variants << app
333+
not_found_variants << "'#{app}' variant with version code `#{variant_version_code}` was not found in `#{variant_track}` track in Google Play Console"
325334
end
326335

327-
not_found_variants.each do |app|
328-
UI.important("'#{app}' variant for `#{version}` was not found in Google Play Console")
336+
not_found_variants.each do |message|
337+
UI.important(message)
329338
end
330339
UI.user_error!('None of the 3 app variants were found in Google Play Console. We expected at least one') if not_found_variants.count == APPS.count
331340
end

0 commit comments

Comments
 (0)