fastlane-plugin-firebase_app_distribution 0.4.2 → 0.5.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: 0c1ecfa3d259597531bf5d000974d70de8f91aaf2e530f4b277f9382627bb27c
4
- data.tar.gz: 64de62eea1701401a75adee5b412970e6bc3abb14964ad9f4fc7a57ce74d03e6
3
+ metadata.gz: 745bfb3dfc4c6c48f389c8e4d75b50026cf37e872ce26e7510aefef049280329
4
+ data.tar.gz: 8122801b30f95422216c9c5343d102bc6b11fbc16308f268515e7a3405bbf070
5
5
  SHA512:
6
- metadata.gz: 01423717bdd9b128f047b81c3e91072067441aeb0378b27e45b72af59f4387bb37d40144f2d082f1608bcf59f709bae0feefa9fcdba490873e679fff9898dca2
7
- data.tar.gz: 02d60865da2daee4b649bcebe14c35f64eaba2c8fd09f4ebd21d3099632779492d81eeac454697052db836ba63425f68ef7a1a59656d6f915b14a36a57cc2096
6
+ metadata.gz: 6ac42a57fdbda601b6ef2656a7e0d1b38304f022a26c970a75f1e0a43d01f2607f993c5500bceaf8ffb5b24ada6fbcbcb1ccf84d7dc8d87dc7d62049561d7886
7
+ data.tar.gz: ae12197e0149e187b02716e28a71207cd5ce67d14ea331bb9c230e41a53237e1c3e4359b1178f09bf059ac2d9697cb4b667d358a1d4751a3b47006efcaf131bb
@@ -11,6 +11,10 @@ require_relative '../helper/firebase_app_distribution_auth_client'
11
11
  ## How should we document the usage of release notes?
12
12
  module Fastlane
13
13
  module Actions
14
+ module SharedValues
15
+ FIREBASE_APP_DISTRO_RELEASE ||= :FIREBASE_APP_DISTRO_RELEASE
16
+ end
17
+
14
18
  class FirebaseAppDistributionAction < Action
15
19
  extend Auth::FirebaseAppDistributionAuthClient
16
20
  extend Helper::FirebaseAppDistributionHelper
@@ -48,6 +52,7 @@ module Fastlane
48
52
 
49
53
  upload_status_response = fad_api_client.upload(app_name, binary_path, platform.to_s, upload_timeout)
50
54
  release_name = upload_status_response.release_name
55
+ release = upload_status_response.release
51
56
 
52
57
  if binary_type == :AAB && aab_info && !aab_info.certs_provided?
53
58
  updated_aab_info = fad_api_client.get_aab_info(app_name)
@@ -62,14 +67,19 @@ module Fastlane
62
67
  end
63
68
  end
64
69
 
65
- fad_api_client.update_release_notes(release_name, release_notes(params))
70
+ release_notes = release_notes(params)
71
+ if release_notes.nil? || release_notes.empty?
72
+ UI.message("⏩ No release notes passed in. Skipping this step.")
73
+ else
74
+ release = fad_api_client.update_release_notes(release_name, release_notes)
75
+ end
66
76
 
67
77
  testers = get_value_from_value_or_file(params[:testers], params[:testers_file])
68
78
  groups = get_value_from_value_or_file(params[:groups], params[:groups_file])
69
79
  emails = string_to_array(testers)
70
80
  group_aliases = string_to_array(groups)
71
81
  fad_api_client.distribute(release_name, emails, group_aliases)
72
- UI.success("🎉 App Distribution upload finished successfully.")
82
+ UI.success("🎉 App Distribution upload finished successfully. Setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_RELEASE] to the uploaded release.")
73
83
 
74
84
  if upload_status_response.firebase_console_uri
75
85
  UI.message("🔗 View this release in the Firebase console: #{upload_status_response.firebase_console_uri}")
@@ -82,6 +92,9 @@ module Fastlane
82
92
  if upload_status_response.binary_download_uri
83
93
  UI.message("🔗 Download the release binary (link expires in 1 hour): #{upload_status_response.binary_download_uri}")
84
94
  end
95
+
96
+ Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_RELEASE] = release
97
+ release
85
98
  end
86
99
 
87
100
  def self.description
@@ -256,7 +269,7 @@ module Fastlane
256
269
  optional: true,
257
270
  type: String),
258
271
  FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
259
- description: "Auth token generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
272
+ description: "Auth token generated using the Firebase CLI's login:ci command",
260
273
  optional: true,
261
274
  type: String),
262
275
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -294,6 +307,12 @@ module Fastlane
294
307
  CODE
295
308
  ]
296
309
  end
310
+
311
+ def self.output
312
+ [
313
+ ['FIREBASE_APP_DISTRO_RELEASE', 'A hash representing the uploaded release created in Firebase App Distribution']
314
+ ]
315
+ end
297
316
  end
298
317
  end
299
318
  end
@@ -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 generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
74
+ description: "Auth token generated using the Firebase CLI's login:ci command",
75
75
  optional: true,
76
76
  type: String),
77
77
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -5,6 +5,9 @@ require_relative '../helper/firebase_app_distribution_helper'
5
5
 
6
6
  module Fastlane
7
7
  module Actions
8
+ module SharedValues
9
+ FIREBASE_APP_DISTRO_LATEST_RELEASE ||= :FIREBASE_APP_DISTRO_LATEST_RELEASE
10
+ end
8
11
  class FirebaseAppDistributionGetLatestReleaseAction < Action
9
12
  extend Auth::FirebaseAppDistributionAuthClient
10
13
  extend Helper::FirebaseAppDistributionHelper
@@ -18,12 +21,12 @@ module Fastlane
18
21
  releases = fad_api_client.list_releases(app_name_from_app_id(params[:app]), 1)[:releases] || []
19
22
  if releases.empty?
20
23
  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].")
24
+ UI.important("No releases for app #{params[:app]} found in App Distribution. Returning nil and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
22
25
  else
23
26
  latest_release = releases[0]
24
- UI.success("✅ Latest release fetched successfully. Returning release and setting Actions.lane_context[:FIREBASE_APP_DISTRO_LATEST_RELEASE].")
27
+ UI.success("✅ Latest release fetched successfully. Returning release and setting Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE].")
25
28
  end
26
- Actions.lane_context[:FIREBASE_APP_DISTRO_LATEST_RELEASE] = latest_release
29
+ Actions.lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE] = latest_release
27
30
  return latest_release
28
31
  end
29
32
 
@@ -49,7 +52,7 @@ module Fastlane
49
52
  optional: false,
50
53
  type: String),
51
54
  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",
55
+ description: "Auth token generated using Firebase CLI's login:ci command",
53
56
  optional: true,
54
57
  type: String),
55
58
  FastlaneCore::ConfigItem.new(key: :service_credentials_file,
@@ -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 generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
66
+ description: "Auth token generated using 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 generated using 'fastlane run firebase_app_distribution_login', or the Firebase CLI's login:ci command",
71
+ description: "Auth token generated using the Firebase CLI's login:ci command",
72
72
  optional: true,
73
73
  type: String),
74
74
  FastlaneCore::ConfigItem.new(key: :debug,
@@ -1,5 +1,4 @@
1
1
  require 'fastlane_core/ui/ui'
2
- require_relative '../actions/firebase_app_distribution_login'
3
2
  require_relative '../client/error_response'
4
3
  require_relative '../client/aab_info'
5
4
  require_relative '../helper/firebase_app_distribution_helper'
@@ -59,29 +58,26 @@ module Fastlane
59
58
  # release_name - App release resource name, returned by upload_status endpoint
60
59
  # release_notes - String of notes for this release
61
60
  #
61
+ # Returns a hash of the release
62
+ #
62
63
  # Throws a user_error if the release_notes are invalid
63
64
  def update_release_notes(release_name, release_notes)
64
- if release_notes.nil? || release_notes.empty?
65
- UI.success("✅ No release notes passed in. Skipping this step.")
66
- return
67
- end
68
- begin
69
- payload = {
70
- name: release_name,
71
- releaseNotes: {
72
- text: release_notes
73
- }
65
+ payload = {
66
+ name: release_name,
67
+ releaseNotes: {
68
+ text: release_notes
74
69
  }
75
- connection.patch(update_release_notes_url(release_name), payload.to_json) do |request|
76
- request.headers[AUTHORIZATION] = "Bearer " + @auth_token
77
- request.headers[CONTENT_TYPE] = APPLICATION_JSON
78
- request.headers[CLIENT_VERSION] = client_version_header_value
79
- end
80
- rescue Faraday::ClientError => e
81
- error = ErrorResponse.new(e.response)
82
- UI.user_error!("#{ErrorMessage::INVALID_RELEASE_NOTES}: #{error.message}")
70
+ }
71
+ response = connection.patch(update_release_notes_url(release_name), payload.to_json) do |request|
72
+ request.headers[AUTHORIZATION] = "Bearer " + @auth_token
73
+ request.headers[CONTENT_TYPE] = APPLICATION_JSON
74
+ request.headers[CLIENT_VERSION] = client_version_header_value
83
75
  end
84
76
  UI.success("✅ Posted release notes.")
77
+ response.body
78
+ rescue Faraday::ClientError => e
79
+ error = ErrorResponse.new(e.response)
80
+ UI.user_error!("#{ErrorMessage::INVALID_RELEASE_NOTES}: #{error.message}")
85
81
  end
86
82
 
87
83
  # Get AAB info (Android apps only)
@@ -136,7 +132,7 @@ module Fastlane
136
132
  # binary_path - Absolute path to your app's aab/apk/ipa file
137
133
  # timeout - The amount of seconds before the upload will timeout, if not completed
138
134
  #
139
- # Returns the release_name of the uploaded release.
135
+ # Returns a `UploadStatusResponse` with the upload is complete.
140
136
  #
141
137
  # Crashes if the number of polling retries exceeds MAX_POLLING_RETRIES or if the binary cannot
142
138
  # be uploaded.
@@ -6,6 +6,12 @@ module Fastlane
6
6
  TOKEN_CREDENTIAL_URI = "https://oauth2.googleapis.com/token"
7
7
  REDACTION_EXPOSED_LENGTH = 5
8
8
  REDACTION_CHARACTER = "X"
9
+ SCOPE = "https://www.googleapis.com/auth/cloud-platform"
10
+
11
+ # In this type of application, the client secret is not treated as a secret.
12
+ # See: https://developers.google.com/identity/protocols/OAuth2InstalledApp
13
+ CLIENT_ID = "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com"
14
+ CLIENT_SECRET = "j9iVZfS8kkCEFUPaAeJV0sAi"
9
15
 
10
16
  # Returns the auth token for any of the auth methods (Firebase CLI token,
11
17
  # Google service account, firebase-tools). To ensure that a specific
@@ -13,8 +19,7 @@ module Fastlane
13
19
  #
14
20
  # args
15
21
  # google_service_path - Absolute path to the Google service account file
16
- # firebase_cli_token - Firebase CLI refresh token from login action or
17
- # CI environment
22
+ # firebase_cli_token - Refresh token
18
23
  # debug - Whether to enable debug-level logging
19
24
  #
20
25
  # env variables
@@ -74,8 +79,8 @@ module Fastlane
74
79
  def firebase_token(refresh_token, debug)
75
80
  client = Signet::OAuth2::Client.new(
76
81
  token_credential_uri: TOKEN_CREDENTIAL_URI,
77
- client_id: Fastlane::Actions::FirebaseAppDistributionLoginAction::CLIENT_ID,
78
- client_secret: Fastlane::Actions::FirebaseAppDistributionLoginAction::CLIENT_SECRET,
82
+ client_id: CLIENT_ID,
83
+ client_secret: CLIENT_SECRET,
79
84
  refresh_token: refresh_token
80
85
  )
81
86
  client.fetch_access_token!
@@ -94,7 +99,7 @@ module Fastlane
94
99
  def service_account(google_service_path, debug)
95
100
  service_account_credentials = Google::Auth::ServiceAccountCredentials.make_creds(
96
101
  json_key_io: File.open(google_service_path),
97
- scope: Fastlane::Actions::FirebaseAppDistributionLoginAction::SCOPE
102
+ scope: SCOPE
98
103
  )
99
104
  service_account_credentials.fetch_access_token!["access_token"]
100
105
  rescue Errno::ENOENT
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.4.2"
3
+ VERSION = "0.5.0"
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.4.2
4
+ version: 0.5.0
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: 2023-01-24 00:00:00.000000000 Z
13
+ date: 2023-02-15 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
@@ -155,7 +155,6 @@ files:
155
155
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb
156
156
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb
157
157
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb
158
- - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_login.rb
159
158
  - lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb
160
159
  - lib/fastlane/plugin/firebase_app_distribution/client/aab_info.rb
161
160
  - lib/fastlane/plugin/firebase_app_distribution/client/error_response.rb
@@ -169,7 +168,7 @@ homepage: https://github.com/fastlane/fastlane-plugin-firebase_app_distribution
169
168
  licenses:
170
169
  - MIT
171
170
  metadata: {}
172
- post_install_message:
171
+ post_install_message:
173
172
  rdoc_options: []
174
173
  require_paths:
175
174
  - lib
@@ -184,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
183
  - !ruby/object:Gem::Version
185
184
  version: '0'
186
185
  requirements: []
187
- rubygems_version: 3.1.6
188
- signing_key:
186
+ rubygems_version: 3.4.6
187
+ signing_key:
189
188
  specification_version: 4
190
189
  summary: Release your beta builds to Firebase App Distribution. https://firebase.google.com/docs/app-distribution
191
190
  test_files: []
@@ -1,121 +0,0 @@
1
- require 'googleauth'
2
- require "fileutils"
3
-
4
- module Fastlane
5
- module Actions
6
- class FirebaseAppDistributionLoginAction < Action
7
- SCOPE = "https://www.googleapis.com/auth/cloud-platform"
8
-
9
- # In this type of application, the client secret is not treated as a secret.
10
- # See: https://developers.google.com/identity/protocols/OAuth2InstalledApp
11
- CLIENT_ID = "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com"
12
- CLIENT_SECRET = "j9iVZfS8kkCEFUPaAeJV0sAi"
13
-
14
- def self.run(params)
15
- callback_uri = "http://localhost:#{params[:port]}"
16
- client_id = Google::Auth::ClientId.new(CLIENT_ID, CLIENT_SECRET)
17
- authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, nil, callback_uri)
18
-
19
- # Create an anti-forgery state token as described here:
20
- # https://developers.google.com/identity/protocols/OpenIDConnect#createxsrftoken
21
- state = SecureRandom.hex(16)
22
- url = authorizer.get_authorization_url(state: state)
23
-
24
- UI.message("Open the following address in your browser and sign in with your Google account:")
25
- UI.message(url)
26
-
27
- response_params = get_authorization_code(params[:port])
28
-
29
- # Confirm that the state in the response matches the state token used to
30
- # generate the authorization URL.
31
- unless state == response_params['state'][0]
32
- UI.crash!('An error has occurred. The state parameter in the authorization response does not match the expected state, which could mean that a malicious attacker is trying to make a login request.')
33
- end
34
-
35
- user_credentials = authorizer.get_credentials_from_code(
36
- code: response_params['code'][0]
37
- )
38
- UI.success("Set the refresh token as the FIREBASE_TOKEN environment variable")
39
- UI.success("Refresh Token: #{user_credentials.refresh_token}")
40
- rescue => error
41
- UI.error(error.to_s)
42
- UI.crash!("An error has occurred, please login again.")
43
- end
44
-
45
- def self.get_authorization_code(port)
46
- begin
47
- server = TCPServer.open(port)
48
- rescue Errno::EADDRINUSE => error
49
- UI.error(error.to_s)
50
- UI.crash!("Port #{port} is in use. Please specify a different one using the port parameter.")
51
- end
52
- client = server.accept
53
- callback_request = client.readline
54
- # Use a regular expression to extract the request line from the first line of
55
- # the callback request, e.g.:
56
- # GET /?code=AUTH_CODE&state=XYZ&scope=... HTTP/1.1
57
- matcher = /GET +([^ ]+)/.match(callback_request)
58
- response_params = CGI.parse(URI.parse(matcher[1]).query) unless matcher.nil?
59
-
60
- client.puts("HTTP/1.1 200 OK")
61
- client.puts("Content-Type: text/html")
62
- client.puts("")
63
- client.puts("<b>")
64
- if response_params['code'].nil?
65
- client.puts("Failed to retrieve authorization code.")
66
- else
67
- client.puts("Authorization code was successfully retrieved.")
68
- end
69
- client.puts("</b>")
70
- client.puts("<p>Please check the console output.</p>")
71
- client.close
72
-
73
- return response_params
74
- end
75
-
76
- #####################################################
77
- # @!group Documentation
78
- #####################################################
79
-
80
- def self.description
81
- "Authenticate with Firebase App Distribution using a Google account."
82
- end
83
-
84
- def self.details
85
- "Log in to Firebase App Distribution using a Google account to generate an authentication "\
86
- "token. This token is stored within an environment variable and used to authenticate with your Firebase project. "\
87
- "See https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane for more information."
88
- end
89
-
90
- def self.authors
91
- ["Manny Jimenez Github: mannyjimenez0810, Alonso Salas Infante Github: alonsosalasinfante"]
92
- end
93
-
94
- def self.is_supported?(platform)
95
- [:ios, :android].include?(platform)
96
- end
97
-
98
- def self.available_options
99
- [
100
- FastlaneCore::ConfigItem.new(key: :port,
101
- env_name: "FIREBASEAPPDISTRO_LOGIN_PORT",
102
- description: "Port for the local web server which receives the response from Google's authorization server",
103
- default_value: "8081",
104
- optional: true,
105
- type: String)
106
-
107
- ]
108
- end
109
-
110
- def self.category
111
- :deprecated
112
- end
113
-
114
- def self.deprecated_notes
115
- "The firebase_app_distribution_login task is deprecated and will be removed in Q1 2023. See "\
116
- "https://firebase.google.com/docs/app-distribution/android/distribute-gradle#authenticate "\
117
- "for more information on alternative ways to authenticate."
118
- end
119
- end
120
- end
121
- end