fastlane-plugin-huawei_appgallery 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 814eeb8cd0cb8757080358a1015311e60b495356acec1e42c7f89a0f19fa03c1
4
+ data.tar.gz: e4228b3f43c4fbcd648428b79fdd0b7ba776a2411474e37c36ebc9ad236e849f
5
+ SHA512:
6
+ metadata.gz: c9649220e125e2b92562640e9c79dc7ec3596052fc18c11f9fd5f8e2134d57996e92dc811c6f59817771a4edaa4c7d787de9676e9f6da942c10769fe6a5bcb1d
7
+ data.tar.gz: 870cccb67d99ec822447dbe7a6ef1c2a8d27b15c1e6ab850c5908b98edcbb4ecc8fc07babfac8042a0483c73eb6452b1133e1d3d4e730e5110c0d4423ce9214a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Arne Kaiser <onkelarne@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # huawei_appgallery plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-huawei_appgallery)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-huawei_appgallery`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin huawei_appgallery
11
+ ```
12
+
13
+ ## About huawei_appgallery
14
+
15
+ Plugin to deploy an app to the Huawei AppGallery. Updates the release notes, uploads an APK and submits the new version for review.
16
+
17
+ **Note:** To authenticate, you need to create the signature by your own.
18
+ Example code: https://developer.huawei.com/consumer/en/service/hms/catalog/publishingAPI.html?page=hmssdk_appGalleryConnect_devguide (Authentication by secret key)
19
+
20
+ Pull requests are welcome. ;)
21
+
22
+ ## Example
23
+
24
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin.
25
+
26
+ ## Issues and Feedback
27
+
28
+ For any other issues and feedback about this plugin, please submit it to this repository.
29
+
30
+ ## Troubleshooting
31
+
32
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
33
+
34
+ ## Using _fastlane_ Plugins
35
+
36
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
37
+
38
+ ## About _fastlane_
39
+
40
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/huawei_appgallery/version'
2
+
3
+ module Fastlane
4
+ module HuaweiAppgallery
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::HuaweiAppgallery.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,71 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/huawei_appgallery_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class HuaweiAppgalleryAction < Action
7
+ def self.run(params)
8
+ cookie = Helper::HuaweiAppgalleryHelper.request_cookie(params[:client_id], params[:time], params[:signature])
9
+ Helper::HuaweiAppgalleryHelper.update_release_notes(cookie, params[:app_id], params[:release_notes])
10
+ Helper::HuaweiAppgalleryHelper.upload_apk(cookie, params[:app_id], params[:apk_path])
11
+ Helper::HuaweiAppgalleryHelper.submit_app(cookie, params[:app_id])
12
+ UI.message('Finished!')
13
+ end
14
+
15
+ def self.description
16
+ "Plugin to deploy an app to the Huawei AppGallery"
17
+ end
18
+
19
+ def self.authors
20
+ ["Arne Kaiser"]
21
+ end
22
+
23
+ def self.return_value
24
+ # no return value
25
+ end
26
+
27
+ def self.details
28
+ "Updates the release notes, uploads an APK and submits the new version for review."
29
+ end
30
+
31
+ def self.available_options
32
+ [
33
+ FastlaneCore::ConfigItem.new(key: :client_id,
34
+ env_name: "HUAWEI_APPGALLERY_CLIENT_ID",
35
+ description: "Client ID of an AppGallery Connect API client",
36
+ optional: false,
37
+ type: String),
38
+ FastlaneCore::ConfigItem.new(key: :time,
39
+ env_name: "HUAWEI_APPGALLERY_TIME",
40
+ description: "Time in milliseconds since 1970, which was used to create the signature",
41
+ optional: false,
42
+ type: String),
43
+ FastlaneCore::ConfigItem.new(key: :signature,
44
+ env_name: "HUAWEI_APPGALLERY_SIGNATURE",
45
+ description: "Signature which needs to be created by your own. Example code: https://developer.huawei.com/consumer/en/service/hms/catalog/publishingAPI.html?page=hmssdk_appGalleryConnect_devguide",
46
+ optional: false,
47
+ type: String),
48
+ FastlaneCore::ConfigItem.new(key: :app_id,
49
+ env_name: "HUAWEI_APPGALLERY_APP_ID",
50
+ description: "Application ID of your app",
51
+ optional: false,
52
+ type: String),
53
+ FastlaneCore::ConfigItem.new(key: :apk_path,
54
+ env_name: "HUAWEI_APPGALLERY_APK_PATH",
55
+ description: "Path to your APK file",
56
+ optional: false,
57
+ type: String),
58
+ FastlaneCore::ConfigItem.new(key: :release_notes,
59
+ env_name: "HUAWEI_APPGALLERY_RELEASE_NOTES",
60
+ description: "Dictionary with language codes as the keys and the release notes as the values",
61
+ optional: false,
62
+ type: Hash)
63
+ ]
64
+ end
65
+
66
+ def self.is_supported?(platform)
67
+ [:android].include?(platform)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,158 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class HuaweiAppgalleryHelper
8
+ def self.request_cookie(client_id, time, signature)
9
+ UI.message("Requesting cookie from Huawei AppGallery ...")
10
+ content = { 'key_string' => { 'clientId' => client_id, 'time' => time, 'sign' => signature } }
11
+ result = Net::HTTP.post(
12
+ URI('https://connect-api.cloud.huawei.com/api/common/v1/connect'),
13
+ content.to_json.encode('utf-8'),
14
+ "Accept" => "application/json"
15
+ )
16
+ cookie = result['set-cookie']
17
+ if cookie.nil?
18
+ UI.user_error!("Authentication failed: #{result.body}")
19
+ end
20
+ cookie.split('; ')[0]
21
+ end
22
+
23
+ def self.update_release_notes(cookie, app_id, release_notes)
24
+ release_notes.each do |lang, notes|
25
+ UI.message("Updating release notes for language #{lang} ...")
26
+
27
+ uri = URI("https://connect-api.cloud.huawei.com/api/publish/v1/appInfo/#{app_id}?lang=#{lang}")
28
+ http = Net::HTTP.new(uri.host, uri.port)
29
+ http.use_ssl = true
30
+ request = Net::HTTP::Get.new(uri)
31
+ request['Cookie'] = cookie
32
+ request['Accept'] = 'application/json'
33
+
34
+ result = http.request(request)
35
+
36
+ if result.code.to_i != 200
37
+ UI.user_error!("Cannot retrieve language information for language #{lang}!")
38
+ end
39
+
40
+ # get values for mandatory parameters
41
+ result_json = JSON.parse(result.body)
42
+ app_name = result_json['languages'][0]['appName']
43
+ app_desc = result_json['languages'][0]['appDesc']
44
+ brief_info = result_json['languages'][0]['briefInfo']
45
+
46
+ if app_name.nil? || app_desc.nil? || brief_info.nil?
47
+ UI.user_error!("Cannot retrieve language information for language #{lang}!")
48
+ end
49
+
50
+ # set new release notes
51
+ content = {
52
+ 'appName' => app_name,
53
+ 'appDesc' => app_desc,
54
+ 'briefInfo' => brief_info,
55
+ 'newFeatures' => notes
56
+ }
57
+
58
+ uri = URI("https://connect-api.cloud.huawei.com/api/publish/v1/languageInfo/#{app_id}/#{lang}")
59
+ http = Net::HTTP.new(uri.host, uri.port)
60
+ http.use_ssl = true
61
+ request = Net::HTTP::Put.new(uri)
62
+ request.body = content.to_json.encode('utf-8')
63
+ request['Cookie'] = cookie
64
+ request['Content-Type'] = 'application/json'
65
+ result = http.request(request)
66
+ if result.code.to_i != 200
67
+ UI.user_error!("Cannot update language information for language #{lang}!")
68
+ end
69
+ end
70
+ end
71
+
72
+ def self.upload_apk(cookie, app_id, apk_path)
73
+ unless File.file?(apk_path)
74
+ UI.user_error!("Cannot read apk at: #{apk_path}")
75
+ end
76
+
77
+ # obtain upload url
78
+ UI.message("Obtaining upload url ...")
79
+ uri = URI("https://connect-api.cloud.huawei.com/api/publish/v1/uploadUrl?suffix=apk")
80
+ http = Net::HTTP.new(uri.host, uri.port)
81
+ http.use_ssl = true
82
+ request = Net::HTTP::Get.new(uri)
83
+ request['Cookie'] = cookie
84
+ request['Accept'] = 'application/json'
85
+ result = http.request(request)
86
+ result_json = JSON.parse(result.body)
87
+ upload_url = result_json['uploadUrl'] # this is the upload server
88
+ auth_code = result_json['authCode']
89
+ if result.code.to_i != 200 || upload_url.nil? || auth_code.nil?
90
+ UI.user_error!("Cannot obtain upload url!")
91
+ end
92
+
93
+ # upload apk
94
+ UI.message("Uploading apk to #{upload_url} ...")
95
+ boundary = "755754302457647"
96
+ uri = URI("https://#{upload_url}/api/publish/v1/uploadFile")
97
+ http = Net::HTTP.new(uri.host, uri.port)
98
+ http.use_ssl = true
99
+ request = Net::HTTP::Post.new(uri)
100
+ request['Cookie'] = cookie
101
+ request['Accept'] = 'application/json'
102
+ request['Content-Type'] = "multipart/form-data, boundary=#{boundary}"
103
+
104
+ post_body = []
105
+ # add the auth code
106
+ post_body << "--#{boundary}\r\n"
107
+ post_body << "Content-Disposition: form-data; name=\"authCode\"\r\n\r\n"
108
+ post_body << auth_code
109
+ # add the apk
110
+ post_body << "\r\n--#{boundary}\r\n"
111
+ post_body << "Content-Disposition: form-data; name=\"file\"; filename=\"release.apk\"\r\n"
112
+ post_body << "Content-Type: multipart/form-data\r\n\r\n"
113
+ post_body << File.read(apk_path).encode('utf-8')
114
+ post_body << "\r\n--#{boundary}--\r\n"
115
+ request.body = post_body.join
116
+
117
+ result = http.request(request)
118
+ result_json = JSON.parse(result.body)
119
+ upload_url = result_json['uploadUrl']
120
+
121
+ # update app file informnation
122
+ UI.message("Updating app file information ...")
123
+ content = {
124
+ 'type' => 5, # type 5 = RPK or APK
125
+ 'data' => upload_url
126
+ }
127
+ uri = URI("https://connect-api.cloud.huawei.com/api/publish/v1/mediaInfo/#{app_id}/en-US") # assumes that en-US is the default language
128
+ http = Net::HTTP.new(uri.host, uri.port)
129
+ http.use_ssl = true
130
+ request = Net::HTTP::Put.new(uri)
131
+ request.body = content.to_json.encode('utf-8')
132
+ request['Cookie'] = cookie
133
+ request['Content-Type'] = 'application/json'
134
+ result = http.request(request)
135
+ if result.code.to_i != 200
136
+ UI.user_error!("Cannot upload apk!")
137
+ end
138
+ end
139
+
140
+ def self.submit_app(cookie, app_id)
141
+ UI.message('Submitting app for review ...')
142
+ uri = URI("https://connect-api.cloud.huawei.com/api/publish/v1/submit/#{app_id}")
143
+ http = Net::HTTP.new(uri.host, uri.port)
144
+ http.use_ssl = true
145
+ request = Net::HTTP::Post.new(uri)
146
+ request['Cookie'] = cookie
147
+ request['Accept'] = 'application/json'
148
+ request['Content-Type'] = "application/json"
149
+ content = { 'releaseTime' => (Time.now.to_f * 1000).to_i.to_s } # as soon as possible
150
+ request.body = content.to_json.encode('utf-8')
151
+ result = http.request(request)
152
+ if result.code.to_i != 200
153
+ UI.user_error!("Cannot submit app!")
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module HuaweiAppgallery
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-huawei_appgallery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arne Kaiser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.128.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.128.1
139
+ description:
140
+ email: onkelarne@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/huawei_appgallery.rb
148
+ - lib/fastlane/plugin/huawei_appgallery/actions/huawei_appgallery_action.rb
149
+ - lib/fastlane/plugin/huawei_appgallery/helper/huawei_appgallery_helper.rb
150
+ - lib/fastlane/plugin/huawei_appgallery/version.rb
151
+ homepage: https://github.com/arnekaiser/fastlane-plugin-huawei_appgallery
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.7.6.2
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Plugin to deploy an app to the Huawei AppGallery
175
+ test_files: []