fastlane-plugin-firebase_app_distribution 0.3.6 → 0.3.8

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: fbab06941b8df52d0959f4792a5414de798b9038f89c8774b5e35afd57019729
4
- data.tar.gz: 4b64872b0d8bc723fcb85bdf31d447bfd0ac001595c27e2209faa792d31a79ca
3
+ metadata.gz: 9054b14c72ce1d0b5ee23da37fc3da51a2860b3249b07e5271d281c47570e5d0
4
+ data.tar.gz: 22e4f72109457476f1ab857e6dad86146ae3733972fda42cb80c8c73b89d42fc
5
5
  SHA512:
6
- metadata.gz: 27fc550a02fad5d23cca0ac7abf1b1787df45ff01facf402a1a64bff6d1489c61058e1a92a78027779f0ef2f55308dab59a87052ad326ef8ce050a643cc65c3c
7
- data.tar.gz: 862ccc4890c1f7c76ae2c1491da5c039551de3c016e405052f3487b702fcdf897dad14ae0513c70b79e657d61abbd397b7c66b1969685808d1c3c73f60e94ff5
6
+ metadata.gz: 80f3d004d4f6263a15c6aba591bb5ae10705dca4c9c31c8f6f0dc4f513e6fbe50310e605cae5b30a4c3bc28ac0eadca29d4bcd51b19b2ed3f970001df1b6d8fa
7
+ data.tar.gz: 4f4b8f3780fd86299ea1c393e6446e02e5e4414b498b4f85b764a27f8584395f88b40325d54e33bd6e782bc9fe3b58960e8ba72fd5e6e453aba3d563e555e14b
data/fad-icon.png ADDED
Binary file
@@ -15,6 +15,8 @@ module Fastlane
15
15
  extend Auth::FirebaseAppDistributionAuthClient
16
16
  extend Helper::FirebaseAppDistributionHelper
17
17
 
18
+ DEFAULT_UPLOAD_TIMEOUT_SECONDS = 300
19
+
18
20
  def self.run(params)
19
21
  params.values # to validate all inputs before looking for the ipa/apk/aab
20
22
 
@@ -42,7 +44,9 @@ module Fastlane
42
44
  validate_aab_setup!(aab_info)
43
45
  end
44
46
 
45
- release_name = fad_api_client.upload(app_name, binary_path, platform.to_s)
47
+ upload_timeout = get_upload_timeout(params)
48
+
49
+ release_name = fad_api_client.upload(app_name, binary_path, platform.to_s, upload_timeout)
46
50
 
47
51
  if binary_type == :AAB && aab_info && !aab_info.certs_provided?
48
52
  updated_aab_info = fad_api_client.get_aab_info(app_name)
@@ -135,6 +139,14 @@ module Fastlane
135
139
  end
136
140
  end
137
141
 
142
+ def self.get_upload_timeout(params)
143
+ if params[:upload_timeout]
144
+ return params[:upload_timeout]
145
+ else
146
+ return DEFAULT_UPLOAD_TIMEOUT_SECONDS
147
+ end
148
+ end
149
+
138
150
  def self.validate_aab_setup!(aab_info)
139
151
  if aab_info && aab_info.integration_state != AabInfo::AabState::INTEGRATED && aab_info.integration_state != AabInfo::AabState::UNAVAILABLE
140
152
  case aab_info.integration_state
@@ -242,7 +254,12 @@ module Fastlane
242
254
  FastlaneCore::ConfigItem.new(key: :service_credentials_file,
243
255
  description: "Path to Google service account json",
244
256
  optional: true,
245
- type: String)
257
+ type: String),
258
+ FastlaneCore::ConfigItem.new(key: :upload_timeout,
259
+ description: "The amount of seconds before the upload will timeout, if not completed",
260
+ optional: true,
261
+ default_value: DEFAULT_UPLOAD_TIMEOUT_SECONDS,
262
+ type: Integer)
246
263
  ]
247
264
  end
248
265
 
@@ -106,11 +106,12 @@ module Fastlane
106
106
  # app_name - Firebase App resource name
107
107
  # binary_path - Absolute path to your app's aab/apk/ipa file
108
108
  # platform - 'android' or 'ios'
109
+ # timeout - The amount of seconds before the upload will timeout, if not completed
109
110
  #
110
111
  # Throws a user_error if the binary file does not exist
111
- def upload_binary(app_name, binary_path, platform)
112
+ def upload_binary(app_name, binary_path, platform, timeout)
112
113
  response = connection.post(binary_upload_url(app_name), read_binary(binary_path)) do |request|
113
- request.options.timeout = 300 # seconds
114
+ request.options.timeout = timeout # seconds
114
115
  request.headers[AUTHORIZATION] = "Bearer " + @auth_token
115
116
  request.headers[CONTENT_TYPE] = APPLICATION_OCTET_STREAM
116
117
  request.headers[CLIENT_VERSION] = client_version_header_value
@@ -130,16 +131,17 @@ module Fastlane
130
131
  # args
131
132
  # app_name - Firebase App resource name
132
133
  # binary_path - Absolute path to your app's aab/apk/ipa file
134
+ # timeout - The amount of seconds before the upload will timeout, if not completed
133
135
  #
134
136
  # Returns the release_name of the uploaded release.
135
137
  #
136
138
  # Crashes if the number of polling retries exceeds MAX_POLLING_RETRIES or if the binary cannot
137
139
  # be uploaded.
138
- def upload(app_name, binary_path, platform)
140
+ def upload(app_name, binary_path, platform, timeout)
139
141
  binary_type = binary_type_from_path(binary_path)
140
142
 
141
143
  UI.message("⌛ Uploading the #{binary_type}.")
142
- operation_name = upload_binary(app_name, binary_path, platform)
144
+ operation_name = upload_binary(app_name, binary_path, platform, timeout)
143
145
 
144
146
  upload_status_response = get_upload_status(operation_name)
145
147
  MAX_POLLING_RETRIES.times do
@@ -24,44 +24,50 @@ module Fastlane
24
24
  # Crashes if given invalid or missing credentials
25
25
  def fetch_auth_token(google_service_path, firebase_cli_token, debug = false)
26
26
  if !google_service_path.nil? && !google_service_path.empty?
27
- UI.message("Authenticating with --service_credentials_file path parameter: #{google_service_path}")
27
+ UI.message("🔐 Authenticating with --service_credentials_file path parameter: #{google_service_path}")
28
28
  token = service_account(google_service_path, debug)
29
29
  elsif !firebase_cli_token.nil? && !firebase_cli_token.empty?
30
- UI.message("Authenticating with --firebase_cli_token parameter")
30
+ UI.message("🔐 Authenticating with --firebase_cli_token parameter")
31
31
  token = firebase_token(firebase_cli_token, debug)
32
32
  elsif !ENV["FIREBASE_TOKEN"].nil? && !ENV["FIREBASE_TOKEN"].empty?
33
- UI.message("Authenticating with FIREBASE_TOKEN environment variable")
33
+ UI.message("🔐 Authenticating with FIREBASE_TOKEN environment variable")
34
34
  token = firebase_token(ENV["FIREBASE_TOKEN"], debug)
35
35
  elsif !ENV["GOOGLE_APPLICATION_CREDENTIALS"].nil? && !ENV["GOOGLE_APPLICATION_CREDENTIALS"].empty?
36
- UI.message("Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: #{ENV['GOOGLE_APPLICATION_CREDENTIALS']}")
36
+ UI.message("🔐 Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: #{ENV['GOOGLE_APPLICATION_CREDENTIALS']}")
37
37
  token = service_account(ENV["GOOGLE_APPLICATION_CREDENTIALS"], debug)
38
38
  elsif (refresh_token = refresh_token_from_firebase_tools)
39
- UI.message("No authentication method specified. Using cached Firebase CLI credentials.")
39
+ UI.message("🔐 No authentication method specified. Using cached Firebase CLI credentials.")
40
40
  token = firebase_token(refresh_token, debug)
41
41
  else
42
42
  UI.user_error!(ErrorMessage::MISSING_CREDENTIALS)
43
43
  end
44
- UI.success("🔐 Authenticated successfully.")
45
44
  token
46
45
  end
47
46
 
48
47
  private
49
48
 
50
49
  def refresh_token_from_firebase_tools
51
- if ENV["XDG_CONFIG_HOME"].nil? || ENV["XDG_CONFIG_HOME"].empty?
52
- config_path = File.expand_path(".config/configstore/firebase-tools.json", "~")
53
- else
54
- config_path = File.expand_path("configstore/firebase-tools.json", ENV["XDG_CONFIG_HOME"])
55
- end
56
-
50
+ config_path = format_config_path
57
51
  if File.exist?(config_path)
58
52
  begin
59
- refresh_token = JSON.parse(File.read(config_path))['tokens']['refresh_token']
60
- refresh_token unless refresh_token.nil? || refresh_token.empty?
61
- # TODO: Catch parser errors, improve error handling here
62
- # Returns nil when there is an empty "tokens" field in the firebase-tools json
63
- rescue NoMethodError
53
+ firebase_tools_tokens = JSON.parse(File.read(config_path))['tokens']
54
+ if firebase_tools_tokens.nil?
55
+ UI.user_error!(ErrorMessage::EMPTY_TOKENS_FIELD)
56
+ return
57
+ end
58
+ refresh_token = firebase_tools_tokens['refresh_token']
59
+ rescue JSON::ParserError
60
+ UI.user_error!(ErrorMessage::PARSE_FIREBASE_TOOLS_JSON_ERROR)
64
61
  end
62
+ refresh_token unless refresh_token.nil? || refresh_token.empty?
63
+ end
64
+ end
65
+
66
+ def format_config_path
67
+ if ENV["XDG_CONFIG_HOME"].nil? || ENV["XDG_CONFIG_HOME"].empty?
68
+ File.expand_path(".config/configstore/firebase-tools.json", "~")
69
+ else
70
+ File.expand_path("configstore/firebase-tools.json", ENV["XDG_CONFIG_HOME"])
65
71
  end
66
72
  end
67
73
 
@@ -3,6 +3,7 @@ module ErrorMessage
3
3
  MISSING_APP_ID = "Missing app id. Please check that the app parameter is set and try again"
4
4
  SERVICE_CREDENTIALS_NOT_FOUND = "Service credentials file does not exist. Please check the service credentials path and try again"
5
5
  PARSE_SERVICE_CREDENTIALS_ERROR = "Failed to extract service account information from the service credentials file"
6
+ PARSE_FIREBASE_TOOLS_JSON_ERROR = "Encountered error parsing json file. Ensure the firebase-tools.json file is formatted correctly"
6
7
  UPLOAD_RELEASE_NOTES_ERROR = "App Distribution halted because it had a problem uploading release notes"
7
8
  UPLOAD_TESTERS_ERROR = "App Distribution halted because it had a problem adding testers/groups"
8
9
  GET_RELEASE_TIMEOUT = "App Distribution failed to fetch release information"
@@ -20,6 +21,7 @@ module ErrorMessage
20
21
  PLAY_IAS_TERMS_NOT_ACCEPTED = "You must accept the Play Internal App Sharing (IAS) terms to upload AABs."
21
22
  INVALID_EMAIL_ADDRESS = "You passed an invalid email address."
22
23
  TESTER_LIMIT_VIOLATION = "Creating testers would exceed tester limit"
24
+ EMPTY_TOKENS_FIELD = "Unable to find \"tokens\" field in the firebase-tools.json file. Ensure that the file has a tokens field and try again"
23
25
 
24
26
  def self.aab_upload_error(aab_state)
25
27
  "Failed to process the AAB: #{aab_state}"
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.8"
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.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Natchev
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-09-09 00:00:00.000000000 Z
13
+ date: 2022-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -149,6 +149,7 @@ extra_rdoc_files: []
149
149
  files:
150
150
  - LICENSE
151
151
  - README.md
152
+ - fad-icon.png
152
153
  - lib/fastlane/plugin/firebase_app_distribution.rb
153
154
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb
154
155
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb