fastlane-plugin-get_new_build_number 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 979fa803d1b127d9876efe95a9c1d167abc582c657db6f91491125c76aa9c33a
4
- data.tar.gz: a5c519939cd2a7781beda1ab42eae03a0923e88596328a6ad249a19a0998386c
3
+ metadata.gz: 67d1c54a512da268d76be07efd79c59d2f408fd5d819cc01e197502b266158bb
4
+ data.tar.gz: 13b1dbab9cf2abb03640946e7844b2a6dada623c9ced316669ab398a0f838eb6
5
5
  SHA512:
6
- metadata.gz: ed8d8a6be9b37690b1bd4a330f7bdfabc1243193d11b71ddd428155d2ee9cfb61bc961920a95d899ca1aa14955539e761dc99d30c2221a8ca651a8ad39d19c77
7
- data.tar.gz: 92d1062ddf34c2287b371e20d52cd0c727bf930a8c7b7fc58dba7ec601ee380d02790de84ea97dc341a374df9063b016b1714b07d7844946b013c7c4026e0cb2
6
+ metadata.gz: 266b82fc7073c011d2c530cbcd2aae2426987d101e2139dc004ad369c8302a8857634870d96fcfaa5180f39b73d998b243cf76e0337df67a353a20fe4abdbdc6
7
+ data.tar.gz: a0b2a74cdd03d216d26c4308ecbc44c685837b917f3336df036c52fee85c0862effc3da789950499d784eac5893e704494cfa85ce3334a665d1e8048669d2f56
data/LICENSE CHANGED
@@ -1,21 +1,20 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Bartek Pacia <barpac02@gmail.com>
3
+ Copyright (c) 2022 Bartek Pacia @bartekpacia
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,52 +1,224 @@
1
1
  # get_new_build_number plugin
2
2
 
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-get_new_build_number)
3
+ [![fastlane Plugin Badge][fastlane-plugin-badge]][fastlane-plugin]
4
4
 
5
- ## Getting Started
5
+ I've often found myself wanting to _just assign new build number_ to my apps.
6
+ This simple task turns out to be harder that it seems at first. There's a
7
+ production build number (on App Store and Google Play), you might also have
8
+ separate build numbers for beta, alpha, and other versions of your app.
9
+
10
+ Fortunately, all of these services provide fastlane actions to get the latest
11
+ build number.
12
+
13
+ Unfortunately, every service provides app's build number in a bit different
14
+ format, which makes it not-so-straightforward to get the latest-latest version
15
+ number.
16
+
17
+ This is my take at automating this.
18
+
19
+ ### Features
20
+
21
+ Supported services:
22
+
23
+ - [x] App Store (via [app_store_build_number][app-store])
24
+ - [x] TestFlight (via [latest_testflight_build_number][testflight])
25
+ - [x] Google Play (via [google_play_track_version_codes][google-play])
26
+ - [x] Firebase App Distribution (via
27
+ [firebase_app_distribution_get_latest_release][fad])
28
+ - [ ] App Center (via [appcenter_fetch_version_number][app-center])
6
29
 
7
- This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-get_new_build_number`, add it to your project by running:
30
+ The _latest_ build number is persisted in
31
+ [$TMPDIR][ruby-tmpdir]`/latest_build_number.txt`, so you can use it across
32
+ `fastlane` invocations. For example, you could safely do:
8
33
 
9
34
  ```bash
