fastlane-plugin-firebase_app_distribution 0.2.1 → 0.2.4
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 +47 -20
- data/lib/fastlane/plugin/firebase_app_distribution/client/error_response.rb +16 -0
- data/lib/fastlane/plugin/firebase_app_distribution/client/firebase_app_distribution_api_client.rb +20 -8
- data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_error_message.rb +1 -0
- data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb +4 -4
- data/lib/fastlane/plugin/firebase_app_distribution/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a6b59efacf7524b9c562405bf867140a83ece4972cc0e4c22cfea123e1e5842
|
4
|
+
data.tar.gz: 1a64bbb493f3956eb5d90e78ffbbc6ffa60ceb54930542f6cbcefcf179cc9820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be9c94c149bd843bdad4523c559c84fee46813b97e9c02a383a18824d23e8f5c61db0c66209f1673d4c879fcf22a0714e49c98dd8b960554219b59c8289c2c53
|
7
|
+
data.tar.gz: 4cd7cb1a546b6baa8fa11a8829e45b488bfaf3c54934cc016c161914f03321611ba25e8b6116c77029c9d5d9a4851ce548a01d60ad719ddd06e13413190e191e
|
data/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb
CHANGED
@@ -20,23 +20,14 @@ module Fastlane
|
|
20
20
|
|
21
21
|
def self.run(params)
|
22
22
|
params.values # to validate all inputs before looking for the ipa/apk
|
23
|
-
auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
|
24
|
-
binary_path = params[:ipa_path] || params[:apk_path]
|
25
|
-
platform = lane_platform || platform_from_path(binary_path)
|
26
|
-
fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, platform)
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
24
|
+
app_id = app_id_from_params(params)
|
25
|
+
platform = lane_platform || platform_from_app_id(app_id)
|
26
|
+
binary_path = binary_path_from_platform(platform, params[:ipa_path], params[:apk_path])
|
27
|
+
|
28
|
+
auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
|
29
|
+
fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, platform, params[:debug])
|
36
30
|
|
37
|
-
if app_id.nil?
|
38
|
-
UI.crash!(ErrorMessage::MISSING_APP_ID)
|
39
|
-
end
|
40
31
|
release_id = fad_api_client.upload(app_id, binary_path, platform.to_s)
|
41
32
|
if release_id.nil?
|
42
33
|
return
|
@@ -66,20 +57,50 @@ module Fastlane
|
|
66
57
|
"Release your beta builds with Firebase App Distribution"
|
67
58
|
end
|
68
59
|
|
60
|
+
def self.app_id_from_params(params)
|
61
|
+
if params[:app]
|
62
|
+
app_id = params[:app]
|
63
|
+
elsif xcode_archive_path
|
64
|
+
plist_path = params[:googleservice_info_plist_path]
|
65
|
+
app_id = get_ios_app_id_from_archive_plist(xcode_archive_path, plist_path)
|
66
|
+
end
|
67
|
+
if app_id.nil?
|
68
|
+
UI.crash!(ErrorMessage::MISSING_APP_ID)
|
69
|
+
end
|
70
|
+
app_id
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.xcode_archive_path
|
74
|
+
# prevents issues on cross-platform build environments where an XCode build happens within
|
75
|
+
# the same lane
|
76
|
+
return nil if lane_platform == :android
|
77
|
+
|
78
|
+
Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
|
79
|
+
end
|
80
|
+
|
69
81
|
def self.lane_platform
|
70
82
|
Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
|
71
83
|
end
|
72
84
|
|
73
|
-
def self.
|
74
|
-
|
75
|
-
case binary_path.split('.').last
|
76
|
-
when 'ipa'
|
85
|
+
def self.platform_from_app_id(app_id)
|
86
|
+
if app_id.include?(':ios:')
|
77
87
|
:ios
|
78
|
-
|
88
|
+
elsif app_id.include?(':android:')
|
79
89
|
:android
|
80
90
|
end
|
81
91
|
end
|
82
92
|
|
93
|
+
def self.binary_path_from_platform(platform, ipa_path, apk_path)
|
94
|
+
case platform
|
95
|
+
when :ios
|
96
|
+
ipa_path
|
97
|
+
when :android
|
98
|
+
apk_path
|
99
|
+
else
|
100
|
+
ipa_path || apk_path
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
83
104
|
def self.available_options
|
84
105
|
if lane_platform == :ios || lane_platform.nil?
|
85
106
|
ipa_path_default = Dir["*.ipa"].sort_by { |x| File.mtime(x) }.last
|
@@ -100,6 +121,12 @@ module Fastlane
|
|
100
121
|
verify_block: proc do |value|
|
101
122
|
UI.user_error!("firebase_app_distribution: Couldn't find ipa file at path '#{value}'") unless File.exist?(value)
|
102
123
|
end),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :googleservice_info_plist_path,
|
125
|
+
env_name: "GOOGLESERVICE_INFO_PLIST_PATH",
|
126
|
+
description: "Path to your GoogleService-Info.plist file, relative to the root of your Xcode project",
|
127
|
+
default_value: "GoogleService-Info.plist",
|
128
|
+
optional: true,
|
129
|
+
type: String),
|
103
130
|
# Android Specific
|
104
131
|
FastlaneCore::ConfigItem.new(key: :apk_path,
|
105
132
|
env_name: "FIREBASEAPPDISTRO_APK_PATH",
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Client
|
3
|
+
class ErrorResponse
|
4
|
+
attr_accessor :code, :message, :status
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
unless response[:body].nil? || response[:body].empty?
|
8
|
+
response_body = JSON.parse(response[:body], symbolize_names: true)
|
9
|
+
@code = response_body[:error][:code]
|
10
|
+
@message = response_body[:error][:message]
|
11
|
+
@status = response_body[:error][:status]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/fastlane/plugin/firebase_app_distribution/client/firebase_app_distribution_api_client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
2
2
|
require_relative '../actions/firebase_app_distribution_login'
|
3
|
+
require_relative '../client/error_response'
|
3
4
|
|
4
5
|
module Fastlane
|
5
6
|
module Client
|
@@ -9,8 +10,14 @@ module Fastlane
|
|
9
10
|
MAX_POLLING_RETRIES = 60
|
10
11
|
POLLING_INTERVAL_SECONDS = 2
|
11
12
|
|
12
|
-
|
13
|
+
AUTHORIZATION = "Authorization"
|
14
|
+
CONTENT_TYPE = "Content-Type"
|
15
|
+
APPLICATION_JSON = "application/json"
|
16
|
+
APPLICATION_OCTET_STREAM = "application/octet-stream"
|
17
|
+
|
18
|
+
def initialize(auth_token, platform, debug = false)
|
13
19
|
@auth_token = auth_token
|
20
|
+
@debug = debug
|
14
21
|
|
15
22
|
if platform.nil?
|
16
23
|
@binary_type = "IPA/APK"
|
@@ -39,7 +46,8 @@ module Fastlane
|
|
39
46
|
payload = { emails: emails, groupIds: group_ids }
|
40
47
|
begin
|
41
48
|
connection.post(enable_access_url(app_id, release_id), payload.to_json) do |request|
|
42
|
-
request.headers[
|
49
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
50
|
+
request.headers[CONTENT_TYPE] = APPLICATION_JSON
|
43
51
|
end
|
44
52
|
rescue Faraday::ResourceNotFound
|
45
53
|
UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
|
@@ -66,12 +74,14 @@ module Fastlane
|
|
66
74
|
end
|
67
75
|
begin
|
68
76
|
connection.post(release_notes_create_url(app_id, release_id), payload.to_json) do |request|
|
69
|
-
request.headers[
|
77
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
78
|
+
request.headers[CONTENT_TYPE] = APPLICATION_JSON
|
70
79
|
end
|
71
80
|
rescue Faraday::ResourceNotFound
|
72
81
|
UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
|
73
|
-
|
74
|
-
|
82
|
+
rescue Faraday::ClientError => e
|
83
|
+
error = ErrorResponse.new(e.response)
|
84
|
+
UI.user_error!("#{ErrorMessage::INVALID_RELEASE_NOTES}: #{error.message}")
|
75
85
|
end
|
76
86
|
UI.success("✅ Posted release notes.")
|
77
87
|
end
|
@@ -93,7 +103,7 @@ module Fastlane
|
|
93
103
|
|
94
104
|
begin
|
95
105
|
response = connection.get(v1_apps_url(app_id)) do |request|
|
96
|
-
request.headers[
|
106
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
97
107
|
end
|
98
108
|
rescue Faraday::ResourceNotFound
|
99
109
|
UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
|
@@ -115,7 +125,8 @@ module Fastlane
|
|
115
125
|
# Throws a user_error if an invalid app id is passed in, or if the binary file does not exist
|
116
126
|
def upload_binary(app_id, binary_path, platform)
|
117
127
|
connection.post(binary_upload_url(app_id), read_binary(binary_path)) do |request|
|
118
|
-
request.headers[
|
128
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
129
|
+
request.headers[CONTENT_TYPE] = APPLICATION_OCTET_STREAM
|
119
130
|
request.headers["X-APP-DISTRO-API-CLIENT-ID"] = "fastlane"
|
120
131
|
request.headers["X-APP-DISTRO-API-CLIENT-TYPE"] = platform
|
121
132
|
request.headers["X-APP-DISTRO-API-CLIENT-VERSION"] = Fastlane::FirebaseAppDistribution::VERSION
|
@@ -182,7 +193,7 @@ module Fastlane
|
|
182
193
|
def get_upload_status(app_id, upload_token)
|
183
194
|
begin
|
184
195
|
response = connection.get(upload_status_url(app_id, upload_token)) do |request|
|
185
|
-
request.headers[
|
196
|
+
request.headers[AUTHORIZATION] = "Bearer " + @auth_token
|
186
197
|
end
|
187
198
|
rescue Faraday::ResourceNotFound
|
188
199
|
UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
|
@@ -220,6 +231,7 @@ module Fastlane
|
|
220
231
|
@connection ||= Faraday.new(url: BASE_URL) do |conn|
|
221
232
|
conn.response(:json, parser_options: { symbolize_names: true })
|
222
233
|
conn.response(:raise_error) # raise_error middleware will run before the json middleware
|
234
|
+
conn.response(:logger, nil, { headers: false, bodies: { response: true }, log_level: :debug }) if @debug
|
223
235
|
conn.adapter(Faraday.default_adapter)
|
224
236
|
end
|
225
237
|
end
|
data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_error_message.rb
CHANGED
@@ -14,6 +14,7 @@ module ErrorMessage
|
|
14
14
|
INVALID_PATH = "Could not read content from"
|
15
15
|
INVALID_TESTERS = "Could not enable access for testers. Check that the groups exist and the tester emails are formatted correctly"
|
16
16
|
INVALID_RELEASE_ID = "App distribution failed to fetch release with id"
|
17
|
+
INVALID_RELEASE_NOTES = "Failed to add release notes"
|
17
18
|
SERVICE_CREDENTIALS_ERROR = "App Distribution could not generate credentials from the service credentials file specified. Service Account Path"
|
18
19
|
|
19
20
|
def self.binary_not_found(binary_type)
|
data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb
CHANGED
@@ -28,10 +28,10 @@ module Fastlane
|
|
28
28
|
CFPropertyList.native_types(CFPropertyList::List.new(file: path).value)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
app_path = parse_plist("#{
|
33
|
-
UI.shell_error!("can't extract application path from Info.plist at #{
|
34
|
-
identifier = parse_plist("#{
|
31
|
+
def get_ios_app_id_from_archive_plist(archive_path, plist_path)
|
32
|
+
app_path = parse_plist("#{archive_path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
|
33
|
+
UI.shell_error!("can't extract application path from Info.plist at #{archive_path}") if app_path.empty?
|
34
|
+
identifier = parse_plist("#{archive_path}/Products/#{app_path}/#{plist_path}")["GOOGLE_APP_ID"]
|
35
35
|
UI.shell_error!("can't extract GOOGLE_APP_ID") if identifier.empty?
|
36
36
|
return identifier
|
37
37
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-firebase_app_distribution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Natchev
|
8
8
|
- Manny Jimenez
|
9
9
|
- Alonso Salas Infante
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-09
|
13
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 2.127.1
|
141
|
-
description:
|
141
|
+
description:
|
142
142
|
email:
|
143
143
|
- snatchev@google.com
|
144
144
|
- mannyjimenez@google.com
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/fastlane/plugin/firebase_app_distribution.rb
|
153
153
|
- lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb
|
154
154
|
- lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_login.rb
|
155
|
+
- lib/fastlane/plugin/firebase_app_distribution/client/error_response.rb
|
155
156
|
- lib/fastlane/plugin/firebase_app_distribution/client/firebase_app_distribution_api_client.rb
|
156
157
|
- lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb
|
157
158
|
- lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_error_message.rb
|
@@ -162,7 +163,7 @@ homepage: https://github.com/fastlane/fastlane-plugin-firebase_app_distribution
|
|
162
163
|
licenses:
|
163
164
|
- MIT
|
164
165
|
metadata: {}
|
165
|
-
post_install_message:
|
166
|
+
post_install_message:
|
166
167
|
rdoc_options: []
|
167
168
|
require_paths:
|
168
169
|
- lib
|
@@ -177,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
178
|
- !ruby/object:Gem::Version
|
178
179
|
version: '0'
|
179
180
|
requirements: []
|
180
|
-
rubygems_version: 3.1.
|
181
|
-
signing_key:
|
181
|
+
rubygems_version: 3.1.4
|
182
|
+
signing_key:
|
182
183
|
specification_version: 4
|
183
184
|
summary: Release your beta builds to Firebase App Distribution. https://firebase.google.com/docs/app-distribution
|
184
185
|
test_files: []
|