fastlane-plugin-firebase_app_distribution 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf7cfe204f09a005063f099ef379887cda33351ed6f1dfd1bb84773b1c989a4f
4
- data.tar.gz: 3fc3e7c82e6506a670ab6b137ab8a4a55d968ba5f89ff0f20bcb0448ca0d2f76
3
+ metadata.gz: 2f128010598972c74283a13b7f0b5f4caf6d6e5c81a55d29afe2ce95aaec1689
4
+ data.tar.gz: cee09afb5df6a71d152b83aa8bd1ffb9d345d1a4bb67d023d873d66ee4a1ea8e
5
5
  SHA512:
6
- metadata.gz: c25cb0b20720cd286c3665d8496b7c66e90121f34c2802fa7e63e52835a54aff81cc7fe2c91313af45a9e69ded27560b495917da498d0ea13a34712ae323dbbf
7
- data.tar.gz: 1b45cb5e6657fac457d9bf34bbe4e5a624a8f912b193eaf58138d964cdb3d793aac0bf5036cd56dd997dee1b25e57ab2d30602a122e2c9f24d7171c8f7b25ccc
6
+ metadata.gz: 9c07147d44692df714866c88cfd48a6562e51727bb37bdd2e330060432f3f19301988942304d124aab72005b061e0139b6d781871af66469de76236f9da09e24
7
+ data.tar.gz: 515ce2300fe54efef6e165d3a942268ee80624d7fed9feba07144893855e34144899d03e4d770b6e3088282e743fb272c231f919e5658e758508f18bec65c14a
@@ -89,10 +89,6 @@ module Fastlane
89
89
  app_id
90
90
  end
91
91
 
92
- def self.app_name_from_app_id(app_id)
93
- "projects/#{app_id.split(':')[1]}/apps/#{app_id}"
94
- end
95
-
96
92
  def self.xcode_archive_path
97
93
  # prevents issues on cross-platform build environments where an XCode build happens within
98
94
  # the same lane
@@ -187,7 +183,7 @@ module Fastlane
187
183
  default_value_dynamic: true,
188
184
  optional: true,
189
185
  verify_block: proc do |value|
190
- UI.user_error!("firebase_app_distribution: '#{value}' is not a valid value for android_artifact_path. Should be 'APK' or 'AAB'") unless ['APK', 'AAB'].include?(value)
186
+ UI.user_error!("firebase_app_distribution: '#{value}' is not a valid value for android_artifact_type. Should be 'APK' or 'AAB'") unless ['APK', 'AAB'].include?(value)
191
187
  end),
192
188
  FastlaneCore::ConfigItem.new(key: :app,
193
189
  env_name: "FIREBASEAPPDISTRO_APP",
@@ -230,7 +226,7 @@ module Fastlane
230
226
  optional: true,
231
227
  type: String),
232
228
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
233
- description: "Auth token for firebase cli",
229
+ description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
234
230
  optional: true,
235
231
  type: String),
236
232
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -71,7 +71,7 @@ module Fastlane
71
71
  optional: true,
72
72
  type: String),
73
73
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
74
- description: "Auth token for firebase cli",
74
+ description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
75
75
  optional: true,
76
76
  type: String),
77
77
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -0,0 +1,111 @@
1
+ require 'fastlane/action'
2
+ require_relative '../client/firebase_app_distribution_api_client'
3
+ require_relative '../helper/firebase_app_distribution_auth_client'
4
+ require_relative '../helper/firebase_app_distribution_helper'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class FirebaseAppDistributionGetLatestReleaseAction < Action
9
+ extend Auth::FirebaseAppDistributionAuthClient
10
+ extend Helper::FirebaseAppDistributionHelper
11
+
12
+ def self.run(params)
13
+ auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
14
+ fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, params[:debug])
15
+
16
+ UI.message("⏳ Fetching latest release for app #{params[:app]}...")
17
+
18
+ releases = fad_api_client.list_releases(app_name_from_app_id(params[:app]), 1)[:releases] || []
19
+ if releases.empty?
20
+ latest_release = nil
21
+ UI.important("No releases for app #{params[:app]} found in App Distribution. Returning nil and setting Actions.lane_context[:FIREBASE_APP_DISTRO_LATEST_RELEASE].")
22
+ else
23
+ latest_release = releases[0]
24
+ UI.success("✅ Latest release fetched successfully. Returning release and setting Actions.lane_context[:FIREBASE_APP_DISTRO_LATEST_RELEASE].")
25
+ end
26
+ Actions.lane_context[:FIREBASE_APP_DISTRO_LATEST_RELEASE] = latest_release
27
+ return latest_release
28
+ end
29
+
30
+ #####################################################
31
+ # @!group Documentation
32
+ #####################################################
33
+
34
+ def self.description
35
+ "Fetches the latest release in Firebase App Distribution"
36
+ end
37
+
38
+ def self.details
39
+ [
40
+ "Fetches information about the most recently created release in App Distribution, including the version and release notes. Returns nil if no releases are found."
41
+ ].join("\n")
42
+ end
43
+
44
+ def self.available_options
45
+ [
46
+ FastlaneCore::ConfigItem.new(key: :app,
47
+ env_name: "FIREBASEAPPDISTRO_APP",
48
+ description: "Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page",
49
+ optional: false,
50
+ type: String),
51
+ FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
52
+ description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
53
+ optional: true,
54
+ type: String),
55
+ FastlaneCore::ConfigItem.new(key: :service_credentials_file,
56
+ description: "Path to Google service account json",
57
+ optional: true,
58
+ type: String),
59
+ FastlaneCore::ConfigItem.new(key: :debug,
60
+ description: "Print verbose debug output",
61
+ optional: true,
62
+ default_value: false,
63
+ is_string: false)
64
+ ]
65
+ end
66
+
67
+ def self.output
68
+ [
69
+ ['FIREBASE_APP_DISTRO_LATEST_RELEASE', 'A hash representing the lastest release created in Firebase App Distribution']
70
+ ]
71
+ end
72
+
73
+ def self.return_value
74
+ "Hash representation of the lastest release created in Firebase App Distribution (see https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.apps.releases#resource:-release)"
75
+ end
76
+
77
+ def self.return_type
78
+ :hash
79
+ end
80
+
81
+ def self.authors
82
+ ["lkellogg@google.com"]
83
+ end
84
+
85
+ def self.is_supported?(platform)
86
+ true
87
+ end
88
+
89
+ def self.example_code
90
+ [
91
+ 'release = firebase_app_distribution_get_latest_release(app: "1:1234567890:ios:0a1b2c3d4e5f67890")',
92
+ 'increment_build_number({
93
+ build_number: firebase_app_distribution_get_latest_release(app: "1:1234567890:ios:0a1b2c3d4e5f67890")[:buildVersion].to_i + 1
94
+ })'
95
+ ]
96
+ end
97
+
98
+ def self.sample_return_value
99
+ {
100
+ name: "projects/123456789/apps/1:1234567890:ios:0a1b2c3d4e5f67890/releases/0a1b2c3d4",
101
+ releaseNotes: {
102
+ text: "Here are some release notes!"
103
+ },
104
+ displayVersion: "1.2.3",
105
+ buildVersion: "10",
106
+ createTime: "2021-10-06T15:01:23Z"
107
+ }
108
+ end
109
+ end
110
+ end
111
+ end
@@ -63,7 +63,7 @@ module Fastlane
63
63
  optional: false,
64
64
  type: String),
65
65
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
66
- description: "Auth token for firebase cli",
66
+ description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
67
67
  optional: true,
68
68
  type: String),
69
69
  FastlaneCore::ConfigItem.new(key: :service_credentials_file,
@@ -68,7 +68,7 @@ module Fastlane
68
68
  optional: true,
69
69
  type: String),
70
70
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
71
- description: "Auth token for firebase cli",
71
+ description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
72
72
  optional: true,
73
73
  type: String),
74
74
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -220,7 +220,7 @@ module Fastlane
220
220
  rescue Faraday::ResourceNotFound
221
221
  UI.user_error!(ErrorMessage::INVALID_PROJECT)
222
222
  rescue Faraday::ClientError => e
223
- if e.response_status == 429
223
+ if e.response[:status] == 429
224
224
  UI.user_error!(ErrorMessage::TESTER_LIMIT_VIOLATION)
225
225
  else
226
226
  raise e
@@ -247,6 +247,27 @@ module Fastlane
247
247
  UI.user_error!(ErrorMessage::INVALID_PROJECT)
248
248
  end
249
249
 
250
+ # List releases
251
+ #
252
+ # args
253
+ # app_name - Firebase App resource name
254
+ # page_size - The number of releases to return in the page
255
+ # page_token - A page token, received from a previous call
256
+ #
257
+ # Returns the response body. Throws a user_error if the app hasn't been onboarded to App Distribution.
258
+ def list_releases(app_name, page_size = 100, page_token = nil)
259
+ begin
260
+ response = connection.get(list_releases_url(app_name), { pageSize: page_size.to_s, pageToken: page_token }) do |request|
261
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
262
+ request.headers[CLIENT_VERSION] = client_version_header_value
263
+ end
264
+ rescue Faraday::ResourceNotFound
265
+ UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_name}")
266
+ end
267
+
268
+ return response.body
269
+ end
270
+
250
271
  private
251
272
 
252
273
  def client_version_header_value
@@ -281,6 +302,10 @@ module Fastlane
281
302
  "/v1/#{operation_name}"
282
303
  end
283
304
 
305
+ def list_releases_url(app_name)
306
+ "#{v1_apps_url(app_name)}/releases"
307
+ end
308
+
284
309
  def get_udids_url(app_id)
285
310
  "#{v1alpha_apps_url(app_id)}/testers:getTesterUdids"
286
311
  end
@@ -53,6 +53,10 @@ module Fastlane
53
53
  def present?(value)
54
54
  !blank?(value)
55
55
  end
56
+
57
+ def app_name_from_app_id(app_id)
58
+ "projects/#{app_id.split(':')[1]}/apps/#{app_id}"
59
+ end
56
60
  end
57
61
  end
58
62
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2.pre.1"
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.1
4
+ version: 0.3.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: 2021-08-27 00:00:00.000000000 Z
13
+ date: 2021-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -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_add_testers_action.rb
155
+ - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb
155
156
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb
156
157
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_login.rb
157
158
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb
@@ -178,9 +179,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
179
  version: '0'
179
180
  required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  requirements:
181
- - - ">="
182
+ - - ">"
182
183
  - !ruby/object:Gem::Version
183
- version: '0'
184
+ version: 1.3.1
184
185
  requirements: []
185
186
  rubygems_version: 3.0.3
186
187
  signing_key: