fastlane-plugin-zealot 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/lib/fastlane/plugin/zealot.rb +16 -0
- data/lib/fastlane/plugin/zealot/actions/zealot_action.rb +194 -0
- data/lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb +191 -0
- data/lib/fastlane/plugin/zealot/actions/zealot_version_check.rb +149 -0
- data/lib/fastlane/plugin/zealot/helper/zealot_helper.rb +135 -0
- data/lib/fastlane/plugin/zealot/version.rb +5 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e53f65df107be1d1cd79b0cf84f2841791357c7e6efecbdd59399b899976ddde
|
4
|
+
data.tar.gz: 586e7f0e8821806b988a20e0aa348407ce31ffaa4c816ff0ccf8abc91c3f630b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1bf42c92ab17668d7f1186a97239aa846684b6f2b4348d779e8b8c55b34c93f101835c269126836001ea05e65657eeda7292f57636795533d48d37fccbc7e65e
|
7
|
+
data.tar.gz: 6fbb5b8cca9ff25e47672980293d900b77a33d4b1a997ab8bd49a0a03638dd3fc568f61c1d50a1393d5ddd6edd129bc5cd31babde6fec73e18d69c62677799f5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Zealot
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Zealot plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-zealot)
|
4
|
+
|
5
|
+
上传移动应用(iPhone、Android)到 [Zealot](https://github.com/getzealot/zealot) 自建 App 分发系统。
|
6
|
+
|
7
|
+
> Zealot 是一个开源、可自建服务的移动应用上传没有如此简单、解放开发打包的烦恼,轻松放权给测试、产品、运营等使用 App 的人员,深度与 Jenkins 和 Gitlab 集成。
|
8
|
+
|
9
|
+
## 快速上手
|
10
|
+
|
11
|
+
这是一个 [_fastlane_](https://github.com/fastlane/fastlane) 插件。如果要使用 `fastlane-plugin-zealot` 可通过下面方法添加到 fastlane 体系中:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ fastlane add_plugin zealot
|
15
|
+
```
|
16
|
+
|
17
|
+
## 参数说明
|
18
|
+
|
19
|
+
```
|
20
|
+
+-----------------+-------------------------------------------------+------------------------+----------+
|
21
|
+
| zealot Options |
|
22
|
+
+-----------------+-------------------------------------------------+------------------------+----------+
|
23
|
+
| Key | Description | Env Var | Default |
|
24
|
+
+-----------------+-------------------------------------------------+------------------------+----------+
|
25
|
+
| endpoint | The endpoint of zealot | ZEALOT_ENDPOINT | |
|
26
|
+
| token | The token of user | ZEALOT_TOKEN | |
|
27
|
+
| channel_key | The key of app's channel | ZEALOT_CHANNEL_KEY | |
|
28
|
+
| file | The path of app file. Optional if you use the | ZEALOT_FILE | |
|
29
|
+
| | `gym`, `ipa`, `xcodebuild` or `gradle` action. | | |
|
30
|
+
| name | The name of app to display on zealot | ZEALOT_NAME | |
|
31
|
+
| changelog | The changelog of app | ZEALOT_CHANGELOG | |
|
32
|
+
| slug | The slug of app | ZEALOT_SLUG | |
|
33
|
+
| release_type | The release type of app | ZEALOT_RELEASE_TYPE | |
|
34
|
+
| branch | The name of git branch | ZEALOT_BRANCH | |
|
35
|
+
| git_commit | The hash of git commit | ZEALOT_GIT_COMMIT | |
|
36
|
+
| password | The password of app to download | ZEALOT_PASSWORD | |
|
37
|
+
| source | The name of upload source | ZEALOT_SOURCE | fastlane |
|
38
|
+
| timeout | Request timeout in seconds | ZEALOT_TIMEOUT | |
|
39
|
+
| hide_user_token | replase user token to *** to keep secret | ZEALOT_HIDE_USER_TOKEN | true |
|
40
|
+
| fail_on_error | Should an error uploading app cause a failure? | ZEALOT_FAIL_ON_ERROR | false |
|
41
|
+
| | (true/false) | | |
|
42
|
+
+-----------------+-------------------------------------------------+------------------------+----------+
|
43
|
+
```
|
44
|
+
|
45
|
+
## 举个例子
|
46
|
+
|
47
|
+
检查[范例 `Fastfile` 文件](fastlane/Fastfile) 来看看如何使用插件吧(其实啥都没有写)
|
48
|
+
|
49
|
+
## Issues and Feedback
|
50
|
+
|
51
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
52
|
+
|
53
|
+
## Troubleshooting
|
54
|
+
|
55
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
56
|
+
|
57
|
+
## Using _fastlane_ Plugins
|
58
|
+
|
59
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
60
|
+
|
61
|
+
## About _fastlane_
|
62
|
+
|
63
|
+
_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/zealot/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Zealot
|
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::Zealot.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fastlane/action'
|
4
|
+
require_relative '../helper/zealot_helper'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Actions
|
8
|
+
module SharedValues
|
9
|
+
ZEALOT_RELEASE_URL = :ZEALOT_RELEASE_URL
|
10
|
+
ZEALOT_QRCODE_URL = :ZEALOT_QRCODE_URL
|
11
|
+
ZEALOT_INSTALL_URL = :ZEALOT_INSTALL_URL
|
12
|
+
end
|
13
|
+
|
14
|
+
class ZealotAction < Action
|
15
|
+
extend Fastlane::Helper::ZealotHelper
|
16
|
+
|
17
|
+
def self.run(params)
|
18
|
+
endpoint = params[:endpoint]
|
19
|
+
fail_on_error = params[:fail_on_error]
|
20
|
+
|
21
|
+
response = upload_app(params)
|
22
|
+
if parse_response(response, endpoint, fail_on_error)
|
23
|
+
UI.success('Build successfully uploaded to Zealot.')
|
24
|
+
UI.success("Release URL: #{Actions.lane_context[SharedValues::ZEALOT_RELEASE_URL]}")
|
25
|
+
UI.success("QRCode URL: #{Actions.lane_context[SharedValues::ZEALOT_QRCODE_URL]}")
|
26
|
+
UI.success("Download URL: #{Actions.lane_context[SharedValues::ZEALOT_INSTALL_URL]}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.parse_response(response, upload_url, fail_on_error)
|
31
|
+
return show_error("Error uploading to Zealot: empty response", fail_on_error) unless response
|
32
|
+
|
33
|
+
UI.verbose response.body.to_s
|
34
|
+
|
35
|
+
if (body = response.body) && (error = body['error'])
|
36
|
+
return show_error("Error uploading to Zealot: #{response.body}", fail_on_error)
|
37
|
+
end
|
38
|
+
|
39
|
+
Actions.lane_context[SharedValues::ZEALOT_RELEASE_URL] = body['release_url']
|
40
|
+
Actions.lane_context[SharedValues::ZEALOT_INSTALL_URL] = body['install_url']
|
41
|
+
Actions.lane_context[SharedValues::ZEALOT_QRCODE_URL] = body['qrcode_url']
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
private_class_method :parse_response
|
46
|
+
|
47
|
+
#####################################################
|
48
|
+
# @!group Documentation
|
49
|
+
#####################################################
|
50
|
+
|
51
|
+
def self.description
|
52
|
+
'Upload a new build to Zealot'
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.available_options
|
56
|
+
[
|
57
|
+
FastlaneCore::ConfigItem.new(key: :endpoint,
|
58
|
+
env_name: 'ZEALOT_ENDPOINT',
|
59
|
+
description: 'The endpoint of zealot',
|
60
|
+
type: String),
|
61
|
+
FastlaneCore::ConfigItem.new(key: :token,
|
62
|
+
env_name: 'ZEALOT_TOKEN',
|
63
|
+
description: 'The token of user',
|
64
|
+
sensitive: true,
|
65
|
+
verify_block: proc do |value|
|
66
|
+
UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
|
67
|
+
end,
|
68
|
+
type: String),
|
69
|
+
FastlaneCore::ConfigItem.new(key: :channel_key,
|
70
|
+
env_name: 'ZEALOT_CHANNEL_KEY',
|
71
|
+
description: 'The key of app\'s channel',
|
72
|
+
type: String),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :file,
|
74
|
+
env_name: 'ZEALOT_FILE',
|
75
|
+
description: 'The path of app file. Optional if you use the `gym`, `ipa`, `xcodebuild` or `gradle` action. ',
|
76
|
+
default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] || Dir['*.ipa'].last || Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] || Dir['*.apk'].last,
|
77
|
+
verify_block: proc do |value|
|
78
|
+
UI.user_error!("Couldn't pass empty to file") if value.nil? || value.empty?
|
79
|
+
UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
80
|
+
end,
|
81
|
+
optional: true,
|
82
|
+
type: String),
|
83
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
84
|
+
env_name: 'ZEALOT_NAME',
|
85
|
+
description: 'The name of app to display on zealot',
|
86
|
+
optional: true,
|
87
|
+
type: String),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :changelog,
|
89
|
+
env_name: 'ZEALOT_CHANGELOG',
|
90
|
+
description: 'The changelog of app',
|
91
|
+
optional: true,
|
92
|
+
type: String),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :slug,
|
94
|
+
env_name: 'ZEALOT_SLUG',
|
95
|
+
description: 'The slug of app',
|
96
|
+
optional: true,
|
97
|
+
type: String),
|
98
|
+
FastlaneCore::ConfigItem.new(key: :release_type,
|
99
|
+
env_name: 'ZEALOT_RELEASE_TYPE',
|
100
|
+
description: 'The release type of app',
|
101
|
+
optional: true,
|
102
|
+
type: String),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
104
|
+
env_name: 'ZEALOT_BRANCH',
|
105
|
+
description: 'The name of git branch',
|
106
|
+
optional: true,
|
107
|
+
type: String),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :git_commit,
|
109
|
+
env_name: 'ZEALOT_GIT_COMMIT',
|
110
|
+
description: 'The hash of git commit',
|
111
|
+
optional: true,
|
112
|
+
type: String),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :password,
|
114
|
+
env_name: 'ZEALOT_PASSWORD',
|
115
|
+
description: 'The password of app to download',
|
116
|
+
optional: true,
|
117
|
+
type: String),
|
118
|
+
FastlaneCore::ConfigItem.new(key: :source,
|
119
|
+
env_name: 'ZEALOT_SOURCE',
|
120
|
+
description: 'The name of upload source',
|
121
|
+
optional: true,
|
122
|
+
default_value: 'fastlane',
|
123
|
+
type: String),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :timeout,
|
125
|
+
env_name: 'ZEALOT_TIMEOUT',
|
126
|
+
description: 'Request timeout in seconds',
|
127
|
+
type: Integer,
|
128
|
+
optional: true),
|
129
|
+
FastlaneCore::ConfigItem.new(key: :hide_user_token,
|
130
|
+
env_name: 'ZEALOT_HIDE_USER_TOKEN',
|
131
|
+
description: 'replase user token to *** to keep secret',
|
132
|
+
optional: true,
|
133
|
+
default_value: true,
|
134
|
+
type: Boolean),
|
135
|
+
FastlaneCore::ConfigItem.new(key: :verify_ssl,
|
136
|
+
env_name: 'ZEALOT_VERIFY_SSL',
|
137
|
+
description: 'Should verify SSL of zealot service',
|
138
|
+
optional: true,
|
139
|
+
default_value: true,
|
140
|
+
type: Boolean),
|
141
|
+
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
142
|
+
env_name: 'ZEALOT_FAIL_ON_ERROR',
|
143
|
+
description: 'Should an error uploading app cause a failure',
|
144
|
+
optional: true,
|
145
|
+
default_value: false,
|
146
|
+
type: Boolean)
|
147
|
+
]
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.example_code
|
151
|
+
[
|
152
|
+
'zealot(
|
153
|
+
endpoint: "...",
|
154
|
+
token: "...",
|
155
|
+
channel_key: "..."
|
156
|
+
)',
|
157
|
+
'zealot(
|
158
|
+
endpoint: "...",
|
159
|
+
token: "...",
|
160
|
+
channel_key: "...",
|
161
|
+
name: "custom_app_name",
|
162
|
+
release_type: "adhoc",
|
163
|
+
branch: "develop",
|
164
|
+
git_commit: "8s20an32",
|
165
|
+
source: "jenkins",
|
166
|
+
file: "./app.{ipa,apk}"
|
167
|
+
)',
|
168
|
+
]
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.output
|
172
|
+
[
|
173
|
+
[
|
174
|
+
'ZEALOT_RELEASE_URL', 'The release URL of the newly uploaded build',
|
175
|
+
'ZEALOT_INSTALL_URL', 'The install URL of the newly uploaded build',
|
176
|
+
'ZEALOT_QRCODE_URL', 'The QRCode URL of the newly uploaded build'
|
177
|
+
]
|
178
|
+
]
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.category
|
182
|
+
:beta
|
183
|
+
end
|
184
|
+
|
185
|
+
def self.authors
|
186
|
+
['icyleaf']
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.is_supported?(_)
|
190
|
+
true
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fastlane/action'
|
4
|
+
require_relative '../helper/zealot_helper'
|
5
|
+
# require 'fastlane-plugin-debug_file'
|
6
|
+
|
7
|
+
module Fastlane
|
8
|
+
module Actions
|
9
|
+
class ZealotDebugFileAction < Action
|
10
|
+
extend Fastlane::Helper::ZealotHelper
|
11
|
+
|
12
|
+
PLATFORM = %I[ios mac android].freeze
|
13
|
+
|
14
|
+
def self.run(params)
|
15
|
+
endpoint = params[:endpoint]
|
16
|
+
platform = params[:platform]
|
17
|
+
path = params[:path]
|
18
|
+
fail_on_error = params[:fail_on_error]
|
19
|
+
|
20
|
+
# UI.user_error! "Not found path: #{path}" unless Dir.exist?(path)
|
21
|
+
|
22
|
+
case platform
|
23
|
+
when :ios, :mac
|
24
|
+
params.set(archive_path, path) unless path.empty?
|
25
|
+
file = Fastlane::Actions::DsymAction.run(params)
|
26
|
+
when :android
|
27
|
+
params.set(app_path, path) unless path.empty?
|
28
|
+
file = Fastlane::Actions::ProguardAction.run(params)
|
29
|
+
else
|
30
|
+
UI.user_error!("No match value of platform: #{value}, avaiable value are #{PLATFORM.join(',')}.")
|
31
|
+
end
|
32
|
+
|
33
|
+
UI.user_error! "Something wrong with compress debug file" unless file
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.upload(upload_url, form, timeout, fail_on_error)
|
37
|
+
begin
|
38
|
+
connection.post do |req|
|
39
|
+
req.url('/api/debug_files/upload')
|
40
|
+
req.options.timeout = timeout
|
41
|
+
req.body = form
|
42
|
+
end
|
43
|
+
rescue Faraday::Error::TimeoutError
|
44
|
+
show_error('Uploading build to Zealot timed out ⏳', fail_on_error)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
private_class_method :upload
|
48
|
+
|
49
|
+
def self.parse_response(response, upload_url, fail_on_error)
|
50
|
+
return show_error("Error uploading to Zealot: empty response", fail_on_error) unless response
|
51
|
+
|
52
|
+
UI.verbose response.body.to_s
|
53
|
+
|
54
|
+
if (body = response.body) && (error = body['error'])
|
55
|
+
return show_error("Error uploading to Zealot: #{response.body}", fail_on_error)
|
56
|
+
end
|
57
|
+
|
58
|
+
Actions.lane_context[SharedValues::ZEALOT_RELEASE_URL] = body['release_url']
|
59
|
+
Actions.lane_context[SharedValues::ZEALOT_INSTALL_URL] = body['install_url']
|
60
|
+
Actions.lane_context[SharedValues::ZEALOT_QRCODE_URL] = body['qrcode_url']
|
61
|
+
|
62
|
+
true
|
63
|
+
end
|
64
|
+
private_class_method :parse_response
|
65
|
+
|
66
|
+
#####################################################
|
67
|
+
# @!group Documentation
|
68
|
+
#####################################################
|
69
|
+
|
70
|
+
def self.description
|
71
|
+
'Upload a new build to Zealot'
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.available_options
|
75
|
+
[
|
76
|
+
FastlaneCore::ConfigItem.new(key: :endpoint,
|
77
|
+
env_name: 'ZEALOT_ENDPOINT',
|
78
|
+
description: 'The endpoint of zealot',
|
79
|
+
type: String),
|
80
|
+
FastlaneCore::ConfigItem.new(key: :token,
|
81
|
+
env_name: 'ZEALOT_TOKEN',
|
82
|
+
description: 'The token of user',
|
83
|
+
sensitive: true,
|
84
|
+
verify_block: proc do |value|
|
85
|
+
UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
|
86
|
+
end,
|
87
|
+
type: String),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :channel_key,
|
89
|
+
env_name: 'ZEALOT_CHANNEL_KEY',
|
90
|
+
description: 'The key of app\'s channel',
|
91
|
+
type: String),
|
92
|
+
FastlaneCore::ConfigItem.new(key: :platform,
|
93
|
+
env_name: 'ZEALOT_PLATFORM',
|
94
|
+
description: "The name of platfrom, avaiable value are #{PLATFORM.join(',')}",
|
95
|
+
verify_block: proc do |value|
|
96
|
+
UI.user_error!("No match value of platform: #{value}") unless PLATFORM.include?(value)
|
97
|
+
end,
|
98
|
+
type: :Symbol),
|
99
|
+
FastlaneCore::ConfigItem.new(key: :path,
|
100
|
+
env_name: 'ZEALOT_PATH',
|
101
|
+
description: 'The path of debug file (iOS/macOS is archive path for Xcode, Android is path for app project)',
|
102
|
+
type: String),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :xcode_scheme,
|
104
|
+
env_name: 'ZEALOT_XCODE_SCHEME',
|
105
|
+
description: 'The scheme name of app',
|
106
|
+
optional: true,
|
107
|
+
type: String),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :android_build_type,
|
109
|
+
env_name: 'ZEALOT_ANDROID_BUILD_TYPE',
|
110
|
+
description: 'The build type of app',
|
111
|
+
default_value: Fastlane::Actions::ProguardAction::RELEASE_TYPE,
|
112
|
+
optional: true,
|
113
|
+
type: String),
|
114
|
+
FastlaneCore::ConfigItem.new(key: :android_flavor,
|
115
|
+
env_name: 'ZEALOT_ANDROID_FLAVOR',
|
116
|
+
description: 'The product flavor of app',
|
117
|
+
optional: true,
|
118
|
+
type: String),
|
119
|
+
FastlaneCore::ConfigItem.new(key: :extra_files,
|
120
|
+
env_name: 'ZEALOT_EXTRA_FILES',
|
121
|
+
description: 'A set file names',
|
122
|
+
optional: true,
|
123
|
+
default_value: [],
|
124
|
+
type: Array),
|
125
|
+
FastlaneCore::ConfigItem.new(key: :output_path,
|
126
|
+
env_name: 'DF_DSYM_OUTPUT_PATH',
|
127
|
+
description: "The output path of compressed dSYM file",
|
128
|
+
default_value: OUTPUT_PATH,
|
129
|
+
optional: true,
|
130
|
+
type: String),
|
131
|
+
FastlaneCore::ConfigItem.new(key: :release_version,
|
132
|
+
env_name: 'ZEALOT_RELEASE_VERSION',
|
133
|
+
description: 'The release version of app',
|
134
|
+
optional: true,
|
135
|
+
type: String),
|
136
|
+
FastlaneCore::ConfigItem.new(key: :build_version,
|
137
|
+
env_name: 'ZEALOT_BUILD_VERSION',
|
138
|
+
description: 'The build version of app',
|
139
|
+
optional: true,
|
140
|
+
type: String),
|
141
|
+
FastlaneCore::ConfigItem.new(key: :timeout,
|
142
|
+
env_name: 'ZEALOT_TIMEOUT',
|
143
|
+
description: 'Request timeout in seconds',
|
144
|
+
type: Integer,
|
145
|
+
optional: true),
|
146
|
+
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
147
|
+
env_name: 'ZEALOT_FAIL_ON_ERROR',
|
148
|
+
description: 'Should an error uploading app cause a failure? (true/false)',
|
149
|
+
optional: true,
|
150
|
+
default_value: false,
|
151
|
+
type: Boolean)
|
152
|
+
]
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.example_code
|
156
|
+
[
|
157
|
+
'zealot_debug_file(
|
158
|
+
endpoint: "...",
|
159
|
+
token: "...",
|
160
|
+
channel_key: "...",
|
161
|
+
zip_file: "...",
|
162
|
+
release_version: "...",
|
163
|
+
build_version: "..."
|
164
|
+
)'
|
165
|
+
]
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.output
|
169
|
+
[
|
170
|
+
[
|
171
|
+
'ZEALOT_RELEASE_URL', 'The release URL of the newly uploaded build',
|
172
|
+
'ZEALOT_INSTALL_URL', 'The install URL of the newly uploaded build',
|
173
|
+
'ZEALOT_QRCODE_URL', 'The QRCode URL of the newly uploaded build'
|
174
|
+
]
|
175
|
+
]
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.category
|
179
|
+
:misc
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.authors
|
183
|
+
['icyleaf']
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.is_supported?(_)
|
187
|
+
true
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fastlane/action'
|
4
|
+
require_relative '../helper/zealot_helper'
|
5
|
+
|
6
|
+
module Fastlane
|
7
|
+
module Actions
|
8
|
+
module SharedValues
|
9
|
+
ZEALOT_APP_VERSION_EXISTED = :ZEALOT_APP_VERSION_EXISTED
|
10
|
+
end
|
11
|
+
|
12
|
+
class ZealotVersionCheckAction < Action
|
13
|
+
extend Fastlane::Helper::ZealotHelper
|
14
|
+
|
15
|
+
def self.run(params)
|
16
|
+
response = check_app_version(params)
|
17
|
+
parse_response(response, params[:fail_on_error])
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.parse_response(response, fail_on_error)
|
21
|
+
UI.verbose "[status] #{response.status}"
|
22
|
+
UI.verbose "[body] #{response.body}"
|
23
|
+
|
24
|
+
is_existed = case response.status
|
25
|
+
when 200 then true
|
26
|
+
when 404 then false
|
27
|
+
end
|
28
|
+
|
29
|
+
return show_error(response.body['error'], fail_on_error) if is_existed.nil?
|
30
|
+
|
31
|
+
Actions.lane_context[SharedValues::ZEALOT_APP_VERSION_EXISTED] = is_existed
|
32
|
+
|
33
|
+
if is_existed
|
34
|
+
UI.important 'Found app version, you can skip upload it'
|
35
|
+
else
|
36
|
+
UI.success 'Not found app version, you can upload it'
|
37
|
+
end
|
38
|
+
|
39
|
+
is_existed
|
40
|
+
end
|
41
|
+
private_class_method :parse_response
|
42
|
+
|
43
|
+
#####################################################
|
44
|
+
# @!group Documentation
|
45
|
+
#####################################################
|
46
|
+
|
47
|
+
def self.description
|
48
|
+
'Check app version exists from Zealot'
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.available_options
|
52
|
+
[
|
53
|
+
FastlaneCore::ConfigItem.new(key: :endpoint,
|
54
|
+
env_name: 'ZEALOT_ENDPOINT',
|
55
|
+
description: 'The endpoint of zealot',
|
56
|
+
type: String),
|
57
|
+
FastlaneCore::ConfigItem.new(key: :token,
|
58
|
+
env_name: 'ZEALOT_TOKEN',
|
59
|
+
description: 'The token of user',
|
60
|
+
sensitive: true,
|
61
|
+
verify_block: proc do |value|
|
62
|
+
UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
|
63
|
+
end,
|
64
|
+
type: String),
|
65
|
+
FastlaneCore::ConfigItem.new(key: :channel_key,
|
66
|
+
env_name: 'ZEALOT_CHANNEL_KEY',
|
67
|
+
description: 'The key of app\'s channel',
|
68
|
+
type: String),
|
69
|
+
FastlaneCore::ConfigItem.new(key: :bundle_id,
|
70
|
+
env_name: 'ZEALOT_BUNDLE_ID',
|
71
|
+
description: 'The bundle id(package name) of app',
|
72
|
+
type: String),
|
73
|
+
FastlaneCore::ConfigItem.new(key: :release_version,
|
74
|
+
env_name: 'ZEALOT_RELEASE_VERSION',
|
75
|
+
description: 'The release version of app',
|
76
|
+
optional: true,
|
77
|
+
type: String),
|
78
|
+
FastlaneCore::ConfigItem.new(key: :build_version,
|
79
|
+
env_name: 'ZEALOT_BUILD_VERSION',
|
80
|
+
description: 'The build version of app',
|
81
|
+
optional: true,
|
82
|
+
type: String),
|
83
|
+
FastlaneCore::ConfigItem.new(key: :git_commit,
|
84
|
+
env_name: 'ZEALOT_GIT_COMMIT',
|
85
|
+
description: 'The latest git commit of app',
|
86
|
+
default_value: ENV['GIT_COMMIT'] || ENV['CI_COMMIT_SHA'],
|
87
|
+
optional: true,
|
88
|
+
type: String),
|
89
|
+
FastlaneCore::ConfigItem.new(key: :verify_ssl,
|
90
|
+
env_name: 'ZEALOT_VERIFY_SSL',
|
91
|
+
description: 'Should verify SSL of zealot service',
|
92
|
+
optional: true,
|
93
|
+
default_value: true,
|
94
|
+
type: Boolean),
|
95
|
+
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
96
|
+
env_name: 'ZEALOT_FAIL_ON_ERROR',
|
97
|
+
description: 'Should an error http request cause a failure? (true/false)',
|
98
|
+
optional: true,
|
99
|
+
default_value: false,
|
100
|
+
type: Boolean)
|
101
|
+
]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.example_code
|
105
|
+
[
|
106
|
+
'zealot_version_check(
|
107
|
+
endpoint: "...",
|
108
|
+
token: "...",
|
109
|
+
channel_key: "...",
|
110
|
+
bundle_id: "im.ews.zealot",
|
111
|
+
git_commit: "ec7b5859f77882892325840eae0716fcaab6c14f"
|
112
|
+
)',
|
113
|
+
'zealot_version_check(
|
114
|
+
endpoint: "...",
|
115
|
+
token: "...",
|
116
|
+
channel_key: "...",
|
117
|
+
bundle_id: "im.ews.zealot",
|
118
|
+
release_version: "1.0.0",
|
119
|
+
build_version: "1"
|
120
|
+
)',
|
121
|
+
]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.output
|
125
|
+
[
|
126
|
+
[
|
127
|
+
'ZEALOT_APP_VERSION_EXISTED', 'The result of app verison existed (Boolean)'
|
128
|
+
]
|
129
|
+
]
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.return_value
|
133
|
+
Boolean
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.category
|
137
|
+
:beta
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.authors
|
141
|
+
['icyleaf']
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.is_supported?(_)
|
145
|
+
true
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fastlane_core/ui/ui'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
7
|
+
|
8
|
+
module Helper
|
9
|
+
module ZealotHelper
|
10
|
+
def upload_app(params)
|
11
|
+
form = upload_app_params(params)
|
12
|
+
print_table(form, title: 'zealot', hidden_keys: [:token])
|
13
|
+
|
14
|
+
endpoint = params[:endpoint]
|
15
|
+
UI.success("Uploading to #{endpoint} ...")
|
16
|
+
connection = make_connection(params[:endpoint], params[:verify_ssl])
|
17
|
+
connection.post do |req|
|
18
|
+
req.url('/api/apps/upload')
|
19
|
+
req.options.timeout = params[:timeout]
|
20
|
+
req.body = form
|
21
|
+
end
|
22
|
+
rescue Faraday::Error::TimeoutError
|
23
|
+
show_error('Uploading build to Apphost timed out ⏳', params[:fail_on_error])
|
24
|
+
end
|
25
|
+
|
26
|
+
def upload_app_params(params)
|
27
|
+
form = {
|
28
|
+
token: params[:token],
|
29
|
+
channel_key: params[:channel_key],
|
30
|
+
file: Faraday::UploadIO.new(params[:file], 'application/octet-stream')
|
31
|
+
}
|
32
|
+
|
33
|
+
form.merge(avialable_upload_app_params(params))
|
34
|
+
end
|
35
|
+
|
36
|
+
UPLOAD_APP_PARAMS_KEYS = %w[
|
37
|
+
name changelog release_type
|
38
|
+
slug source branch git_commit password
|
39
|
+
].freeze
|
40
|
+
|
41
|
+
def avialable_upload_app_params(params)
|
42
|
+
UPLOAD_APP_PARAMS_KEYS.each_with_object({}) do |key, obj|
|
43
|
+
value = params.fetch(key.to_sym, ask: false)
|
44
|
+
obj[key.to_sym] = value if value && !value.empty?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
#####################################
|
49
|
+
|
50
|
+
def check_app_version(params)
|
51
|
+
query = build_app_version_check_params(params)
|
52
|
+
print_table(query, title: 'zealot_version_check', hidden_keys: ['token'])
|
53
|
+
|
54
|
+
UI.success("Checking app version from Zealot ...")
|
55
|
+
connection = make_connection(params[:endpoint], params[:verify_ssl])
|
56
|
+
connection.get do |req|
|
57
|
+
req.url '/api/apps/version_exist'
|
58
|
+
req.params = query
|
59
|
+
end
|
60
|
+
rescue Faraday::Error::TimeoutError
|
61
|
+
show_error('Check app version from Zealot timed out ⏳', params[:fail_on_error])
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_app_version_check_params(params)
|
65
|
+
token = params[:token]
|
66
|
+
channel_key = params[:channel_key]
|
67
|
+
bundle_id = params[:bundle_id]
|
68
|
+
release_version = params[:release_version]
|
69
|
+
build_version = params[:build_version]
|
70
|
+
git_commit = params[:git_commit]
|
71
|
+
|
72
|
+
UI.user_error! 'bundle id is missing' if bundle_id.to_s.empty?
|
73
|
+
|
74
|
+
has_version = !(release_version.to_s.empty? && build_version.to_s.empty?)
|
75
|
+
has_git_commit = !git_commit.to_s.empty?
|
76
|
+
UI.user_error! 'release_version + build_version or git_commit is missing' unless has_version || has_git_commit
|
77
|
+
|
78
|
+
if has_version
|
79
|
+
{
|
80
|
+
token: token,
|
81
|
+
channel_key: channel_key,
|
82
|
+
bundle_id: bundle_id,
|
83
|
+
release_version: release_version,
|
84
|
+
build_version: build_version
|
85
|
+
}
|
86
|
+
else
|
87
|
+
{
|
88
|
+
token: token,
|
89
|
+
channel_key: channel_key,
|
90
|
+
bundle_id: bundle_id,
|
91
|
+
git_commit: git_commit
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#####################################
|
97
|
+
|
98
|
+
def make_connection(endpoint, verify_ssl = true)
|
99
|
+
require 'faraday'
|
100
|
+
require 'faraday_middleware'
|
101
|
+
|
102
|
+
Faraday.new(url: endpoint, ssl: { verify: verify_ssl }) do |builder|
|
103
|
+
builder.request(:multipart)
|
104
|
+
builder.request(:url_encoded)
|
105
|
+
builder.request(:retry, max: 3, interval: 5)
|
106
|
+
builder.response(:json, content_type: /\bjson$/)
|
107
|
+
builder.adapter(:net_http)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def print_table(form, title: 'zealot', hidden_keys: [], remove_empty_value: true)
|
112
|
+
rows = form.dup
|
113
|
+
rows.keys.each do |k|
|
114
|
+
rows.delete(k) if remove_empty_value && !rows[k]
|
115
|
+
rows.delete(k) if hidden_keys.include?(k.to_s)
|
116
|
+
rows[k] = rows[k].path if rows[k].is_a?(UploadIO)
|
117
|
+
end
|
118
|
+
puts Terminal::Table.new(
|
119
|
+
title: "Summary for #{title} #{Fastlane::Zealot::VERSION}".green,
|
120
|
+
rows: rows
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def show_error(message, fail_on_error)
|
125
|
+
if fail_on_error
|
126
|
+
UI.user_error!(message)
|
127
|
+
else
|
128
|
+
UI.error(message)
|
129
|
+
end
|
130
|
+
|
131
|
+
false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-zealot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- icyleaf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-11 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.137.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.137.0
|
139
|
+
description:
|
140
|
+
email: icyleaf.cn@gmail.com
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- LICENSE
|
146
|
+
- README.md
|
147
|
+
- lib/fastlane/plugin/zealot.rb
|
148
|
+
- lib/fastlane/plugin/zealot/actions/zealot_action.rb
|
149
|
+
- lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb
|
150
|
+
- lib/fastlane/plugin/zealot/actions/zealot_version_check.rb
|
151
|
+
- lib/fastlane/plugin/zealot/helper/zealot_helper.rb
|
152
|
+
- lib/fastlane/plugin/zealot/version.rb
|
153
|
+
homepage: https://github.com/getzealot/fastlane-plugin-zealot
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubygems_version: 3.0.6
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Upload a new build to Zealot
|
176
|
+
test_files: []
|