fastlane-plugin-huawei_appgallery_connect 1.0.27 → 1.0.29

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: 3572c301afd996aadeccb467e91daaa3b8514d7dd6837b9ee6d13d335da35773
4
- data.tar.gz: 9cba86c4dee9506d332c246bee527b27357ad7b4369c385255ed4bcf27093273
3
+ metadata.gz: 173402f664ca90b6a05b0f8d61e4b844ab8ff929f420bf45ae889832153e354d
4
+ data.tar.gz: 44c91af71dc9152b9a35126a6702e220c7c91227d981cf5babdde6af32120d72
5
5
  SHA512:
6
- metadata.gz: b3e891f32a127c782092c5011b060b9184c022702af2ff90b7e968824ddaa9d30d25fab56cea0aae4a1f9bac9f6f51063565cb91d8cb795e60df2f394f6e7789
7
- data.tar.gz: 03fed4623c6d833b221228e56513368b58a1846688ba56f69e78ab4f0ba7e778779784e102af47f2fd4ca01c6e746fbd6d96ae15f3570311e78fac3de2675e6d
6
+ metadata.gz: 798db4979efd1a8e42920a73463b931947d7e5bc20cbccceead219bdf5112250ccd53bf62d16c962b82c1fcdd96559bad6b63480751b1dde265fcc34b7b4770c
7
+ data.tar.gz: 76f08835134cf11d4abd1eac939608fd03f79536a35577c3518dabfab6c35fd821f2ea7bc5cdbb5a4e1592b2a227c96cc6f685ec30ff120ca1009a20a25668bc
data/README.md CHANGED
@@ -102,6 +102,17 @@ huawei_appgallery_connect_update_app_localization(
102
102
  )
103
103
  ```
104
104
 
105
+ To update the GMS dependency of the app, use the following action
106
+
107
+ ```
108
+ huawei_appgallery_connect_set_gms_dependency(
109
+ client_id: "<CLIENT_ID>",
110
+ client_secret: "<CLIENT_SECRET>",
111
+ app_id: "<APP_ID>",
112
+ gms_dependency: 1 #Indicates whether an app depends on GMS. 1: Yes, 0: No
113
+ )
114
+ ```
115
+
105
116
  Your folder structure for applying multiple languages for the metadata should look like this:
106
117
 
107
118
  ```
@@ -0,0 +1,75 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/huawei_appgallery_connect_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class HuaweiAppgalleryConnectSetGmsDependencyAction < Action
7
+
8
+ def self.run(params)
9
+ token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
10
+
11
+ if token.nil?
12
+ UI.message("Cannot retrieve token, please check your client ID and client secret")
13
+ else
14
+ Helper::HuaweiAppgalleryConnectHelper.set_gms_dependency(token,
15
+ params[:client_id],
16
+ params[:app_id],
17
+ params[:gms_dependency]
18
+ )
19
+ end
20
+ end
21
+
22
+ def self.description
23
+ "Huawei AppGallery Connect Plugin"
24
+ end
25
+
26
+ def self.authors
27
+ ["Shreejan Shrestha"]
28
+ end
29
+
30
+ def self.return_value
31
+ # If your method provides a return value, you can describe here what it does
32
+ end
33
+
34
+ def self.details
35
+ # Optional:
36
+ "Set GMS Dependency"
37
+ end
38
+
39
+ def self.available_options
40
+ [
41
+ FastlaneCore::ConfigItem.new(key: :client_id,
42
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_ID",
43
+ description: "Huawei AppGallery Connect Client ID",
44
+ optional: false,
45
+ type: String),
46
+
47
+ FastlaneCore::ConfigItem.new(key: :client_secret,
48
+ env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET",
49
+ description: "Huawei AppGallery Connect Client Secret",
50
+ optional: false,
51
+ type: String),
52
+
53
+ FastlaneCore::ConfigItem.new(key: :app_id,
54
+ env_name: "HUAWEI_APPGALLERY_CONNECT_APP_ID",
55
+ description: "Huawei AppGallery Connect App ID",
56
+ optional: false,
57
+ type: String),
58
+
59
+ FastlaneCore::ConfigItem.new(key: :gms_dependency,
60
+ env_name: "HUAWEI_APPGALLERY_CONNECT_GMS_DEPENDENCY",
61
+ description: "GMS Dependency of the app. (0 for no, 1 for yes)",
62
+ optional: false,
63
+ type: Integer),
64
+
65
+ ]
66
+ end
67
+
68
+ def self.is_supported?(platform)
69
+ [:android].include?(platform)
70
+ true
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -112,11 +112,14 @@ module Fastlane
112
112
  responseData["success"] = false
113
113
  responseData["code"] = 0
114
114
 
115
+ file_size_in_bytes = File.size(apk_path.to_s)
116
+ sha256 = Digest::SHA256.file(apk_path).hexdigest
117
+
115
118
  if(is_aab)
116
- uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=aab")
119
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url/for-obs?appId=#{app_id}&fileName=release.aab&contentLength=#{file_size_in_bytes}&suffix=aab")
117
120
  upload_filename = "release.aab"
118
121
  else
119
- uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=apk")
122
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url/for-obs?appId=#{app_id}&fileName=release.apk&contentLength=#{file_size_in_bytes}&suffix=apk")
120
123
  upload_filename = "release.apk"
121
124
  end
122
125
 
@@ -137,32 +140,40 @@ module Fastlane
137
140
 
138
141
  result_json = JSON.parse(response.body)
139
142
 
140
- if result_json['uploadUrl'].nil?
141
- UI.user_error!('Cannot obtain upload url')
143
+ if result_json['urlInfo']['url'].nil?
144
+ UI.message('Cannot obtain upload url')
145
+ UI.user_error!(response.body)
146
+
142
147
  responseData["success"] = false
143
148
  return responseData
144
149
  else
145
150
  UI.important('Uploading app')
146
151
  # Upload App
147
152
  boundary = "755754302457647"
148
- uri = URI(result_json['uploadUrl'])
153
+ uri = URI(result_json['urlInfo']['url'])
149
154
  # uri = URI("http://localhost/dashboard/test")
150
155
  http = Net::HTTP.new(uri.host, uri.port)
151
156
  http.use_ssl = true
152
- request = Net::HTTP::Post.new(uri)
157
+ request = Net::HTTP::Put.new(uri)
158
+ request["Authorization"] = result_json['urlInfo']['headers']['Authorization']
159
+ request["Content-Type"] = result_json['urlInfo']['headers']['Content-Type']
160
+ request["user-agent"] = result_json['urlInfo']['headers']['user-agent']
161
+ request["Host"] = result_json['urlInfo']['headers']['Host']
162
+ request["x-amz-date"] = result_json['urlInfo']['headers']['x-amz-date']
163
+ request["x-amz-content-sha256"] = result_json['urlInfo']['headers']['x-amz-content-sha256']
153
164
 
154
- form_data = [['file', File.open(apk_path.to_s)],['authCode', result_json['authCode']],['fileCount', '1']]
155
- request.set_form form_data, 'multipart/form-data'
165
+ request.body = File.read(apk_path.to_s)
166
+ request.content_type = 'application/octet-stream'
156
167
 
157
168
  result = http.request(request)
158
169
  if !result.kind_of? Net::HTTPSuccess
170
+ UI.user_error!(result.body)
159
171
  UI.user_error!("Cannot upload app, please check API Token / Permissions (status code: #{result.code})")
160
172
  responseData["success"] = false
161
173
  return responseData
162
174
  end
163
- result_json = JSON.parse(result.body)
164
175
 
165
- if result_json['result']['result_code'].to_i == 0
176
+ if result.code.to_i == 200
166
177
  UI.success('Upload app to AppGallery Connect successful')
167
178
  UI.important("Saving app information")
168
179
 
@@ -178,8 +189,8 @@ module Fastlane
178
189
  data = {fileType: 5, files: [{
179
190
 
180
191
  fileName: upload_filename,
181
- fileDestUrl: result_json['result']['UploadFileRsp']['fileInfoList'][0]['fileDestUlr'],
182
- size: result_json['result']['UploadFileRsp']['fileInfoList'][0]['size'].to_s
192
+ fileDestUrl: result_json['urlInfo']['objectId']
193
+ # size: result_json['result']['UploadFileRsp']['fileInfoList'][0]['size'].to_s
183
194
 
184
195
  }] }.to_json
185
196
 
@@ -369,6 +380,36 @@ module Fastlane
369
380
  end
370
381
  end
371
382
  end
383
+
384
+ def self.set_gms_dependency(token, client_id, app_id, gms_dependency)
385
+ UI.message("Setting GMS Dependency")
386
+
387
+ uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/properties/gms?appId=#{app_id}")
388
+
389
+ http = Net::HTTP.new(uri.host, uri.port)
390
+ http.use_ssl = true
391
+ request = Net::HTTP::Put.new(uri.request_uri)
392
+ request["client_id"] = client_id
393
+ request["Authorization"] = "Bearer #{token}"
394
+ request["Content-Type"] = "application/json"
395
+
396
+ request.body = {needGms: gms_dependency}.to_json
397
+
398
+ response = http.request(request)
399
+ if !response.kind_of? Net::HTTPSuccess
400
+ UI.user_error!("Cannot update gms dependency, please check API Token / Permissions (status code: #{response.code})")
401
+ return false
402
+ end
403
+ result_json = JSON.parse(response.body)
404
+
405
+ if result_json['ret']['code'] == 0
406
+ UI.success("Successfully updated GMS Dependency")
407
+ else
408
+ UI.user_error!(result_json)
409
+ UI.user_error!("Failed to update GMS Dependency")
410
+ end
411
+ end
412
+
372
413
  end
373
414
  end
374
415
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module HuaweiAppgalleryConnect
3
- VERSION = "1.0.27"
3
+ VERSION = "1.0.29"
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.27
4
+ version: 1.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreejan Shrestha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -162,6 +162,7 @@ files:
162
162
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb
163
163
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_id.rb
164
164
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_info.rb
165
+ - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_set_gms_dependency.rb
165
166
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_submit_for_review.rb
166
167
  - lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_update_app_localization.rb
167
168
  - lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb