fastlane-plugin-firebase_app_distribution 0.2.2.pre.1 → 0.2.5

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: 3bb962d7530d1226f6f4811578bebe6086c1e1d82222ed5d935e3314cb933a50
4
- data.tar.gz: e2cd536750a1b8e328cba78a43329d4bab7988d74fee1f83ececf19963812acd
3
+ metadata.gz: 1415793a828ae696b67f1568c6393a9ae68eb6dbf17fc2a379904e3256201c1b
4
+ data.tar.gz: b1e08e8e78359f62c2c76c868c8e80e90bdf3d463951072ecf77aaa46a232ad1
5
5
  SHA512:
6
- metadata.gz: b439ab0e98082e51dc96f0f29009aa7ffe83aca6c347f3967ee85e68077161cec8621aeac6861470266226132eec2fa1ae2cd3676be081cf97cc909b948e614d
7
- data.tar.gz: 9b5777d5e274a92963b57253a81a9866a461f2024f4abf9226b247a65f6e0b4a2f03fc7c439133935115921aadec767048a0a8e68cb03d6a652db36152b7ab60
6
+ metadata.gz: a3c2f313a6401ac052c48329d9f21228c084983c6f6a3c252e22c494c4216b57ee68882668e1f3f6f0e5f639b3389b0701d97dad3c3542289099450aea2f1952
7
+ data.tar.gz: 29c7622c069712c0012429c26e3ad7e306499c6a29d7a7d837185a008837831dba795787a16930817dbbdbb3aabb0f38f37c06094208d2e1376cff030c79733d
@@ -21,23 +21,12 @@ module Fastlane
21
21
  def self.run(params)
22
22
  params.values # to validate all inputs before looking for the ipa/apk
23
23
 
24
- if params[:app] # Set app_id if it is specified as a parameter
25
- app_id = params[:app]
26
- elsif platform == :ios
27
- archive_path = Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
28
- if archive_path
29
- app_id = get_ios_app_id_from_archive(archive_path)
30
- end
31
- end
32
- if app_id.nil?
33
- UI.crash!(ErrorMessage::MISSING_APP_ID)
34
- end
35
-
24
+ app_id = app_id_from_params(params)
36
25
  platform = lane_platform || platform_from_app_id(app_id)
37
26
  binary_path = binary_path_from_platform(platform, params[:ipa_path], params[:apk_path])
38
27
 
39
28
  auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
40
- fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, platform)
29
+ fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, platform, params[:debug])
41
30
 
42
31
  release_id = fad_api_client.upload(app_id, binary_path, platform.to_s)
43
32
  if release_id.nil?
@@ -68,6 +57,27 @@ module Fastlane
68
57
  "Release your beta builds with Firebase App Distribution"
69
58
  end
70
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
+
71
81
  def self.lane_platform
72
82
  Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
73
83
  end
@@ -111,6 +121,12 @@ module Fastlane
111
121
  verify_block: proc do |value|
112
122
  UI.user_error!("firebase_app_distribution: Couldn't find ipa file at path '#{value}'") unless File.exist?(value)
113
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 archived product path",
127
+ default_value: "GoogleService-Info.plist",
128
+ optional: true,
129
+ type: String),
114
130
  # Android Specific
115
131
  FastlaneCore::ConfigItem.new(key: :apk_path,
116
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
@@ -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
- def initialize(auth_token, platform)
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"
@@ -30,7 +37,7 @@ module Fastlane
30
37
  # emails - String array of app testers' email addresses
31
38
  # group_ids - String array of Firebase tester group IDs
32
39
  #
33
- # Throws a user_error if app_id, emails, or group_ids are invalid
40
+ # Throws a user_error if emails or group_ids are invalid
34
41
  def enable_access(app_id, release_id, emails, group_ids)
35
42
  if (emails.nil? || emails.empty?) && (group_ids.nil? || group_ids.empty?)
36
43
  UI.success("✅ No testers passed in. Skipping this step.")
@@ -39,10 +46,9 @@ 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["Authorization"] = "Bearer " + @auth_token
49
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
50
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
43
51
  end
44
- rescue Faraday::ResourceNotFound
45
- UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
46
52
  rescue Faraday::ClientError
47
53
  UI.user_error!("#{ErrorMessage::INVALID_TESTERS} \nEmails: #{emails} \nGroups: #{group_ids}")
48
54
  end
@@ -57,7 +63,7 @@ module Fastlane
57
63
  # release_id - App release ID, returned by upload_status endpoint
58
64
  # release_notes - String of notes for this release
59
65
  #
60
- # Throws a user_error if app_id or release_id are invalid
66
+ # Throws a user_error if the release_notes are invalid
61
67
  def post_notes(app_id, release_id, release_notes)
62
68
  payload = { releaseNotes: { releaseNotes: release_notes } }
63
69
  if release_notes.nil? || release_notes.empty?
@@ -66,12 +72,12 @@ module Fastlane
66
72
  end
67
73
  begin
68
74
  connection.post(release_notes_create_url(app_id, release_id), payload.to_json) do |request|
69
- request.headers["Authorization"] = "Bearer " + @auth_token
75
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
76
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
70
77
  end
71
- rescue Faraday::ResourceNotFound
72
- UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
73
- # rescue Faraday::ClientError
74
- # UI.user_error!("#{ErrorMessage::INVALID_RELEASE_ID}: #{release_id}")
78
+ rescue Faraday::ClientError => e
79
+ error = ErrorResponse.new(e.response)
80
+ UI.user_error!("#{ErrorMessage::INVALID_RELEASE_NOTES}: #{error.message}")
75
81
  end
76
82
  UI.success("✅ Posted release notes.")
77
83
  end
@@ -93,7 +99,7 @@ module Fastlane
93
99
 
94
100
  begin
95
101
  response = connection.get(v1_apps_url(app_id)) do |request|
96
- request.headers["Authorization"] = "Bearer " + @auth_token
102
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
97
103
  end
98
104
  rescue Faraday::ResourceNotFound
99
105
  UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
@@ -112,16 +118,15 @@ module Fastlane
112
118
  # binary_path - Absolute path to your app's apk/ipa file
113
119
  # platform - 'android' or 'ios'
114
120
  #
115
- # Throws a user_error if an invalid app id is passed in, or if the binary file does not exist
121
+ # Throws a user_error if the binary file does not exist
116
122
  def upload_binary(app_id, binary_path, platform)
117
123
  connection.post(binary_upload_url(app_id), read_binary(binary_path)) do |request|
118
- request.headers["Authorization"] = "Bearer " + @auth_token
124
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
125
+ request.headers[CONTENT_TYPE] = APPLICATION_OCTET_STREAM
119
126
  request.headers["X-APP-DISTRO-API-CLIENT-ID"] = "fastlane"
120
127
  request.headers["X-APP-DISTRO-API-CLIENT-TYPE"] = platform
121
128
  request.headers["X-APP-DISTRO-API-CLIENT-VERSION"] = Fastlane::FirebaseAppDistribution::VERSION
122
129
  end
123
- rescue Faraday::ResourceNotFound
124
- UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
125
130
  rescue Errno::ENOENT # Raised when binary_path file does not exist
126
131
  UI.user_error!("#{ErrorMessage.binary_not_found(@binary_type)}: #{binary_path}")
127
132
  end
@@ -177,15 +182,9 @@ module Fastlane
177
182
  # upload_token - URL encoded upload token
178
183
  #
179
184
  # Returns the release ID on a successful release, otherwise returns nil.
180
- #
181
- # Throws a user_error if an invalid app_id is passed in
182
185
  def get_upload_status(app_id, upload_token)
183
- begin
184
- response = connection.get(upload_status_url(app_id, upload_token)) do |request|
185
- request.headers["Authorization"] = "Bearer " + @auth_token
186
- end
187
- rescue Faraday::ResourceNotFound
188
- UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
186
+ response = connection.get(upload_status_url(app_id, upload_token)) do |request|
187
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
189
188
  end
190
189
  return UploadStatusResponse.new(response.body)
191
190
  end
@@ -220,6 +219,7 @@ module Fastlane
220
219
  @connection ||= Faraday.new(url: BASE_URL) do |conn|
221
220
  conn.response(:json, parser_options: { symbolize_names: true })
222
221
  conn.response(:raise_error) # raise_error middleware will run before the json middleware
222
+ conn.response(:logger, nil, { headers: false, bodies: { response: true }, log_level: :debug }) if @debug
223
223
  conn.adapter(Faraday.default_adapter)
224
224
  end
225
225
  end
@@ -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)
@@ -28,10 +28,10 @@ module Fastlane
28
28
  CFPropertyList.native_types(CFPropertyList::List.new(file: path).value)
29
29
  end
30
30
 
31
- def get_ios_app_id_from_archive(path)
32
- app_path = parse_plist("#{path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
33
- UI.shell_error!("can't extract application path from Info.plist at #{path}") if app_path.empty?
34
- identifier = parse_plist("#{path}/Products/#{app_path}/GoogleService-Info.plist")["GOOGLE_APP_ID"]
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.2.2.pre.1"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  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.2.pre.1
4
+ version: 0.2.5
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-17 00:00:00.000000000 Z
13
+ date: 2021-01-06 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
@@ -173,12 +174,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
174
  version: '0'
174
175
  required_rubygems_version: !ruby/object:Gem::Requirement
175
176
  requirements:
176
- - - ">"
177
+ - - ">="
177
178
  - !ruby/object:Gem::Version
178
- version: 1.3.1
179
+ version: '0'
179
180
  requirements: []
180
- rubygems_version: 3.1.2
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: []