fastlane-plugin-firebase_app_distribution 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 745bfb3dfc4c6c48f389c8e4d75b50026cf37e872ce26e7510aefef049280329
4
- data.tar.gz: 8122801b30f95422216c9c5343d102bc6b11fbc16308f268515e7a3405bbf070
3
+ metadata.gz: c8c5fed8eb93d2d6c62dee224fb08c366646a91b0ddd38d74689e5c34b0f355b
4
+ data.tar.gz: 03ee7ef5569e510ae63370cd860ec6f118f6ce5d8771c2f961d9194609232709
5
5
  SHA512:
6
- metadata.gz: 6ac42a57fdbda601b6ef2656a7e0d1b38304f022a26c970a75f1e0a43d01f2607f993c5500bceaf8ffb5b24ada6fbcbcb1ccf84d7dc8d87dc7d62049561d7886
7
- data.tar.gz: ae12197e0149e187b02716e28a71207cd5ce67d14ea331bb9c230e41a53237e1c3e4359b1178f09bf059ac2d9697cb4b667d358a1d4751a3b47006efcaf131bb
6
+ metadata.gz: e0b67fbe3ac855aec3dd70be48726d44bcae8eb021a70984ff5274431b0e093c6849ad9ddf64f6186698ffa5701950acc53c602cb48583d520738a1bfa75f6b5
7
+ data.tar.gz: ec59af9949e4d9086004c63561b2e74a3bf09b9a270b02a12e62d66a322198124c8019724ae7cd33f2f5097615dd9c068f416e3efa5bc48fe4b77e11133b6946
@@ -30,6 +30,11 @@ module Fastlane
30
30
 
31
31
  fad_api_client.add_testers(params[:project_number], emails)
32
32
 
33
+ unless blank?(params[:group_alias])
34
+ UI.message("⏳ Adding testers to group #{params[:group_alias]}...")
35
+ fad_api_client.add_testers_to_group(params[:project_number], params[:group_alias], emails)
36
+ end
37
+
33
38
  # The add_testers response lists all the testers from the request
34
39
  # regardless of whether or not they were created or if they already
35
40
  # exists so can't get an accurate count of the number of newly created testers
@@ -66,6 +71,11 @@ module Fastlane
66
71
  description: "Path to a file containing a comma separated list of tester emails to be created. A maximum of 1000 testers can be deleted at a time",
67
72
  optional: true,
68
73
  type: String),
74
+ FastlaneCore::ConfigItem.new(key: :group_alias,
75
+ env_name: "FIREBASEAPPDISTRO_ADD_TESTERS_GROUP_ALIAS",
76
+ description: "Alias of the group to add the specified testers to. The group must already exist. If not specified, testers will not be added to a group",
77
+ optional: true,
78
+ type: String),
69
79
  FastlaneCore::ConfigItem.new(key: :service_credentials_file,
70
80
  description: "Path to Google service credentials file",
71
81
  optional: true,
@@ -0,0 +1,87 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+
4
+ require_relative '../helper/firebase_app_distribution_helper'
5
+ require_relative '../helper/firebase_app_distribution_auth_client'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class FirebaseAppDistributionCreateGroupAction < Action
10
+ extend Auth::FirebaseAppDistributionAuthClient
11
+ extend Helper::FirebaseAppDistributionHelper
12
+
13
+ def self.run(params)
14
+ auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
15
+ fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, params[:debug])
16
+
17
+ if blank?(params[:alias])
18
+ UI.user_error!("Must specify `alias`.")
19
+ end
20
+
21
+ if blank?(params[:display_name])
22
+ UI.user_error!("Must specify `display_name`.")
23
+ end
24
+
25
+ project_number = params[:project_number]
26
+ group_alias = params[:alias]
27
+ display_name = params[:display_name]
28
+
29
+ UI.message("⏳ Creating tester group '#{group_alias} (#{display_name})' in project #{project_number}...")
30
+
31
+ fad_api_client.create_group(project_number, group_alias, display_name)
32
+
33
+ UI.success("✅ Group created successfully.")
34
+ end
35
+
36
+ def self.description
37
+ "Create a tester group"
38
+ end
39
+
40
+ def self.authors
41
+ ["Garry Jeromson"]
42
+ end
43
+
44
+ # supports markdown.
45
+ def self.details
46
+ "Create a tester group"
47
+ end
48
+
49
+ def self.available_options
50
+ [
51
+ FastlaneCore::ConfigItem.new(key: :project_number,
52
+ env_name: "FIREBASEAPPDISTRO_PROJECT_NUMBER",
53
+ description: "Your Firebase project number. You can find the project number in the Firebase console, on the General Settings page",
54
+ type: Integer,
55
+ optional: false),
56
+ FastlaneCore::ConfigItem.new(key: :alias,
57
+ env_name: "FIREBASEAPPDISTRO_CREATE_GROUP_ALIAS",
58
+ description: "Alias of the group to be created",
59
+ optional: false,
60
+ type: String),
61
+ FastlaneCore::ConfigItem.new(key: :display_name,
62
+ env_name: "FIREBASEAPPDISTRO_CREATE_GROUP_DISPLAY_NAME",
63
+ description: "Display name for the group to be created",
64
+ optional: false,
65
+ type: String),
66
+ FastlaneCore::ConfigItem.new(key: :service_credentials_file,
67
+ description: "Path to Google service credentials file",
68
+ optional: true,
69
+ type: String),
70
+ FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
71
+ description: "Auth token generated using the Firebase CLI's login:ci command",
72
+ optional: true,
73
+ type: String),
74
+ FastlaneCore::ConfigItem.new(key: :debug,
75
+ description: "Print verbose debug output",
76
+ optional: true,
77
+ default_value: false,
78
+ is_string: false)
79
+ ]
80
+ end
81
+
82
+ def self.is_supported?(platform)
83
+ true
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,77 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+
4
+ require_relative '../helper/firebase_app_distribution_helper'
5
+ require_relative '../helper/firebase_app_distribution_auth_client'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class FirebaseAppDistributionDeleteGroupAction < Action
10
+ extend Auth::FirebaseAppDistributionAuthClient
11
+ extend Helper::FirebaseAppDistributionHelper
12
+
13
+ def self.run(params)
14
+ auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
15
+ fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, params[:debug])
16
+
17
+ if blank?(params[:alias])
18
+ UI.user_error!("Must specify `alias`.")
19
+ end
20
+
21
+ project_number = params[:project_number]
22
+ group_alias = params[:alias]
23
+
24
+ UI.message("⏳ Deleting tester group '#{group_alias}' in project #{project_number}...")
25
+
26
+ fad_api_client.delete_group(project_number, group_alias)
27
+
28
+ UI.success("✅ Group deleted successfully.")
29
+ end
30
+
31
+ def self.description
32
+ "Delete a tester group"
33
+ end
34
+
35
+ def self.authors
36
+ ["Garry Jeromson"]
37
+ end
38
+
39
+ # supports markdown.
40
+ def self.details
41
+ "Delete a tester group"
42
+ end
43
+
44
+ def self.available_options
45
+ [
46
+ FastlaneCore::ConfigItem.new(key: :project_number,
47
+ env_name: "FIREBASEAPPDISTRO_PROJECT_NUMBER",
48
+ description: "Your Firebase project number. You can find the project number in the Firebase console, on the General Settings page",
49
+ type: Integer,
50
+ optional: false),
51
+ FastlaneCore::ConfigItem.new(key: :alias,
52
+ env_name: "FIREBASEAPPDISTRO_DELETE_GROUP_ALIAS",
53
+ description: "Alias of the group to be deleted",
54
+ optional: false,
55
+ type: String),
56
+ FastlaneCore::ConfigItem.new(key: :service_credentials_file,
57
+ description: "Path to Google service credentials file",
58
+ optional: true,
59
+ type: String),
60
+ FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
61
+ description: "Auth token generated using the Firebase CLI's login:ci command",
62
+ optional: true,
63
+ type: String),
64
+ FastlaneCore::ConfigItem.new(key: :debug,
65
+ description: "Print verbose debug output",
66
+ optional: true,
67
+ default_value: false,
68
+ is_string: false)
69
+ ]
70
+ end
71
+
72
+ def self.is_supported?(platform)
73
+ true
74
+ end
75
+ end
76
+ end
77
+ end
@@ -251,6 +251,102 @@ module Fastlane
251
251
  UI.user_error!(ErrorMessage::INVALID_PROJECT)
252
252
  end
253
253
 
254
+ # Create tester group
255
+ #
256
+ # args
257
+ # project_number - Firebase project number
258
+ # group_alias - Alias of the tester group
259
+ # display_name - Display name of the tester group
260
+ #
261
+ def create_group(project_number, group_alias, display_name)
262
+ payload = { name: "projects/#{project_number}/groups/#{group_alias}",
263
+ displayName: display_name }
264
+ response = connection.post(add_tester_group_url(project_number), payload.to_json) do |request|
265
+ request.params["groupId"] = group_alias
266
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
267
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
268
+ request.headers[CLIENT_VERSION] = client_version_header_value
269
+ end
270
+ response.body
271
+ rescue Faraday::BadRequestError
272
+ UI.user_error!(ErrorMessage::INVALID_TESTER_GROUP_NAME)
273
+ rescue Faraday::ResourceNotFound
274
+ UI.user_error!(ErrorMessage::INVALID_PROJECT)
275
+ rescue Faraday::ConflictError
276
+ UI.important("Tester group #{group_alias} already exists.")
277
+ return {
278
+ name: "projects/#{project_number}/groups/#{group_alias}"
279
+ }
280
+ rescue Faraday::ClientError => e
281
+ raise e
282
+ end
283
+
284
+ # Add testers to group
285
+ #
286
+ # args
287
+ # project_number - Firebase project number
288
+ # group_alias - Alias of the tester group
289
+ # emails - An array of emails to be added to the group.
290
+ # A maximum of 1000 testers can be added at a time, if creating missing testers is enabled.
291
+ # create_missing_testers - If true, missing testers will be created and added to the group.
292
+ #
293
+ def add_testers_to_group(project_number, group_alias, emails, create_missing_testers = false)
294
+ payload = { emails: emails,
295
+ createMissingTesters: create_missing_testers }
296
+ response = connection.post(add_testers_to_group_url(project_number, group_alias), payload.to_json) do |request|
297
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
298
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
299
+ request.headers[CLIENT_VERSION] = client_version_header_value
300
+ end
301
+ response.body
302
+ rescue Faraday::BadRequestError
303
+ UI.user_error!(ErrorMessage::INVALID_EMAIL_ADDRESS)
304
+ rescue Faraday::ResourceNotFound
305
+ UI.user_error!(ErrorMessage::INVALID_TESTER_GROUP)
306
+ rescue Faraday::ClientError => e
307
+ raise e
308
+ end
309
+
310
+ # Remove testers from group
311
+ #
312
+ # args
313
+ # project_number - Firebase project number
314
+ # group_alias - Alias of the tester group
315
+ # emails - An array of emails to be removed from the group.
316
+ #
317
+ def remove_testers_from_group(project_number, group_alias, emails)
318
+ payload = { emails: emails }
319
+ response = connection.post(remove_testers_from_group_url(project_number, group_alias), payload.to_json) do |request|
320
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
321
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
322
+ request.headers[CLIENT_VERSION] = client_version_header_value
323
+ end
324
+ response.body
325
+ rescue Faraday::BadRequestError
326
+ UI.user_error!(ErrorMessage::INVALID_EMAIL_ADDRESS)
327
+ rescue Faraday::ResourceNotFound
328
+ UI.user_error!(ErrorMessage::INVALID_TESTER_GROUP)
329
+ rescue Faraday::ClientError => e
330
+ raise e
331
+ end
332
+
333
+ # Delete tester group
334
+ #
335
+ # args
336
+ # project_number - Firebase project number
337
+ # group_alias - Alias of the tester group
338
+ #
339
+ def delete_group(project_number, group_alias)
340
+ response = connection.delete(delete_tester_group_url(project_number, group_alias)) do |request|
341
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
342
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
343
+ request.headers[CLIENT_VERSION] = client_version_header_value
344
+ end
345
+ response.body
346
+ rescue Faraday::ResourceNotFound
347
+ UI.user_error!(ErrorMessage::INVALID_TESTER_GROUP)
348
+ end
349
+
254
350
  # List releases
255
351
  #
256
352
  # args
@@ -269,7 +365,7 @@ module Fastlane
269
365
  UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_name}")
270
366
  end
271
367
 
272
- return response.body
368
+ response.body
273
369
  end
274
370
 
275
371
  private
@@ -322,6 +418,22 @@ module Fastlane
322
418
  "/v1/projects/#{project_number}/testers:batchRemove"
323
419
  end
324
420
 
421
+ def add_tester_group_url(project_number)
422
+ "/v1/projects/#{project_number}/groups"
423
+ end
424
+
425
+ def delete_tester_group_url(project_number, group_alias)
426
+ "/v1/projects/#{project_number}/groups/#{group_alias}"
427
+ end
428
+
429
+ def add_testers_to_group_url(project_number, group_alias)
430
+ "/v1/projects/#{project_number}/groups/#{group_alias}:batchJoin"
431
+ end
432
+
433
+ def remove_testers_from_group_url(project_number, group_alias)
434
+ "/v1/projects/#{project_number}/groups/#{group_alias}:batchLeave"
435
+ end
436
+
325
437
  def connection
326
438
  @connection ||= Faraday.new(url: BASE_URL) do |conn|
327
439
  conn.response(:json, parser_options: { symbolize_names: true })
@@ -13,6 +13,8 @@ module ErrorMessage
13
13
  INVALID_PROJECT = "App Distribution could not find your Firebase project. Make sure to onboard an app in your project by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution."
14
14
  INVALID_PATH = "Could not read content from"
15
15
  INVALID_TESTERS = "Could not enable access for testers. Check that the tester emails are formatted correctly, the groups exist and you are using group aliases (not group names) for specifying groups."
16
+ INVALID_TESTER_GROUP = "App Distribution could not find your tester group. Make sure that it exists before trying to add testers, and that the group alias is specified correctly."
17
+ INVALID_TESTER_GROUP_NAME = "The tester group name should be 4-63 characters, and valid characters are /[a-z][0-9]-/."
16
18
  INVALID_RELEASE_NOTES = "Failed to add release notes"
17
19
  SERVICE_CREDENTIALS_ERROR = "App Distribution could not generate credentials from the service credentials file specified"
18
20
  PLAY_ACCOUNT_NOT_LINKED = "This project is not linked to a Google Play account."
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
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.5.0
4
+ version: 0.6.0
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-02-15 00:00:00.000000000 Z
13
+ date: 2023-06-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -153,6 +153,8 @@ files:
153
153
  - lib/fastlane/plugin/firebase_app_distribution.rb
154
154
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb
155
155
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb
156
+ - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_create_group_action.rb
157
+ - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_delete_group_action.rb
156
158
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb
157
159
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb
158
160
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
185
  - !ruby/object:Gem::Version
184
186
  version: '0'
185
187
  requirements: []
186
- rubygems_version: 3.4.6
188
+ rubygems_version: 3.4.10
187
189
  signing_key:
188
190
  specification_version: 4
189
191
  summary: Release your beta builds to Firebase App Distribution. https://firebase.google.com/docs/app-distribution