fastlane-plugin-huawei_appgallery_connect 1.1.2 → 1.1.3
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 +4 -4
- data/README.md +21 -0
- data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb +1 -1
- data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_submit_for_review.rb +1 -1
- data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb +42 -0
- data/lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb +50 -2
- data/lib/fastlane/plugin/huawei_appgallery_connect/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97874354ecb4121c45889f9136a236271f77da2de5859f4820595021b6f4cfd4
|
|
4
|
+
data.tar.gz: 11610e645fcd786b9ac726866238c28b281924ebdd4198913324112ed9889f49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 492c3bc90466a858e66da51ecc8ca8b07dcb8baa7bff208c5ec29a6e866622f261ee3c3cd36a91ae7f5c47cc2a4ad701acea7e8a7da55c2b0dc6afc79ee120c1
|
|
7
|
+
data.tar.gz: 5d2144b57b1e3ff0c5c3cb008c5a39022afaf42ad06c6a02ea7d322410ae86a2157a544a587dd4e6245e37ee03fbae74308c625be95a9ae24628509a53d5fb5f
|
data/README.md
CHANGED
|
@@ -12,6 +12,27 @@ fastlane add_plugin huawei_appgallery_connect
|
|
|
12
12
|
|
|
13
13
|
## About huawei_appgallery_connect
|
|
14
14
|
|
|
15
|
+
### Uploading icons and screenshots
|
|
16
|
+
|
|
17
|
+
Visual assets can be uploaded independently of an app package with the
|
|
18
|
+
`huawei_appgallery_connect_upload_assets` action. Pass one or more files (or
|
|
19
|
+
directories) and the language used by the asset metadata:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
huawei_appgallery_connect_upload_assets(
|
|
23
|
+
client_id: ENV['HUAWEI_CLIENT_ID'],
|
|
24
|
+
client_secret: ENV['HUAWEI_CLIENT_SECRET'],
|
|
25
|
+
app_id: ENV['HUAWEI_APP_ID'],
|
|
26
|
+
asset_paths: ['fastlane/assets/icon.png', 'fastlane/assets/screenshots'],
|
|
27
|
+
lang: 'en-US'
|
|
28
|
+
)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The action uses Huawei's Publishing API OBS upload flow and supports the
|
|
32
|
+
formats accepted by Huawei (PNG/JPG screenshots and icons, plus video/PDF
|
|
33
|
+
assets). `file_type` can be supplied when Huawei assigns a different file
|
|
34
|
+
type for an asset in your account.
|
|
35
|
+
|
|
15
36
|
Huawei AppGallery Connect Plugin can be used to upload Android application on the Huawei App Gallery using fastlane.
|
|
16
37
|
|
|
17
38
|
## Usage
|
data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb
CHANGED
|
@@ -100,7 +100,7 @@ module Fastlane
|
|
|
100
100
|
|
|
101
101
|
FastlaneCore::ConfigItem.new(key: :changelog_path,
|
|
102
102
|
env_name: "HUAWEI_APPGALLERY_CONNECT_CHANGELOG_PATH",
|
|
103
|
-
description: "Path to
|
|
103
|
+
description: "Path to changelog file (10-300 characters, default empty)",
|
|
104
104
|
optional: true,
|
|
105
105
|
type: String),
|
|
106
106
|
|
|
@@ -92,7 +92,7 @@ module Fastlane
|
|
|
92
92
|
|
|
93
93
|
FastlaneCore::ConfigItem.new(key: :changelog_path,
|
|
94
94
|
env_name: "HUAWEI_APPGALLERY_CONNECT_CHANGELOG_PATH",
|
|
95
|
-
description: "Path to
|
|
95
|
+
description: "Path to changelog file (10-300 characters, default empty)",
|
|
96
96
|
optional: true,
|
|
97
97
|
type: String),
|
|
98
98
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'fastlane/action'
|
|
2
|
+
require_relative '../helper/huawei_appgallery_connect_helper'
|
|
3
|
+
|
|
4
|
+
module Fastlane
|
|
5
|
+
module Actions
|
|
6
|
+
class HuaweiAppgalleryConnectUploadAssetsAction < Action
|
|
7
|
+
def self.run(params)
|
|
8
|
+
token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
|
|
9
|
+
UI.user_error!('Cannot retrieve Huawei AppGallery Connect token') if token.nil?
|
|
10
|
+
|
|
11
|
+
paths = Array(params[:asset_paths]).flat_map { |path| File.directory?(path) ? Dir[File.join(path, '*')] : path }
|
|
12
|
+
UI.user_error!('Provide at least one asset path') if paths.empty?
|
|
13
|
+
paths.each do |path|
|
|
14
|
+
Helper::HuaweiAppgalleryConnectHelper.upload_asset(
|
|
15
|
+
token, params[:client_id], params[:app_id], path,
|
|
16
|
+
file_type: params[:file_type], lang: params[:lang]
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
UI.success("Uploaded #{paths.length} AppGallery asset(s)")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.description
|
|
23
|
+
'Upload app icons, screenshots, and other visual assets to Huawei AppGallery Connect'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.available_options
|
|
27
|
+
[
|
|
28
|
+
FastlaneCore::ConfigItem.new(key: :client_id, env_name: 'HUAWEI_APPGALLERY_CONNECT_CLIENT_ID', description: 'Huawei AppGallery Connect Client ID', optional: false, type: String),
|
|
29
|
+
FastlaneCore::ConfigItem.new(key: :client_secret, env_name: 'HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET', description: 'Huawei AppGallery Connect Client Secret', optional: false, type: String),
|
|
30
|
+
FastlaneCore::ConfigItem.new(key: :app_id, env_name: 'HUAWEI_APPGALLERY_CONNECT_APP_ID', description: 'Huawei AppGallery Connect App ID', optional: false, type: String),
|
|
31
|
+
FastlaneCore::ConfigItem.new(key: :asset_paths, env_name: 'HUAWEI_APPGALLERY_ASSET_PATHS', description: 'Asset file paths or directories', optional: false, type: Array),
|
|
32
|
+
FastlaneCore::ConfigItem.new(key: :file_type, env_name: 'HUAWEI_APPGALLERY_ASSET_FILE_TYPE', description: 'Huawei Publishing API fileType (default: 5)', optional: true, default_value: 5, type: Integer),
|
|
33
|
+
FastlaneCore::ConfigItem.new(key: :lang, env_name: 'HUAWEI_APPGALLERY_ASSET_LANGUAGE', description: 'Language tag for localized assets, for example en-US', optional: true, type: String)
|
|
34
|
+
]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.is_supported?(platform)
|
|
38
|
+
platform == :android
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
|
2
2
|
require 'cgi'
|
|
3
3
|
require 'time'
|
|
4
|
+
require 'digest'
|
|
4
5
|
|
|
5
6
|
module Fastlane
|
|
6
7
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
|
@@ -222,6 +223,53 @@ module Fastlane
|
|
|
222
223
|
end
|
|
223
224
|
end
|
|
224
225
|
|
|
226
|
+
# Uploads a visual asset (icon, screenshot, video, or PDF) to AGC.
|
|
227
|
+
# Huawei uses the same OBS upload flow for all supported file formats;
|
|
228
|
+
# callers provide the fileType used by their Publishing API account.
|
|
229
|
+
def self.upload_asset(token, client_id, app_id, asset_path, file_type: 5, lang: nil)
|
|
230
|
+
UI.message("Uploading AppGallery asset #{File.basename(asset_path)}")
|
|
231
|
+
UI.user_error!("Asset does not exist: #{asset_path}") unless File.file?(asset_path)
|
|
232
|
+
|
|
233
|
+
filename = File.basename(asset_path)
|
|
234
|
+
suffix = File.extname(filename).delete('.').downcase
|
|
235
|
+
size = File.size(asset_path)
|
|
236
|
+
query = URI.encode_www_form(appId: app_id, fileName: filename,
|
|
237
|
+
contentLength: size, suffix: suffix)
|
|
238
|
+
uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url/for-obs?#{query}")
|
|
239
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
240
|
+
http.use_ssl = true
|
|
241
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
242
|
+
request['client_id'] = client_id
|
|
243
|
+
request['Authorization'] = "Bearer #{token}"
|
|
244
|
+
response = http.request(request)
|
|
245
|
+
UI.user_error!("Cannot obtain asset upload URL (status code: #{response.code})") unless response.is_a?(Net::HTTPSuccess)
|
|
246
|
+
|
|
247
|
+
upload_info = JSON.parse(response.body).fetch('urlInfo')
|
|
248
|
+
upload_uri = URI.parse(upload_info.fetch('url'))
|
|
249
|
+
upload_http = Net::HTTP.new(upload_uri.host, upload_uri.port)
|
|
250
|
+
upload_http.use_ssl = true
|
|
251
|
+
upload_request = Net::HTTP::Put.new(upload_uri)
|
|
252
|
+
upload_info.fetch('headers').each { |key, value| upload_request[key] = value }
|
|
253
|
+
upload_request.body = File.binread(asset_path)
|
|
254
|
+
upload_response = upload_http.request(upload_request)
|
|
255
|
+
UI.user_error!("Cannot upload asset (status code: #{upload_response.code})") unless upload_response.is_a?(Net::HTTPSuccess)
|
|
256
|
+
|
|
257
|
+
info_uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/app-file-info?appId=#{CGI.escape(app_id.to_s)}")
|
|
258
|
+
info_http = Net::HTTP.new(info_uri.host, info_uri.port)
|
|
259
|
+
info_http.use_ssl = true
|
|
260
|
+
info_request = Net::HTTP::Put.new(info_uri.request_uri)
|
|
261
|
+
info_request['client_id'] = client_id
|
|
262
|
+
info_request['Authorization'] = "Bearer #{token}"
|
|
263
|
+
info_request['Content-Type'] = 'application/json'
|
|
264
|
+
file = { fileName: filename, fileDestUrl: upload_info.fetch('objectId'), size: size }
|
|
265
|
+
payload = { fileType: file_type, files: [file] }
|
|
266
|
+
payload[:lang] = lang if lang
|
|
267
|
+
info_request.body = payload.to_json
|
|
268
|
+
info_response = info_http.request(info_request)
|
|
269
|
+
UI.user_error!("Cannot save asset information (status code: #{info_response.code})") unless info_response.is_a?(Net::HTTPSuccess)
|
|
270
|
+
JSON.parse(info_response.body)
|
|
271
|
+
end
|
|
272
|
+
|
|
225
273
|
def self.query_aab_compilation_status(token,params, pkgVersion)
|
|
226
274
|
UI.important("Checking aab compilation status")
|
|
227
275
|
uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/aab/complile/status?appId=#{params[:app_id]}&pkgIds=#{pkgVersion}")
|
|
@@ -283,8 +331,8 @@ module Fastlane
|
|
|
283
331
|
if params[:changelog_path] != nil
|
|
284
332
|
changelog_data = File.read(params[:changelog_path])
|
|
285
333
|
|
|
286
|
-
if changelog_data.length <
|
|
287
|
-
UI.user_error!("Failed to submit app for review. Changelog
|
|
334
|
+
if changelog_data.length < 10 || changelog_data.length > 300
|
|
335
|
+
UI.user_error!("Failed to submit app for review. Changelog must be between 10 and 300 characters (got #{changelog_data.length})")
|
|
288
336
|
return
|
|
289
337
|
else
|
|
290
338
|
changelog = "&remark=" + CGI.escape(changelog_data)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastlane-plugin-huawei_appgallery_connect
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shreejan Shrestha
|
|
@@ -165,6 +165,7 @@ files:
|
|
|
165
165
|
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_set_gms_dependency.rb
|
|
166
166
|
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_submit_for_review.rb
|
|
167
167
|
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_update_app_localization.rb
|
|
168
|
+
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_upload_assets_action.rb
|
|
168
169
|
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_withdraw_review.rb
|
|
169
170
|
- lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
|
|
170
171
|
- lib/fastlane/plugin/huawei_appgallery_connect/version.rb
|