@@ -297,35 +297,44 @@ platform :android do
297
297
end
298
298
end
299
299
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
301
301
#
302
302
# @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`.
303
304
#
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)
308
317
309
318
not_found_variants = [ ]
310
319
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 )
313
322
upload_to_play_store (
314
323
**UPLOAD_TO_PLAY_STORE_COMMON_OPTIONS ,
315
324
skip_upload_aab : true ,
316
- track : track ,
317
- version_code : version_code ,
325
+ track : variant_track ,
326
+ version_code : variant_version_code ,
318
327
release_status : percent . to_f < 1.0 ? 'inProgress' : 'completed' ,
319
328
rollout : percent . to_s
320
329
)
321
330
rescue FastlaneCore ::Interface ::FastlaneError => e
322
331
raise unless e . message =~ /Unable to find the requested release on track/
323
332
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"
325
334
end
326
335
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 )
329
338
end
330
339
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
331
340
end
0 commit comments