fastlane-plugin-huawei_appgallery_connect 1.0.11 → 1.0.16

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: b5551239cf32bab29acd6d2d70b1623731c4629f09f102a98d05f5b0e7ee2bca
4
- data.tar.gz: 83446bfb3a35d813abaa29a09af38185f136ae73c3f08d07f5620f80bedfc17b
3
+ metadata.gz: dfbde49f6453dab62630894c6b4d16a2710d588b0745d97b33840fbb8eaae8d8
4
+ data.tar.gz: 158bbe4a0770dfc2eb01a260144e3aecf72b14ba95f45e50789c3907a92bf8e0
5
5
  SHA512:
6
- metadata.gz: 839662a96b67bec48d6c35e29151db9ab9d91c759de901734eed761392ffc93f3c75f154ca9bf790b38a05bac2e991d4e7896d19babe5d4eec4192f115efd573
7
- data.tar.gz: 1912a210ee2fb2e53f5d5d5adeeae498f98d10e579d84cae441c6b75db8f98d2cea47bcc7893c6df0eb54bff074013589c547240dd8c2365724b9fe38473a825
6
+ metadata.gz: 21ac172a899067f8eac2eaf09268c7ff0e941da6886ab393a9f52f29860c6d03ec71cb997a6d84946410a87bcdf0bed5b2d53816e5aebd66767b0e961c465b44
7
+ data.tar.gz: d77abc579cd3551998c11c8c24a97053a079bcbf8cfc662e97883632da71d9e3be95ecb973dcdeb9461a41015bcac6bf4ba5b99dae4bb88a65847977c7a3aba2
data/README.md CHANGED
@@ -27,6 +27,9 @@ huawei_appgallery_connect(
27
27
 
28
28
  # Optional, Parameter beyond this are optional
29
29
 
30
+ # if you're uploading aab instead of apk, specify is_aab to true and specify path to aab file on apk_path
31
+ is_aab: true
32
+
30
33
  submit_for_review: false,
31
34
 
32
35
  privacy_policy_url: "https://example.com",
@@ -15,13 +15,28 @@ module Fastlane
15
15
  Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url])
16
16
  end
17
17
 
18
- upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path])
18
+ upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path], params[:is_aab])
19
+ self.submit_for_review(token, upload_app, params)
19
20
 
20
- if upload_app && params[:submit_for_review] != false
21
+ end
22
+ # Helper::HuaweiAppgalleryConnectHelper.getAppInfo(token, params[:client_id], params[:app_id])
23
+ end
24
+
25
+ def self.submit_for_review(token, upload_app, params)
26
+ if params[:is_aab] && upload_app["success"] == true && params[:submit_for_review] != false
27
+ compilationStatus = Helper::HuaweiAppgalleryConnectHelper.query_aab_compilation_status(token, params, upload_app["pkgVersion"])
28
+ if compilationStatus == 1
29
+ UI.important("aab file is currently processing, waiting for 2 minutes...")
30
+ sleep(10)
31
+ self.submit_for_review(token, upload_app, params)
32
+ elsif compilationStatus == 2
21
33
  Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
34
+ else
35
+ UI.user_error!("Compilation of aab failed")
22
36
  end
37
+ elsif upload_app["success"] == true && params[:submit_for_review] != false
38
+ Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
23
39
  end
24
- # Helper::HuaweiAppgalleryConnectHelper.getAppInfo(token, params[:client_id], params[:app_id])
25
40
  end
26
41
 
27
42
  def self.description
@@ -67,6 +82,12 @@ module Fastlane
67
82
  optional: false,
68
83
  type: String),
69
84
 
85
+ FastlaneCore::ConfigItem.new(key: :is_aab,
86
+ env_name: "HUAWEI_APPGALLERY_CONNECT_IS_AAB",
87
+ description: "Specify this to be true if you're uploading aab instead of apk",
88
+ optional: true,
89
+ type: Boolean),
90
+
70
91
  FastlaneCore::ConfigItem.new(key: :changelog_path,
71
92
  env_name: "HUAWEI_APPGALLERY_CONNECT_CHANGELOG_PATH",
72
93
  description: "Path to Changelog file (Default empty)",
@@ -41,8 +41,8 @@ module Fastlane
41
41
  UI.success("Successfully getting app info")
42
42
  return result_json['appInfo']
43
43
  else
44
- UI.user_error("Failed to get app info")
45
44
  UI.user_error!(result_json)
45
+ UI.user_error!("Failed to get app info")
46
46
  end
47
47
 
48
48
  end
@@ -57,6 +57,7 @@ module Fastlane
57
57
  request = Net::HTTP::Put.new(uri.request_uri)
58
58
  request["client_id"] = client_id
59
59
  request["Authorization"] = "Bearer #{token}"
60
+ request["Content-Type"] = "application/json"
60
61
 
61
62
  request.body = {privacyPolicy: privacy_policy_url}.to_json
62
63
 
@@ -70,35 +71,48 @@ module Fastlane
70
71
  if result_json['ret']['code'] == 0
71
72
  UI.success("Successfully updated app info")
72
73
  else
73
- UI.user_error("Failed to update app info")
74
74
  UI.user_error!(result_json)
75
+ UI.user_error!("Failed to update app info")
75
76
  end
76
77
  end
77
78
 
78
79
 
79
- def self.upload_app(token, client_id, app_id, apk_path)
80
+ def self.upload_app(token, client_id, app_id, apk_path, is_aab)
80
81
  UI.message("Fetching upload URL")
81
82
 
82
- uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=apk")
83
+ responseData = JSON.parse("{}")
84
+ responseData["success"] = false
85
+ responseData["code"] = 0
86
+
87
+ if(is_aab)
88
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=aab")
89
+ upload_filename = "release.aab"
90
+ else
91
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=apk")
92
+ upload_filename = "release.apk"
93
+ end
83
94
 
84
95
  http = Net::HTTP.new(uri.host, uri.port)
85
96
  http.use_ssl = true
86
97
  request = Net::HTTP::Get.new(uri.request_uri)
87
98
  request["client_id"] = client_id
88
99
  request["Authorization"] = "Bearer #{token}"
100
+ request["Content-Type"] = "application/json"
89
101
 
90
102
  response = http.request(request)
91
103
 
92
104
  if !response.kind_of? Net::HTTPSuccess
93
105
  UI.user_error!("Cannot obtain upload url, please check API Token / Permissions (status code: #{response.code})")
94
- return false
106
+ responseData["success"] = false
107
+ return responseData
95
108
  end
96
109
 
97
110
  result_json = JSON.parse(response.body)
98
111
 
99
112
  if result_json['uploadUrl'].nil?
100
113
  UI.user_error!('Cannot obtain upload url')
101
- return false
114
+ responseData["success"] = false
115
+ return responseData
102
116
  else
103
117
  UI.important('Uploading app')
104
118
  # Upload App
@@ -115,7 +129,8 @@ module Fastlane
115
129
  result = http.request(request)
116
130
  if !result.kind_of? Net::HTTPSuccess
117
131
  UI.user_error!("Cannot upload app, please check API Token / Permissions (status code: #{result.code})")
118
- return false
132
+ responseData["success"] = false
133
+ return responseData
119
134
  end
120
135
  result_json = JSON.parse(result.body)
121
136
 
@@ -130,10 +145,11 @@ module Fastlane
130
145
  request = Net::HTTP::Put.new(uri.request_uri)
131
146
  request["client_id"] = client_id
132
147
  request["Authorization"] = "Bearer #{token}"
148
+ request["Content-Type"] = "application/json"
133
149
 
134
150
  data = {fileType: 5, files: [{
135
151
 
136
- fileName: "release.apk",
152
+ fileName: upload_filename,
137
153
  fileDestUrl: result_json['result']['UploadFileRsp']['fileInfoList'][0]['fileDestUlr'],
138
154
  size: result_json['result']['UploadFileRsp']['fileInfoList'][0]['size'].to_s
139
155
 
@@ -143,24 +159,57 @@ module Fastlane
143
159
  response = http.request(request)
144
160
  if !response.kind_of? Net::HTTPSuccess
145
161
  UI.user_error!("Cannot save app info, please check API Token / Permissions (status code: #{response.code})")
146
- return false
162
+ responseData["success"] = false
163
+ return responseData
147
164
  end
148
165
  result_json = JSON.parse(response.body)
149
166
 
150
167
  if result_json['ret']['code'] == 0
151
168
  UI.success("App information saved.")
152
- return true
169
+ responseData["success"] = true
170
+ responseData["pkgVersion"] = result_json["pkgVersion"][0]
171
+ return responseData
153
172
  else
154
- UI.user_error("Failed to save app information")
155
173
  UI.user_error!(result_json)
156
- return false
174
+ UI.user_error!("Failed to save app information")
175
+ responseData["success"] = false
176
+ return responseData
157
177
  end
158
178
  else
159
- return false
179
+ responseData["success"] = false
180
+ return responseData
160
181
  end
161
182
  end
162
183
  end
163
184
 
185
+ def self.query_aab_compilation_status(token,params, pkgVersion)
186
+ UI.important("Checking aab compilation status")
187
+
188
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/aab/complile/status?appId=#{params[:app_id]}&pkgVersion=#{pkgVersion}")
189
+
190
+ http = Net::HTTP.new(uri.host, uri.port)
191
+ http.use_ssl = true
192
+ request = Net::HTTP::Get.new(uri.request_uri)
193
+ request["client_id"] = params[:client_id]
194
+ request["Authorization"] = "Bearer #{token}"
195
+
196
+ response = http.request(request)
197
+
198
+ if !response.kind_of? Net::HTTPSuccess
199
+ UI.user_error!("Cannot query compilation status (status code: #{response.code}, body: #{response.body})")
200
+ return false
201
+ end
202
+
203
+ result_json = JSON.parse(response.body)
204
+
205
+ if result_json['ret']['code'] == 0
206
+ return result_json['aabCompileStatus']
207
+ else
208
+ UI.user_error!(result_json)
209
+ return -999
210
+ end
211
+ end
212
+
164
213
  def self.submit_app_for_review(token, params)
165
214
  UI.important("Submitting app for review")
166
215
 
@@ -204,6 +253,7 @@ module Fastlane
204
253
  request = Net::HTTP::Post.new(uri.request_uri)
205
254
  request["client_id"] = params[:client_id]
206
255
  request["Authorization"] = "Bearer #{token}"
256
+ request["Content-Type"] = "application/json"
207
257
 
208
258
  if params[:phase_wise_release] != nil && params[:phase_wise_release]
209
259
  request.body = {
@@ -226,9 +276,14 @@ module Fastlane
226
276
 
227
277
  if result_json['ret']['code'] == 0
228
278
  UI.success("Successfully submitted app for review")
279
+ elsif result_json['ret']['code'] == 204144660 && result_json['ret']['msg'].include?("It may take 2-5 minutes")
280
+ UI.important(result_json)
281
+ UI.important("Build is currently processing, waiting for 2 minutes before submitting again...")
282
+ sleep(120)
283
+ self.submit_app_for_review(token, params)
229
284
  else
230
- UI.user_error("Failed to submit app for review.")
231
285
  UI.user_error!(result_json)
286
+ UI.user_error!("Failed to submit app for review.")
232
287
  end
233
288
 
234
289
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module HuaweiAppgalleryConnect
3
- VERSION = "1.0.11"
3
+ VERSION = "1.0.16"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-huawei_appgallery_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreejan Shrestha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-11 00:00:00.000000000 Z
11
+ date: 2021-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry