fastlane-plugin-firebase_app_distribution 0.2.0 → 0.2.3

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: 5c1f9a3bb79927dc10b2ed68e66ad0c8b9593ef5a31a6cc50d91ed635eb6443a
4
- data.tar.gz: bfadb919bccb7bb7b1b7d943cd92b0709f3f8d432e8508efc2ac56bb8969c809
3
+ metadata.gz: ed04551803fc7a5edd8e0d43b48ff6e84e55565f3219422619e78ef96f2e6654
4
+ data.tar.gz: bd070b167f9fa4f72e13f3250524af46b75861ee9096e2a73b8e5441c5889fa8
5
5
  SHA512:
6
- metadata.gz: 55f7b6245940db7d3141ac707d52646d5dc369d7a9d4a2add36e1e5efe11365e0ef3aaa13cbab59cb51f8696320d186570bd5c3e38f5856fc8a801246b3f93da
7
- data.tar.gz: dc02fa663afe0cfeba8b71f2de2bc91feed18cf2ca3b0134567d80729d529c9dab9573831e0c23100e96f00c2447b1af95dc688860b514ea6080fd3e303ed438
6
+ metadata.gz: 123bec0fbac40f216c10a4e05aab1e43644286972f2ab436ed91686a1e5404779b3d9f7dbd8ecfe208264f702f51982cfea60d3607e1090795941d2d0b65e23c
7
+ data.tar.gz: d4f509e5a09b916486f0d10802c2ff53fc1efb803e476f27f71bfade12ee5b6a46b0aa0992099582531c93de423712ccaf6a8b1276f22145701eef4158cbd95b
@@ -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
+
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
+
23
28
  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
29
  fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, platform)
27
30
 
28
- if params[:app] # Set app_id if it is specified as a parameter
29
- app_id = params[:app]
30
- elsif platform == :ios
31
- archive_path = Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
32
- if archive_path
33
- app_id = get_ios_app_id_from_archive(archive_path)
34
- end
35
- end
36
-
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.platform_from_path(binary_path)
74
- return nil unless binary_path
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
- when 'apk'
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",
@@ -40,6 +40,7 @@ module Fastlane
40
40
  begin
41
41
  connection.post(enable_access_url(app_id, release_id), payload.to_json) do |request|
42
42
  request.headers["Authorization"] = "Bearer " + @auth_token
43
+ request.headers["Content-Type"] = "application/json"
43
44
  end
44
45
  rescue Faraday::ResourceNotFound
45
46
  UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
@@ -67,6 +68,7 @@ module Fastlane
67
68
  begin
68
69
  connection.post(release_notes_create_url(app_id, release_id), payload.to_json) do |request|
69
70
  request.headers["Authorization"] = "Bearer " + @auth_token
71
+ request.headers["Content-Type"] = "application/json"
70
72
  end
71
73
  rescue Faraday::ResourceNotFound
72
74
  UI.user_error!("#{ErrorMessage::INVALID_APP_ID}: #{app_id}")
@@ -89,7 +91,7 @@ module Fastlane
89
91
  if binary_path.nil? || !File.exist?(binary_path)
90
92
  UI.crash!("#{ErrorMessage.binary_not_found(@binary_type)}: #{binary_path}")
91
93
  end
92
- binary_hash = Digest::SHA256.hexdigest(File.open(binary_path).read)
94
+ binary_hash = Digest::SHA256.hexdigest(read_binary(binary_path))
93
95
 
94
96
  begin
95
97
  response = connection.get(v1_apps_url(app_id)) do |request|
@@ -114,7 +116,7 @@ module Fastlane
114
116
  #
115
117
  # Throws a user_error if an invalid app id is passed in, or if the binary file does not exist
116
118
  def upload_binary(app_id, binary_path, platform)
117
- connection.post(binary_upload_url(app_id), File.open(binary_path).read) do |request|
119
+ connection.post(binary_upload_url(app_id), read_binary(binary_path)) do |request|
118
120
  request.headers["Authorization"] = "Bearer " + @auth_token
119
121
  request.headers["X-APP-DISTRO-API-CLIENT-ID"] = "fastlane"
120
122
  request.headers["X-APP-DISTRO-API-CLIENT-TYPE"] = platform
@@ -223,6 +225,11 @@ module Fastlane
223
225
  conn.adapter(Faraday.default_adapter)
224
226
  end
225
227
  end
228
+
229
+ def read_binary(path)
230
+ # File must be read in binary mode to work on Windows
231
+ File.open(path, 'rb').read
232
+ end
226
233
  end
227
234
  end
228
235
  end
@@ -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.0"
3
+ VERSION = "0.2.3"
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.2.0
4
+ version: 0.2.3
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: 2020-09-02 00:00:00.000000000 Z
13
+ date: 2020-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry