fastlane-plugin-firebase_app_distribution 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb +18 -30
- data/lib/fastlane/plugin/firebase_app_distribution/client/firebase_app_distribution_api_client.rb +40 -0
- data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb +7 -9
- data/lib/fastlane/plugin/firebase_app_distribution/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acf5235acb6cfddfc1046c7a0acc6fbd021def03abb41a0e2a852108e16ccdfc
|
4
|
+
data.tar.gz: 855bc22b9ceedff6d11090ee4ca592ec05021026a470ec2997d161dff8a631d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df84d2a9fe2720885159ceed088eae262503d0f7d56d6bb73d065a524cfd74b1d372e699beb93a88e1d23bddd1df269e64fdeba886c149174dc18ef3844ecf57
|
7
|
+
data.tar.gz: 397d56efaa7ce78800bcd885a9ede5696e38f10bc9bd796f996f39790f51737403374f893a8de48096ef2a3de0928c937034377aeae600e221c16b7a72740efc
|
data/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb
CHANGED
@@ -42,8 +42,7 @@ module Fastlane
|
|
42
42
|
params[:debug],
|
43
43
|
timeout)
|
44
44
|
|
45
|
-
# If binary is an AAB, get the AAB info for this app, which includes the integration state
|
46
|
-
# and certificate data
|
45
|
+
# If binary is an AAB, get the AAB info for this app, which includes the integration state and certificate data
|
47
46
|
if binary_type == :AAB
|
48
47
|
aab_info = get_aab_info(client, app_name)
|
49
48
|
validate_aab_setup!(aab_info)
|
@@ -51,8 +50,21 @@ module Fastlane
|
|
51
50
|
|
52
51
|
binary_type = binary_type_from_path(binary_path)
|
53
52
|
UI.message("⌛ Uploading the #{binary_type}.")
|
54
|
-
|
55
|
-
|
53
|
+
|
54
|
+
# For some reason calling the client.upload_medium returns nil when
|
55
|
+
# it should return a long running operation object
|
56
|
+
# (https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-firebaseappdistribution_v1/lib/google/apis/firebaseappdistribution_v1/service.rb#L79).
|
57
|
+
# We could use client.http, but is much slower
|
58
|
+
# (https://github.com/firebase/fastlane-plugin-firebase_app_distribution/issues/330),
|
59
|
+
# so we still use the old client for now.
|
60
|
+
# TODO(kbolay) Prefer client.upload_medium, assuming it is sufficiently fast
|
61
|
+
fad_api_client = Client::FirebaseAppDistributionApiClient.new(client.authorization.access_token, params[:debug])
|
62
|
+
operation_name = fad_api_client.upload_binary(app_name,
|
63
|
+
binary_path,
|
64
|
+
platform.to_s,
|
65
|
+
get_upload_timeout(params))
|
66
|
+
|
67
|
+
release = poll_upload_release_operation(client, operation_name, binary_type)
|
56
68
|
|
57
69
|
if binary_type == :AAB && aab_info && !aab_certs_included?(aab_info.test_certificate)
|
58
70
|
updated_aab_info = get_aab_info(client, app_name)
|
@@ -210,8 +222,8 @@ module Fastlane
|
|
210
222
|
release_notes_param || Actions.lane_context[SharedValues::FL_CHANGELOG]
|
211
223
|
end
|
212
224
|
|
213
|
-
def self.poll_upload_release_operation(client,
|
214
|
-
operation = client.get_project_app_release_operation(
|
225
|
+
def self.poll_upload_release_operation(client, operation_name, binary_type)
|
226
|
+
operation = client.get_project_app_release_operation(operation_name)
|
215
227
|
MAX_POLLING_RETRIES.times do
|
216
228
|
if operation.done && operation.response && operation.response['release']
|
217
229
|
release = extract_release(operation)
|
@@ -245,30 +257,6 @@ module Fastlane
|
|
245
257
|
extract_release(operation)
|
246
258
|
end
|
247
259
|
|
248
|
-
def self.upload_binary(app_name, binary_path, client, timeout)
|
249
|
-
options = Google::Apis::RequestOptions.new
|
250
|
-
options.max_elapsed_time = timeout # includes retries (default = no retries)
|
251
|
-
options.header = {
|
252
|
-
'Content-Type' => 'application/octet-stream',
|
253
|
-
'X-Goog-Upload-File-Name' => File.basename(binary_path),
|
254
|
-
'X-Goog-Upload-Protocol' => 'raw'
|
255
|
-
}
|
256
|
-
|
257
|
-
# For some reason calling the client.upload_medium returns nil when
|
258
|
-
# it should return a long running operation object, so we make a
|
259
|
-
# standard http call instead and convert it to a long running object
|
260
|
-
# https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-firebaseappdistribution_v1/lib/google/apis/firebaseappdistribution_v1/service.rb#L79
|
261
|
-
# TODO(kbolay) Prefer client.upload_medium
|
262
|
-
response = client.http(
|
263
|
-
:post,
|
264
|
-
"https://firebaseappdistribution.googleapis.com/upload/v1/#{app_name}/releases:upload",
|
265
|
-
body: File.open(binary_path, 'rb').read,
|
266
|
-
options: options
|
267
|
-
)
|
268
|
-
|
269
|
-
Google::Apis::FirebaseappdistributionV1::GoogleLongrunningOperation.from_json(response)
|
270
|
-
end
|
271
|
-
|
272
260
|
def self.extract_release(operation)
|
273
261
|
Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1Release.from_json(operation.response['release'].to_json)
|
274
262
|
end
|
data/lib/fastlane/plugin/firebase_app_distribution/client/firebase_app_distribution_api_client.rb
CHANGED
@@ -7,8 +7,12 @@ module Fastlane
|
|
7
7
|
include Helper::FirebaseAppDistributionHelper
|
8
8
|
|
9
9
|
BASE_URL = "https://firebaseappdistribution.googleapis.com"
|
10
|
+
MAX_POLLING_RETRIES = 60
|
11
|
+
POLLING_INTERVAL_SECONDS = 5
|
10
12
|
|
11
13
|
AUTHORIZATION = "Authorization"
|
14
|
+
CONTENT_TYPE = "Content-Type"
|
15
|
+
APPLICATION_OCTET_STREAM = "application/octet-stream"
|
12
16
|
CLIENT_VERSION = "X-Client-Version"
|
13
17
|
|
14
18
|
def initialize(auth_token, debug = false)
|
@@ -16,6 +20,33 @@ module Fastlane
|
|
16
20
|
@debug = debug
|
17
21
|
end
|
18
22
|
|
23
|
+
# Uploads the app binary to the Firebase API
|
24
|
+
#
|
25
|
+
# args
|
26
|
+
# app_name - Firebase App resource name
|
27
|
+
# binary_path - Absolute path to your app's aab/apk/ipa file
|
28
|
+
# platform - 'android' or 'ios'
|
29
|
+
# timeout - The amount of seconds before the upload will timeout, if not completed
|
30
|
+
#
|
31
|
+
# Returns the long-running operation name.
|
32
|
+
#
|
33
|
+
# Throws a user_error if the binary file does not exist
|
34
|
+
def upload_binary(app_name, binary_path, platform, timeout)
|
35
|
+
response = connection.post(binary_upload_url(app_name), read_binary(binary_path)) do |request|
|
36
|
+
request.options.timeout = timeout # seconds
|
37
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
38
|
+
request.headers[CONTENT_TYPE] = APPLICATION_OCTET_STREAM
|
39
|
+
request.headers[CLIENT_VERSION] = client_version_header_value
|
40
|
+
request.headers["X-Goog-Upload-File-Name"] = File.basename(binary_path)
|
41
|
+
request.headers["X-Goog-Upload-Protocol"] = "raw"
|
42
|
+
end
|
43
|
+
|
44
|
+
response.body[:name] || ''
|
45
|
+
rescue Errno::ENOENT # Raised when binary_path file does not exist
|
46
|
+
binary_type = binary_type_from_path(binary_path)
|
47
|
+
UI.user_error!("#{ErrorMessage.binary_not_found(binary_type)}: #{binary_path}")
|
48
|
+
end
|
49
|
+
|
19
50
|
# Get tester UDIDs
|
20
51
|
#
|
21
52
|
# args
|
@@ -40,6 +71,10 @@ module Fastlane
|
|
40
71
|
"fastlane/#{Fastlane::FirebaseAppDistribution::VERSION}"
|
41
72
|
end
|
42
73
|
|
74
|
+
def binary_upload_url(app_name)
|
75
|
+
"/upload/v1/#{app_name}/releases:upload"
|
76
|
+
end
|
77
|
+
|
43
78
|
def get_udids_url(app_id)
|
44
79
|
"/v1alpha/apps/#{app_id}/testers:getTesterUdids"
|
45
80
|
end
|
@@ -52,6 +87,11 @@ module Fastlane
|
|
52
87
|
conn.adapter(Faraday.default_adapter)
|
53
88
|
end
|
54
89
|
end
|
90
|
+
|
91
|
+
def read_binary(path)
|
92
|
+
# File must be read in binary mode to work on Windows
|
93
|
+
File.open(path, 'rb').read
|
94
|
+
end
|
55
95
|
end
|
56
96
|
end
|
57
97
|
end
|
data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb
CHANGED
@@ -38,9 +38,13 @@ module Fastlane
|
|
38
38
|
elsif !ENV["FIREBASE_TOKEN"].nil? && !ENV["FIREBASE_TOKEN"].empty?
|
39
39
|
UI.message("🔐 Authenticating with FIREBASE_TOKEN environment variable")
|
40
40
|
firebase_token(ENV["FIREBASE_TOKEN"], debug)
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
# TODO(lkellogg): Not using Google::Auth.get_application_default yet while we are still
|
42
|
+
# using the old client for uploads. ADC also does not work for the get_udids action:
|
43
|
+
# https://cloud.google.com/docs/authentication/troubleshoot-adc#user-creds-client-based
|
44
|
+
# For now go back to just using the environment variable:
|
45
|
+
elsif !ENV["GOOGLE_APPLICATION_CREDENTIALS"].nil? && !ENV["GOOGLE_APPLICATION_CREDENTIALS"].empty?
|
46
|
+
UI.message("🔐 Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: #{ENV['GOOGLE_APPLICATION_CREDENTIALS']}")
|
47
|
+
service_account(ENV["GOOGLE_APPLICATION_CREDENTIALS"], debug)
|
44
48
|
elsif (refresh_token = refresh_token_from_firebase_tools)
|
45
49
|
UI.message("🔐 No authentication method found. Using cached Firebase CLI credentials.")
|
46
50
|
firebase_token(refresh_token, debug)
|
@@ -52,12 +56,6 @@ module Fastlane
|
|
52
56
|
|
53
57
|
private
|
54
58
|
|
55
|
-
def application_default_creds
|
56
|
-
Google::Auth.get_application_default([SCOPE])
|
57
|
-
rescue
|
58
|
-
nil
|
59
|
-
end
|
60
|
-
|
61
59
|
def refresh_token_from_firebase_tools
|
62
60
|
config_path = format_config_path
|
63
61
|
if File.exist?(config_path)
|
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.7.
|
4
|
+
version: 0.7.2
|
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: 2023-08-
|
13
|
+
date: 2023-08-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: google-apis-firebaseappdistribution_v1
|