fastlane-plugin-firebase_app_distribution 0.7.1 → 0.7.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 +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 +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01fc473b0dc2f5c03472c4d98f1748c6f8183d23dac7b11416d6c30f4d822862
|
4
|
+
data.tar.gz: 2d9942f8e9a28fc9ca5eb8af100ea2867560aef80558e53d47976b2bc4724a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e496e43baf4a81d3eb86ea734d2458a548f13a1e3f15ba969feb9cfd8fd3e004c51b7472a345f61b7767afeb0d4bd7d56612956b69b1e3b55bc93533d825a4e3
|
7
|
+
data.tar.gz: e0e5a877e7664d017981d623ed9f8d51a4dce186cb0b75bc17de1325e01ee6bd0c5a9b180014a98fc4817051d31502bdcb6a305c7263530c92396a82b38d9cbc
|
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.1
|
4
|
+
version: 0.7.2.pre.1
|
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-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: google-apis-firebaseappdistribution_v1
|
@@ -192,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- - "
|
195
|
+
- - ">"
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version:
|
197
|
+
version: 1.3.1
|
198
198
|
requirements: []
|
199
199
|
rubygems_version: 3.4.10
|
200
200
|
signing_key:
|