fastlane-plugin-firebase_app_distribution 0.10.0 → 0.10.2.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b85c6c60b76c751c0f4f5ca2611bd6735b5540b1525e600dad266b354bcc2e7
4
- data.tar.gz: dbee1fc079ed0d7c8f1b50aec4cc22339e7046cf97b100576564797afa440e48
3
+ metadata.gz: e3ac8eeeed71d57e777bcee0a974d0d23a1093a9d427b591150300c5cd8c36ff
4
+ data.tar.gz: 483d71f41ff6aee5b1da54a5308b89c3180d2bacdc1e0d58d24d6dd175340af6
5
5
  SHA512:
6
- metadata.gz: 5fd6c96184db82f9d38dc5495b2c8adcd9b42326f45420afcf50b9db66064dd7c07228d694d349b0c1ee3e82782cc8fe76ec5e0889841574f3c12ecaeff89362
7
- data.tar.gz: 3f5e0aafc6c0b09ae3722f7fd65522009470c70cad2bd115fd061f2c38a63522eec6b77aa036df9e21cc30b6704134fe593ec132dee5026e65a50d29366f4d91
6
+ metadata.gz: 2d8faa2d8fa9f3f9e6d776d4373644c47799fdca0497b2d07b73bef6b26ed6eaefa641e19ce9e0a8e4f50f881b4e972502d74c1c074e2d4272079693e6a42ef7
7
+ data.tar.gz: 6d38932bfc8842483e31706cdf116a11dfa1798c6ab0fb40dc769c8dda8ac73c4804f569c5ac1cd7c1a96676543d5288ba2de4453602ad94604b4dd466b14686
@@ -21,6 +21,7 @@ module Fastlane
21
21
  extend Helper::FirebaseAppDistributionHelper
22
22
 
23
23
  DEFAULT_UPLOAD_TIMEOUT_SECONDS = 300
24
+ DEFAULT_UPLOAD_RETRIES = 3
24
25
  UPLOAD_MAX_POLLING_RETRIES = 60
25
26
  UPLOAD_POLLING_INTERVAL_SECONDS = 5
26
27
  TEST_MAX_POLLING_RETRIES = 40
@@ -33,6 +34,7 @@ module Fastlane
33
34
  app_name = app_name_from_app_id(app_id)
34
35
  platform = lane_platform || platform_from_app_id(app_id)
35
36
  timeout = get_upload_timeout(params)
37
+ retries = get_upload_retries(params)
36
38
 
37
39
  binary_path = get_binary_path(platform, params)
38
40
  UI.user_error!("Couldn't determine path for #{platform} binary.") if binary_path.nil?
@@ -57,7 +59,7 @@ module Fastlane
57
59
 
58
60
  binary_type = binary_type_from_path(binary_path)
59
61
  UI.message("📡 Uploading the #{binary_type}.")
60
- operation = upload_binary(client, app_name, binary_path, binary_type, timeout)
62
+ operation = upload_binary(client, app_name, binary_path, binary_type, timeout, retries)
61
63
  UI.message("🕵️ Validating upload…")
62
64
  release = poll_upload_release_operation(client, operation, binary_type)
63
65
 
@@ -142,34 +144,6 @@ module Fastlane
142
144
  test_password && test_password.sub(/\r?\n$/, "")
143
145
  end
144
146
 
145
- def self.app_id_from_params(params)
146
- if params[:app]
147
- app_id = params[:app]
148
- elsif xcode_archive_path
149
- plist_path = params[:googleservice_info_plist_path]
150
- app_id = get_ios_app_id_from_archive_plist(xcode_archive_path, plist_path)
151
- end
152
- if app_id.nil?
153
- UI.crash!(ErrorMessage::MISSING_APP_ID)
154
- end
155
- app_id
156
- end
157
-
158
- def self.xcode_archive_path
159
- # prevents issues on cross-platform build environments where an XCode build happens within
160
- # the same lane
161
- return nil if lane_platform == :android
162
-
163
- # rubocop:disable Require/MissingRequireStatement
164
- Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
165
- # rubocop:enable Require/MissingRequireStatement
166
- end
167
-
168
- def self.lane_platform
169
- # to_sym shouldn't be necessary, but possibly fixes #376
170
- Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]&.to_sym
171
- end
172
-
173
147
  def self.platform_from_app_id(app_id)
174
148
  if app_id.include?(':ios:')
175
149
  :ios
@@ -213,6 +187,14 @@ module Fastlane
213
187
  end
214
188
  end
215
189
 
190
+ def self.get_upload_retries(params)
191
+ if params[:upload_retries]
192
+ return params[:upload_retries]
193
+ else
194
+ return DEFAULT_UPLOAD_RETRIES
195
+ end
196
+ end
197
+
216
198
  def self.validate_aab_setup!(aab_info)
217
199
  if aab_info && aab_info.integration_state != 'INTEGRATED' && aab_info.integration_state != 'AAB_STATE_UNAVAILABLE'
218
200
  case aab_info.integration_state
@@ -280,27 +262,15 @@ module Fastlane
280
262
  extract_release(operation)
281
263
  end
282
264
 
283
- def self.upload_binary(client, app_name, binary_path, binary_type, timeout)
284
- options = Google::Apis::RequestOptions.new
285
- options.max_elapsed_time = timeout # includes retries (default = no retries)
265
+ def self.upload_binary(client, app_name, binary_path, binary_type, timeout, retries)
266
+ options = Google::Apis::RequestOptions.new(max_elapsed_time: timeout, retries: retries)
286
267
  options.header = {
287
268
  'Content-Type' => 'application/octet-stream',
288
- 'X-Goog-Upload-File-Name' => CGI.escape(File.basename(binary_path)),
289
- 'X-Goog-Upload-Protocol' => 'raw'
269
+ 'X-Goog-Upload-File-Name' => CGI.escape(File.basename(binary_path))
290
270
  }
291
271
 
292
- # For some reason calling the client.upload_medium returns nil when
293
- # it should return a long running operation object, so we make a
294
- # standard http call instead and convert it to a long running object
295
- # https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-firebaseappdistribution_v1/lib/google/apis/firebaseappdistribution_v1/service.rb#L79
296
- # TODO(kbolay): Prefer client.upload_medium
297
- response = begin
298
- client.http(
299
- :post,
300
- "https://firebaseappdistribution.googleapis.com/upload/v1/#{app_name}/releases:upload",
301
- body: File.open(binary_path, 'rb'),
302
- options: options
303
- )
272
+ begin
273
+ client.upload_medium(app_name, File.open(binary_path, 'rb'), upload_source: binary_path, options: options)
304
274
  rescue Google::Apis::Error => err
305
275
  case err.status_code.to_i
306
276
  when 403
@@ -309,8 +279,6 @@ module Fastlane
309
279
  UI.crash!("#{ErrorMessage.upload_binary_error(binary_type)} (#{err}, status_code: #{err.status_code})")
310
280
  end
311
281
  end
312
-
313
- Google::Apis::FirebaseappdistributionV1::GoogleLongrunningOperation.from_json(response)
314
282
  end
315
283
 
316
284
  def self.extract_release(operation)
@@ -492,7 +460,7 @@ module Fastlane
492
460
  optional: true),
493
461
  FastlaneCore::ConfigItem.new(key: :googleservice_info_plist_path,
494
462
  env_name: "GOOGLESERVICE_INFO_PLIST_PATH",
495
- description: "Path to your GoogleService-Info.plist file, relative to the archived product path",
463
+ description: "Path to your GoogleService-Info.plist file, relative to the archived product path (or directly, if no archived product path is found)",
496
464
  default_value: "GoogleService-Info.plist",
497
465
  optional: true,
498
466
  type: String),
@@ -533,10 +501,15 @@ module Fastlane
533
501
 
534
502
  # Release Distribution
535
503
  FastlaneCore::ConfigItem.new(key: :upload_timeout,
536
- description: "Amount of seconds before the upload will timeout, if not completed",
504
+ description: "Amount of seconds before the upload will timeout, if not completed",
537
505
  optional: true,
538
506
  default_value: DEFAULT_UPLOAD_TIMEOUT_SECONDS,
539
507
  type: Integer),
508
+ FastlaneCore::ConfigItem.new(key: :upload_retries,
509
+ description: "Maximum number of times the upload will retry, if not completed",
510
+ optional: true,
511
+ default_value: DEFAULT_UPLOAD_RETRIES,
512
+ type: Integer),
540
513
  FastlaneCore::ConfigItem.new(key: :groups,
541
514
  env_name: "FIREBASEAPPDISTRO_GROUPS",
542
515
  description: "Group aliases used for distribution, separated by commas",
@@ -19,15 +19,15 @@ module Fastlane
19
19
  client = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService.new
20
20
  client.authorization = get_authorization(params[:service_credentials_file], params[:firebase_cli_token], params[:service_credentials_json_data], params[:debug])
21
21
 
22
- UI.message("⏳ Fetching latest release for app #{params[:app]}...")
23
-
24
- parent = app_name_from_app_id(params[:app])
22
+ app_id = app_id_from_params(params)
23
+ UI.message("⏳ Fetching latest release for app #{app_id}...")
24
+ parent = app_name_from_app_id(app_id)
25
25
 
26
26
  begin
27
27
  releases = client.list_project_app_releases(parent, page_size: 1).releases
28
28
  rescue Google::Apis::Error => err
29
29
  if err.status_code.to_i == 404
30
- UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{params[:app]}")
30
+ UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
31
31
  else
32
32
  UI.crash!(err)
33
33
  end
@@ -35,7 +35,7 @@ module Fastlane
35
35
 
36
36
  if releases.nil? || releases.empty?
37
37
  latest_release = nil
38
- UI.important("No releases for app #{params[:app]} found in App Distribution. Returning nil and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
38
+ UI.important("No releases for app #{app_id} found in App Distribution. Returning nil and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
39
39
  else
40
40
  # latest_release = append_json_style_fields(response.releases[0].to_h)
41
41
  latest_release = map_release_hash(releases[0])
@@ -80,10 +80,19 @@ module Fastlane
80
80
 
81
81
  def self.available_options
82
82
  [
83
+ # iOS Specific
84
+ FastlaneCore::ConfigItem.new(key: :googleservice_info_plist_path,
85
+ env_name: "GOOGLESERVICE_INFO_PLIST_PATH",
86
+ description: "Path to your GoogleService-Info.plist file, relative to the archived product path (or directly, if no archived product path is found)",
87
+ default_value: "GoogleService-Info.plist",
88
+ optional: true,
89
+ type: String),
90
+
91
+ # General
83
92
  FastlaneCore::ConfigItem.new(key: :app,
84
93
  env_name: "FIREBASEAPPDISTRO_APP",
85
94
  description: "Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page",
86
- optional: false,
95
+ optional: true,
87
96
  type: String),
88
97
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
89
98
  description: "Auth token generated using Firebase CLI's login:ci command",
@@ -11,7 +11,7 @@ module ErrorMessage
11
11
  GET_RELEASE_TIMEOUT = "App Distribution failed to fetch release information."
12
12
  REFRESH_TOKEN_ERROR = "App Distribution could not generate credentials from the refresh token specified."
13
13
  APP_NOT_ONBOARDED_ERROR = "App Distribution not onboarded."
14
- INVALID_APP_ID = "App Distribution could not find your app. Make sure to onboard your app by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution. App ID"
14
+ INVALID_APP_ID = "App Distribution could not find your app. Make sure to onboard your app by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution."
15
15
  INVALID_PROJECT = "App Distribution could not find your Firebase project. Make sure to onboard an app in your project by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution."
16
16
  INVALID_PATH = "Could not read content from"
17
17
  INVALID_TESTERS = "Could not enable access for testers. Check that the tester emails are formatted correctly, the groups exist and you are using group aliases (not group names) for specifying groups."
@@ -1,3 +1,4 @@
1
+ require 'fastlane/action'
1
2
  require 'fastlane_core/ui/ui'
2
3
  require 'cfpropertylist'
3
4
  require 'google/apis/core'
@@ -36,15 +37,52 @@ module Fastlane
36
37
  string.strip.split(delimiter).map(&:strip)
37
38
  end
38
39
 
40
+ def app_id_from_params(params)
41
+ plist_path = params[:googleservice_info_plist_path]
42
+ if params[:app]
43
+ UI.message("Using app ID from 'app' parameter")
44
+ app_id = params[:app]
45
+ elsif xcode_archive_path
46
+ UI.message("Using app ID from the GoogleService-Info.plist file located using the 'googleservice_info_plist_path' parameter, relative to the archive path: #{xcode_archive_path}")
47
+ app_id = get_ios_app_id_from_archive_plist(xcode_archive_path, plist_path)
48
+ elsif plist_path
49
+ UI.message("Using app ID from the GoogleService-Info.plist file located using the 'googleservice_info_plist_path' parameter directly since no archive path was found")
50
+ app_id = get_ios_app_id_from_plist(plist_path)
51
+ end
52
+ if app_id.nil?
53
+ UI.crash!(ErrorMessage::MISSING_APP_ID)
54
+ end
55
+ app_id
56
+ end
57
+
58
+ def lane_platform
59
+ # to_sym shouldn't be necessary, but possibly fixes #376
60
+ Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]&.to_sym
61
+ end
62
+
63
+ def xcode_archive_path
64
+ # prevents issues on cross-platform build environments where an XCode build happens within
65
+ # the same lane
66
+ return nil if lane_platform == :android
67
+
68
+ # rubocop:disable Require/MissingRequireStatement
69
+ Actions.lane_context[Actions::SharedValues::XCODEBUILD_ARCHIVE]
70
+ # rubocop:enable Require/MissingRequireStatement
71
+ end
72
+
39
73
  def parse_plist(path)
40
74
  CFPropertyList.native_types(CFPropertyList::List.new(file: path).value)
41
75
  end
42
76
 
43
- def get_ios_app_id_from_archive_plist(archive_path, plist_path)
77
+ def get_ios_app_id_from_archive_plist(archive_path, relative_plist_path)
44
78
  app_path = parse_plist("#{archive_path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
45
79
  UI.shell_error!("can't extract application path from Info.plist at #{archive_path}") if app_path.empty?
46
- identifier = parse_plist("#{archive_path}/Products/#{app_path}/#{plist_path}")["GOOGLE_APP_ID"]
47
- UI.shell_error!("can't extract GOOGLE_APP_ID") if identifier.empty?
80
+ return get_ios_app_id_from_plist("#{archive_path}/Products/#{app_path}/#{relative_plist_path}")
81
+ end
82
+
83
+ def get_ios_app_id_from_plist(plist_path)
84
+ identifier = parse_plist(plist_path)["GOOGLE_APP_ID"]
85
+ UI.shell_error!("can't extract GOOGLE_APP_ID from #{plist_path}") if identifier.empty?
48
86
  return identifier
49
87
  end
50
88
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.10.0"
3
+ VERSION = "0.10.2.pre.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-firebase_app_distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Natchev
@@ -9,7 +9,7 @@ authors:
9
9
  - Alonso Salas Infante
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-01-07 00:00:00.000000000 Z
12
+ date: 1980-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-apis-firebaseappdistribution_v1
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubygems_version: 3.6.2
210
+ rubygems_version: 3.6.9
211
211
  specification_version: 4
212
212
  summary: Release your beta builds to Firebase App Distribution. https://firebase.google.com/docs/app-distribution
213
213
  test_files: []