1616default_platform ( :android )
1717
1818platform :android do
19+ def with_retries ( times : 3 , sleep_time : 10 )
20+ tries = 0
21+ begin
22+ yield
23+ rescue => e
24+ tries += 1
25+ if tries < times
26+ UI . error ( "Retrying due to error: #{ e } " )
27+ sleep ( sleep_time )
28+ retry
29+ else
30+ raise
31+ end
32+ end
33+ end
34+
1935 desc 'Get the highest version code from all tracks'
2036 lane :version_code do |options |
21- production_versions = google_play_track_version_codes (
22- package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
23- json_key : 'service_account.json' ,
24- track : 'production'
25- )
37+ production_versions = with_retries do
38+ google_play_track_version_codes (
39+ package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
40+ json_key : 'service_account.json' ,
41+ track : 'production'
42+ )
43+ end
2644
27- beta_versions = google_play_track_version_codes (
28- package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
29- json_key : 'service_account.json' ,
30- track : 'beta'
31- )
45+ beta_versions = with_retries do
46+ google_play_track_version_codes (
47+ package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
48+ json_key : 'service_account.json' ,
49+ track : 'beta'
50+ )
51+ end
3252
33- alpha_versions = google_play_track_version_codes (
34- package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
35- json_key : 'service_account.json' ,
36- track : 'alpha'
37- )
53+ alpha_versions = with_retries do
54+ google_play_track_version_codes (
55+ package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
56+ json_key : 'service_account.json' ,
57+ track : 'alpha'
58+ )
59+ end
3860
39- internal_versions = google_play_track_version_codes (
40- package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
41- json_key : 'service_account.json' ,
42- track : 'internal'
43- )
61+ internal_versions = with_retries do
62+ google_play_track_version_codes (
63+ package_name : options [ :official ] ? 'chat.rocket.android' : 'chat.rocket.reactnative' ,
64+ json_key : 'service_account.json' ,
65+ track : 'internal'
66+ )
67+ end
4468
4569 all_versions = production_versions + beta_versions + alpha_versions + internal_versions
4670 highest_version = all_versions . max
@@ -50,7 +74,6 @@ platform :android do
5074 UI . success ( "Highest + 1: #{ highest_version + 1 } " )
5175
5276 next_version = highest_version + 1
53-
5477 puts next_version
5578 end
5679
0 commit comments