35
+ $ cd ios && bundle exec fastlane prod && cd ..
36
+ $ cd android && bundle exec fastlane prod && cd ..
37
+ $ cd symbian && bundle exec fastlane prod && cd .. # lol
38
+ ```
39
+
40
+ The first `fastlane` invocation retrieves the _latest_ build number. Then, the 2
41
+ subsequent invocations simply reuse the _latest_ build number from the file.
42
+
43
+ The _new_ build number is derived using this complex forumla:
44
+
45
+ ```
46
+ new_build_number = latest_build_number + 1
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Example 1
52
+
53
+ Simple use case. This will only take the latest version from Google Play. This
54
+ might not seem very useful at first, but is _is_ when you have different version
55
+ codes for different tracks (`production`, `beta`, `alpha`, `internal`).
56
+
57
+ Let's say that your Play Console looks like this:
58
+
59
+ - `production` is at version code `60`
60
+ - `beta` is at version code `61`
61
+ - `alpha` is at 2 version codes: `64` and `65` (becasue you're doing some fancy
62
+ testing)
63
+
64
+ In this case, `get_new_build_number` action would return `66` (because it is
65
+ newer/higher/bigger than all the other build numbers).
66
+
67
+ ```ruby
68
+ # android/fastlane/Fastfile
69
+
70
+ default_platform(:android)
71
+
72
+ platform :android do
73
+ desc "Deploy a new beta version to Google Play"
74
+ lane :beta do
75
+ build_number = get_new_build_number(
76
+ package_name: ENV["APP_PACKAGE_NAME"], # e.g com.example.yourapp
77
+ google_play_json_key_path: ENV["GOOGLE_PLAY_JSON_KEY_PATH"], # path to JSON key for authenticating with Google Play Android Developer API
78
+ ).to_s
79
+
80
+ build_android_app(
81
+ task: "bundleRelease",
82
+ project_dir: "..",
83
+ properties: {
84
+ "android.injected.version.code" => build_number,
85
+ },
86
+ )
87
+
88
+ upload_to_play_store(
89
+ track: "beta",
90
+ aab: "./build/outputs/bundle/release/android-release.aab",
91
+ json_key: ENV["GOOGLE_PLAY_JSON_KEY_PATH"],
92
+ )
93
+ end
94
+ end
95
+ ```
96
+
97
+ ### Example 2
98
+
99
+ If you provide more parameters, the plugin will take them into account. For
100
+ example, if you pass `bundle_identifier` to `get_new_build_number`:
101
+
102
+ ```ruby
103
+ platform :android do
104
+ desc "Deploy a new beta version to Google Play"
105
+ lane :beta do
106
+ build_number = get_new_build_number(
107
+ bundle_identifier: ENV["APP_BUNDLE_ID"], # e.g com.example.yourApp
108
+ package_name: ENV["APP_PACKAGE_NAME"], # e.g com.example.yourapp
109
+ google_play_json_key_path: ENV["GOOGLE_PLAY_JSON_KEY_PATH"], # path to JSON key for authenticating with Google Play Android Developer API
110
+ ).to_s
111
+
112
+ build_android_app(
113
+ task: "bundleRelease",
114
+ project_dir: "..",
115
+ properties: {
116
+ "android.injected.version.code" => build_number,
117
+ },
118
+ )
119
+
120
+ upload_to_play_store(
121
+ track: "beta",
122
+ aab: "./build/outputs/bundle/release/android-release.aab",
123
+ json_key: ENV["GOOGLE_PLAY_JSON_KEY_PATH"],
124
+ )
125
+ end
126
+ end
127
+ ```
128
+
129
+ then also build numbers in App Store will be taken into account.
130
+
131
+ Building on the previous example, let's say that your Play Console looks like
132
+ this (same as before):
133
+
134
+ - `production` is at version code `60`
135
+ - `beta` is at version code `61`
136
+ - `alpha` is at 2 version codes: `64` and `65` (becasue you're doing some fancy
137
+ testing)
138
+
139
+ And let's say that you App Store looks like this:
140
+
141
+ - production is live at version code `81`
142
+
143
+ In this case, `get_new_build_number` action would return `82` (because it is
144
+ newer/higher/bigger than all the other build numbers). Of course, you have to be
145
+ authenticated to App Store using
146
+ [app_store_connect_api_key][app-store-connect-api-key].
147
+
148
+ This makes it easy to keep version codes in sync in your app across different
149
+ app stores.
150
+
151
+ ### Important note
152
+
153
+ Please note that this action is simple and has no protection against concurrent
154
+ builds. Is is probably unsafe to use in an environment when many releases happen
155
+ in a short time frame.
156
+
157
+ ## Getting Started
158
+
159
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
160
+ get started with `fastlane-plugin-get_new_build_number`, add it to your project
161
+ by running:
162
+
163
+ ```
164
+
10
165
  fastlane add_plugin get_new_build_number
166
+
11
167
  ```
12
168
 
13
169
  ## About get_new_build_number
14
170
 
15
171
  Retrieves the new build number for your app.
16
172
 
17
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
173
+ This plugin provides a single action, `get_new_build_number`. For now, see
174
+ source code to learn how to use it. I might write some docs later.
18
175
 
19
176
  ## Example
20
177
 
21
- Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
178
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this
179
+ plugin. Try it by cloning the repo, running `fastlane install_plugins` and
180
+ `bundle exec fastlane test`.
22
181
 
23
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
182
+ **Note to author:** Please set up a sample project to make it easy for users to
183
+ explore what your plugin does. Provide everything that is necessary to try out
184
+ the plugin in this project (including a sample Xcode/Android project if
185
+ necessary)
24
186
 
25
187
  ## Run tests for this plugin
26
188
 
27
189
  To run both the tests, and code style validation, run
28
190
 
29
191
  ```
192
+
30
193
  rake
194
+
31
195
  ```
32
196
 
33
197
  To automatically fix many of the styling issues, use
198
+
34
199
  ```
200
+
35
201
  rubocop -a
202
+
36
203
  ```
37
204
 
38
205
  ## Issues and Feedback
39
206
 
40
- For any other issues and feedback about this plugin, please submit it to this repository.
207
+ For any other issues and feedback about this plugin, please submit it to this
208
+ repository.
41
209
 
42
210
  ## Troubleshooting
43
211
 
44
- If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
-
46
- ## Using _fastlane_ Plugins
47
-
48
- For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
-
50
- ## About _fastlane_
51
-
52
- _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
212
+ If you have trouble using plugins, check out the [Plugins
213
+ Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/)
214
+ guide.
215
+
216
+ [fastlane-plugin-badge]: https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg
217
+ [fastlane-plugin]: https://rubygems.org/gems/fastlane-plugin-get_new_build_number
218
+ [ruby-tmpdir]: https://ruby-doc.org/stdlib-2.5.1/libdoc/tmpdir/rdoc/Dir.html#method-c-tmpdir
219
+ [app-store]: https://docs.fastlane.tools/actions/app_store_build_number
220
+ [testflight]: https://docs.fastlane.tools/actions/latest_testflight_build_number
221
+ [google-play]: https://docs.fastlane.tools/actions/google_play_track_version_codes
222
+ [fad]: https://github.com/fastlane/fastlane-plugin-firebase_app_distribution/blob/master/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb
223
+ [app-center]: https://github.com/microsoft/fastlane-plugin-appcenter/blob/master/lib/fastlane/plugin/appcenter/actions/appcenter_fetch_version_number.rb
224
+ [app-store-connect-api-key]: https://docs.fastlane.tools/actions/app_store_connect_api_key
@@ -14,38 +14,39 @@ module Fastlane
14
14
  UI.message("firebase_app_ios: #{params[:firebase_app_ios]}")
15
15
  UI.message("firebase_app_android: #{params[:firebase_app_android]}")
16
16
 
17
- file = "#{Dir.tmpdir}/highest_build_number.txt"
18
- UI.message "Temp file location: #{file}"
17
+ file = "#{Dir.tmpdir}/latest_build_number.txt"
18
+ UI.message("Temporary file location: #{file}")
19
19
 
20
- if(File.exist?(file))
21
- UI.success "File with new number file exists. Reading build number from it..."
22
- highest_build_number = File.read(file).to_i
23
- else
24
- UI.message "File with new build number does not exist. New build number will be "\
25
- "retrieved and file with it will be created."
26
- highest_build_number = Helper::GetNewBuildNumberHelper.get_highest_build_number(
20
+ if File.exist?(file)
21
+ UI.success("File with new number file exists. Reading build number from it...")
22
+ latest_build_number = File.read(file).to_i
23
+ else
24
+ UI.message("File with new build number does not exist. New build number will be " \
25
+ "retrieved and temporary file with it will be created.")
26
+ latest_build_number = Helper::GetNewBuildNumberHelper.get_latest_build_number(
27
27
  bundle_identifier: params[:bundle_identifier],
28
28
  package_name: params[:package_name],
29
29
  google_play_json_key_path: params[:google_play_json_key_path],
30
+ app_store_initial_build_number: params[:app_store_initial_build_number],
30
31
  firebase_json_key_path: params[:firebase_json_key_path],
31
32
  firebase_app_ios: params[:firebase_app_ios],
32
- firebase_app_android: params[:firebase_app_android],
33
+ firebase_app_android: params[:firebase_app_android]
33
34
  )
34
-
35
+
35
36
  File.open(file, "w") do |f|
36
- f.write "#{highest_build_number}\n"
37
- UI.message "Wrote #{highest_build_number} to #{file}"
37
+ f.write("#{latest_build_number}\n")
38
+ UI.message("Wrote #{latest_build_number} to #{file}")
38
39
  end
39
40
  end
40
41
 
41
- UI.success "Highest build number: #{highest_build_number}"
42
+ UI.success("Latest build number: #{latest_build_number}")
42
43
 
43
- if highest_build_number.is_a? Integer
44
- new_highest_build_number = highest_build_number + 1
45
- UI.success "New build number: #{new_highest_build_number}"
46
- return new_highest_build_number
44
+ if latest_build_number.kind_of?(Integer)
45
+ new_latest_build_number = latest_build_number + 1
46
+ UI.success("New build number: #{new_latest_build_number}")
47
+ return new_latest_build_number
47
48
  else
48
- UI.error "Highest build number is not an Integer"
49
+ UI.error("Latest build number is not an Integer")
49
50
  return nil
50
51
 
51
52
  end
@@ -60,9 +61,9 @@ module Fastlane
60
61
  end
61
62
 
62
63
  def self.return_value
63
- "An integer representing a new build number. It's the highest build "\
64
- "number collected from all services (e.g App Store, Google Play, App "\
65
- "Center) plus 1."
64
+ "An integer representing a new build number. It's the latest build " \
65
+ "number collected from all services (e.g App Store, Google Play, App " \
66
+ "Center) plus 1."
66
67
  end
67
68
 
68
69
  def self.details
@@ -77,43 +78,43 @@ module Fastlane
77
78
  env_name: "APP_BUNDLE_ID",
78
79
  description: "iOS bundle identifier",
79
80
  optional: true,
80
- type: String,
81
+ type: String
81
82
  ),
82
83
  FastlaneCore::ConfigItem.new(
83
84
  key: :package_name,
84
85
  env_name: "APP_PACKAGE_NAME",
85
86
  description: "Android package name",
86
87
  optional: true,
87
- type: String,
88
+ type: String
88
89
  ),
89
90
  FastlaneCore::ConfigItem.new(
90
91
  key: :google_play_json_key_path,
91
92
  env_name: "GOOGLE_PLAY_JSON_KEY_PATH",
92
93
  description: "Path to the Google Play Android Developer JSON key",
93
94
  optional: true,
94
- type: String,
95
+ type: String
95
96
  ),
96
97
  FastlaneCore::ConfigItem.new(
97
98
  key: :firebase_json_key_path,
98
99
  env_name: "FIREBASE_JSON_KEY_PATH",
99
100
  description: "Path to the Firebase Admin JSON key",
100
101
  optional: true,
101
- type: String,
102
+ type: String
102
103
  ),
103
104
  FastlaneCore::ConfigItem.new(
104
105
  key: :firebase_app_ios,
105
106
  env_name: "FIREBASE_APP_IOS",
106
107
  description: "Firebase iOS app ID",
107
108
  optional: true,
108
- type: String,
109
+ type: String
109
110
  ),
110
111
  FastlaneCore::ConfigItem.new(
111
112
  key: :firebase_app_android,
112
113
  env_name: "FIREBASE_APP_ANDROID",
113
114
  description: "Firebase Android app ID",
114
115
  optional: true,
115
- type: String,
116
- ),
116
+ type: String
117
+ )
117
118
  ]
118
119
  end
119
120
 
@@ -2,113 +2,114 @@ require 'fastlane_core/ui/ui'
2
2
  require 'tmpdir'
3
3
 
4
4
  module Fastlane
5
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
6
6
 
7
7
  module Helper
8
8
  class GetNewBuildNumberHelper
9
-
10
- def self.get_highest_build_number(
11
- bundle_identifier:nil,
12
- package_name:nil,
13
- google_play_json_key_path:nil,
14
- firebase_json_key_path:nil,
15
- firebase_app_ios:nil,
16
- firebase_app_android:nil
9
+ def self.get_latest_build_number(
10
+ bundle_identifier: nil,
11
+ package_name: nil,
12
+ google_play_json_key_path: nil,
13
+ app_store_initial_build_number: nil,
14
+ firebase_json_key_path: nil,
15
+ firebase_app_ios: nil,
16
+ firebase_app_android: nil,
17
17
  )
18
18
  if bundle_identifier.nil? && package_name.nil?
19
- UI.error "Both bundle_identifier and package_name are nil"
19
+ UI.error("Both bundle_identifier and package_name are nil")
20
20
  return nil
21
21
  end
22
22
 
23
23
  if package_name.nil? && google_play_json_key_path.nil?
24
- UI.error "Both package_name and google_play_json_key_path are nil"
24
+ UI.error("Both package_name and google_play_json_key_path are nil")
25
25
  return nil
26
26
  end
27
27
 
28
28
  app_store_build_number = 0
29
29
  unless bundle_identifier.nil?
30
- app_store_build_number = Fastlane::Actions::LatestTestflightBuildNumberAction.run(
30
+ app_store_build_number = Fastlane::Actions::AppStoreBuildNumberAction.run(
31
31
  app_identifier: bundle_identifier,
32
- )
32
+ platform: "IOS"
33
+ initial_build_number: app_store_initial_build_number || 1
34
+ )
33
35
 
34
- UI.message "build number (App Store): #{app_store_build_number}"
36
+ UI.message("Latest build number (App Store): #{app_store_build_number}")
35
37
  end
36
38
 
37
- google_play_build_number_prod = get_version_code(
39
+ google_play_build_number_prod = get_google_play_build_number(
38
40
  track: "production",
39
41
  package_name: package_name,
40
- json_key: google_play_json_key_path,
42
+ json_key: google_play_json_key_path
41
43
  )
42
44
 
43
- google_play_build_number_beta = get_version_code(
45
+ google_play_build_number_beta = get_google_play_build_number(
44
46
  track: "beta",
45
47
  package_name: package_name,
46
- json_key: google_play_json_key_path,
48
+ json_key: google_play_json_key_path
47
49
  )
48
50
 
49
- google_play_build_number_alpha = get_version_code(
51
+ google_play_build_number_alpha = get_google_play_build_number(
50
52
  track: "alpha",
51
53
  package_name: package_name,
52
- json_key: google_play_json_key_path,
54
+ json_key: google_play_json_key_path
53
55
  )
54
56
 
55
- google_play_build_number_internal = get_version_code(
57
+ google_play_build_number_internal = get_google_play_build_number(
56
58
  track: "internal",
57
59
  package_name: package_name,
58
- json_key: google_play_json_key_path,
60
+ json_key: google_play_json_key_path
59
61
  )
60
62
 
61
63
  google_play_build_number = [
62
64
  google_play_build_number_prod,
63
65
  google_play_build_number_beta,
64
66
  google_play_build_number_alpha,
65
- google_play_build_number_internal,
67
+ google_play_build_number_internal
66
68
  ].max
67
69
 
68
- UI.message "build number (Google Play Store): #{google_play_build_number}"
70
+ UI.message("Latest build number (Google Play Store): #{google_play_build_number}")
69
71
 
70
72
  fad_build_number_ios = 0
71
73
  unless firebase_app_ios.nil?
72
74
  fad_build_number_ios = Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction.run(
73
75
  app: firebase_app_ios,
74
- service_credentials_file: firebase_json_key_path,
76
+ service_credentials_file: firebase_json_key_path
75
77
  )[:buildVersion].to_i
76
-
77
- UI.message "build number (Firebase App Distribution iOS): #{fad_build_number_ios}"
78
+
79
+ UI.message("Latest build (Firebase App Distribution iOS): #{fad_build_number_ios}")
78
80
  end
79
81
 
80
82
  fad_build_number_android = 0
81
83
  unless firebase_app_android.nil?
82
84
  fad_build_number_android = Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction.run(
83
85
  app: firebase_app_android,
84
- service_credentials_file: firebase_json_key_path,
86
+ service_credentials_file: firebase_json_key_path
85
87
  )[:buildVersion].to_i
86
88
 
87
- UI.message "build number (Firebase App Distribution Android): #{fad_build_number_android}"
89
+ UI.message("Latest build (Firebase App Distribution Android): #{fad_build_number_android}")
88
90
  end
89
91
 
90
92
  return [
91
93
  app_store_build_number,
92
94
  google_play_build_number,
93
95
  fad_build_number_ios,
94
- fad_build_number_android,
96
+ fad_build_number_android
95
97
  ].max
96
98
  end
97
99
 
98
- # Returns highest build number for the given track.
99
- def self.get_version_code(track:, package_name:, json_key:)
100
- begin
101
- codes = google_play_track_version_codes(
102
- track: track,
103
- package_name: package_name,
104
- json_key: json_key,
105
- )
100
+ # Returns the latest build number ("version code", in Android terminology)
101
+ # for the given Google Play track.
102
+ def self.get_google_play_build_number(track:, package_name:, json_key:)
103
+ codes = Fastlane::Actions::GooglePlayTrackVersionCodesAction.run(
104
+ track: track,
105
+ package_name: package_name,
106
+ json_key: json_key
107
+ )
106
108
 
107
- return codes.max
108
- rescue
109
- UI.message "Version code not found for track #{track}"
110
- return 0
111
- end
109
+ return codes.max
110
+ rescue StandardError
111
+ UI.message("No build numbers found for track #{track}")
112
+ return 0
112
113
  end
113
114
  end
114
115
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GetNewBuildNumber
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-get_new_build_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartek Pacia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-29 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -179,7 +179,8 @@ files:
179
179
  homepage: https://github.com/bartekpacia/fastlane-plugin-get_new_build_number
180
180
  licenses:
181
181
  - MIT
182
- metadata: {}
182
+ metadata:
183
+ rubygems_mfa_required: 'true'
183
184
  post_install_message:
184
185
  rdoc_options: []
185
186
  require_paths:
@@ -188,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
189
  requirements:
189
190
  - - ">="
190
191
  - !ruby/object:Gem::Version
191
- version: '2.5'
192
+ version: '3.1'
192
193
  required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  requirements:
194
195
  - - ">="