fastlane-plugin-zealot 0.2.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/zealot/actions/zealot_action.rb +6 -2
- data/lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb +1 -5
- data/lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb +146 -0
- data/lib/fastlane/plugin/zealot/actions/zealot_version_check.rb +25 -1
- data/lib/fastlane/plugin/zealot/helper/zealot_helper.rb +62 -3
- data/lib/fastlane/plugin/zealot/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a1b2f611786f8740b32f953adfbd42bbc5df33e4160f6e1490179200a4dfe4c
|
4
|
+
data.tar.gz: 5a03f7c7e0920c557892758244a1213ba9d4343b00cda48f2b2dfc05c3230039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4877a7954d4afb7a52e5ea78a2848bd9a3cb97c7c19c7f56cb6c07ddafd5e63b302a78c39c873d2486b4233c261b57183fc095922c8476b4b33c205da7078da
|
7
|
+
data.tar.gz: 057e2ce616687b74697fe2411e1d085a3af5a7b5ee77f42801c08e9bb0b6919bf17770f3fc82eb49f2d48d77a0da0fb81c0eb690425230002bbc81d6add0efc8
|
@@ -31,10 +31,9 @@ module Fastlane
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.parse_response(response, upload_url, fail_on_error)
|
34
|
-
return
|
34
|
+
return unless response
|
35
35
|
|
36
36
|
UI.verbose response.body.to_s
|
37
|
-
|
38
37
|
if response.status != 201
|
39
38
|
return show_error("Error uploading to Zealot [#{response.status}]: #{response.body}", fail_on_error)
|
40
39
|
end
|
@@ -137,6 +136,11 @@ module Fastlane
|
|
137
136
|
optional: true,
|
138
137
|
default_value: 'fastlane',
|
139
138
|
type: String),
|
139
|
+
FastlaneCore::ConfigItem.new(key: :ci_url,
|
140
|
+
env_name: 'ZEALOT_CI_CURL',
|
141
|
+
description: 'The name of upload source',
|
142
|
+
optional: true,
|
143
|
+
type: String),
|
140
144
|
FastlaneCore::ConfigItem.new(key: :timeout,
|
141
145
|
env_name: 'ZEALOT_TIMEOUT',
|
142
146
|
description: 'Request timeout in seconds',
|
@@ -6,9 +6,6 @@ require 'fastlane/plugin/debug_file'
|
|
6
6
|
|
7
7
|
module Fastlane
|
8
8
|
module Actions
|
9
|
-
module SharedValues
|
10
|
-
ZEAALOT_ERROR_MESSAGE = :ZEAALOT_ERROR_MESSAGE
|
11
|
-
end
|
12
9
|
|
13
10
|
class ZealotDebugFileAction < Action
|
14
11
|
extend Fastlane::Helper::ZealotHelper
|
@@ -62,10 +59,9 @@ module Fastlane
|
|
62
59
|
end
|
63
60
|
|
64
61
|
def self.parse_response(response, upload_url, fail_on_error)
|
65
|
-
return
|
62
|
+
return unless response
|
66
63
|
|
67
64
|
UI.verbose response.body.to_s
|
68
|
-
|
69
65
|
if (body = response.body) && (error = body['error'])
|
70
66
|
return show_error("Error uploading to Zealot: #{response.body}", fail_on_error)
|
71
67
|
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credentials_manager'
|
4
|
+
require 'fastlane/action'
|
5
|
+
require_relative '../helper/zealot_helper'
|
6
|
+
|
7
|
+
module Fastlane
|
8
|
+
module Actions
|
9
|
+
|
10
|
+
class ZealotSyncDevicesAction < Action
|
11
|
+
extend Fastlane::Helper::ZealotHelper
|
12
|
+
|
13
|
+
def self.run(params)
|
14
|
+
require 'spaceship'
|
15
|
+
|
16
|
+
credentials = CredentialsManager::AccountManager.new(user: params[:username])
|
17
|
+
Spaceship.login(credentials.user, credentials.password)
|
18
|
+
Spaceship.select_team
|
19
|
+
|
20
|
+
UI.message('Fetching list of currently registered devices...')
|
21
|
+
all_platforms = Set[params[:platform]]
|
22
|
+
supported_platforms = all_platforms.select { |platform| self.is_supported?(platform.to_sym) }
|
23
|
+
|
24
|
+
devices = supported_platforms.flat_map { |platform| Spaceship::Device.all(mac: platform == "mac") }
|
25
|
+
|
26
|
+
print_table(build_table_data(params, devices), title: 'zealot_sync_devices')
|
27
|
+
|
28
|
+
UI.verbose("Syncing devices to #{params[:endpoint]} ...")
|
29
|
+
failed_devices = []
|
30
|
+
devices.each do |device|
|
31
|
+
begin
|
32
|
+
sync_deivce(params, device)
|
33
|
+
rescue Faraday::ConnectionFailed
|
34
|
+
failed_devices << {udid: device.udid, error: 'Can not connecting to Zealot'}
|
35
|
+
rescue Faraday::TimeoutError
|
36
|
+
failed_devices << {udid: device.udid, error: 'Timed out to Zealot'}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
failed = failed_devices.size
|
41
|
+
successed = devices.size - failed
|
42
|
+
UI.success "Successful Synced devices. success: #{successed}, failed: #{failed}"
|
43
|
+
UI.verbose "Failed devices: #{failed_devices}"
|
44
|
+
end
|
45
|
+
|
46
|
+
#####################################################
|
47
|
+
# @!group Documentation
|
48
|
+
#####################################################
|
49
|
+
|
50
|
+
def self.description
|
51
|
+
'Check app version exists from Zealot'
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.available_options
|
55
|
+
[
|
56
|
+
FastlaneCore::ConfigItem.new(key: :endpoint,
|
57
|
+
env_name: 'ZEALOT_ENDPOINT',
|
58
|
+
description: 'The endpoint of zealot',
|
59
|
+
type: String),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :token,
|
61
|
+
env_name: 'ZEALOT_TOKEN',
|
62
|
+
description: 'The token of user',
|
63
|
+
sensitive: true,
|
64
|
+
verify_block: proc do |value|
|
65
|
+
UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
|
66
|
+
end,
|
67
|
+
type: String),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
69
|
+
env_name: 'DELIVER_USER',
|
70
|
+
description: 'The apple id (username) of Apple Developer Portal',
|
71
|
+
default_value_dynamic: true,
|
72
|
+
optional: true,
|
73
|
+
type: String),
|
74
|
+
FastlaneCore::ConfigItem.new(key: :team_id,
|
75
|
+
env_name: 'ZEALOT_APPLE_TEAM_ID',
|
76
|
+
description: 'The ID of your Developer Portal team if you\'re in multiple teams',
|
77
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
|
78
|
+
default_value_dynamic: true,
|
79
|
+
optional: true,
|
80
|
+
type: String,
|
81
|
+
verify_block: proc do |value|
|
82
|
+
ENV["FASTLANE_TEAM_ID"] = value.to_s
|
83
|
+
end),
|
84
|
+
FastlaneCore::ConfigItem.new(key: :team_name,
|
85
|
+
env_name: 'ZEALOT_APPLE_TEAM_NAME',
|
86
|
+
description: 'The name of your Developer Portal team if you\'re in multiple teams',
|
87
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
|
88
|
+
default_value_dynamic: true,
|
89
|
+
optional: true,
|
90
|
+
type: String,
|
91
|
+
verify_block: proc do |value|
|
92
|
+
ENV["FASTLANE_TEAM_NAME"] = value.to_s
|
93
|
+
end),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :platform,
|
95
|
+
env_name: 'ZEALOT_APPLE_PLATFORM',
|
96
|
+
description: 'The platform to use (optional)',
|
97
|
+
optional: true,
|
98
|
+
default_value: 'ios',
|
99
|
+
verify_block: proc do |value|
|
100
|
+
UI.user_error!('The platform can only be ios or mac') unless %('ios', 'mac').include?(value)
|
101
|
+
end),
|
102
|
+
FastlaneCore::ConfigItem.new(key: :verify_ssl,
|
103
|
+
env_name: 'ZEALOT_VERIFY_SSL',
|
104
|
+
description: 'Should verify SSL of zealot service',
|
105
|
+
optional: true,
|
106
|
+
default_value: true,
|
107
|
+
type: Boolean),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :timeout,
|
109
|
+
env_name: 'ZEALOT_TIMEOUT',
|
110
|
+
description: 'Request timeout in seconds',
|
111
|
+
type: Integer,
|
112
|
+
optional: true),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
114
|
+
env_name: 'ZEALOT_FAIL_ON_ERROR',
|
115
|
+
description: 'Should an error http request cause a failure? (true/false)',
|
116
|
+
optional: true,
|
117
|
+
default_value: false,
|
118
|
+
type: Boolean)
|
119
|
+
]
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.example_code
|
123
|
+
[
|
124
|
+
'zealot_sync_devices(
|
125
|
+
endpoint: "...",
|
126
|
+
token: "...",
|
127
|
+
username: "...",
|
128
|
+
team_id: "..."
|
129
|
+
)'
|
130
|
+
]
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.category
|
134
|
+
:beta
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.authors
|
138
|
+
['icyleaf']
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.is_supported?(_)
|
142
|
+
true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -7,7 +7,14 @@ module Fastlane
|
|
7
7
|
module Actions
|
8
8
|
module SharedValues
|
9
9
|
ZEALOT_VERSION_EXISTED = :ZEALOT_VERSION_EXISTED
|
10
|
-
|
10
|
+
ZEALOT_LATEST_RELEASE_ID = :ZEALOT_LATEST_RELEASE_ID
|
11
|
+
ZEALOT_LATEST_RELEASE_VERSION = :ZEALOT_LATEST_RELEASE_VERSION
|
12
|
+
ZEALOT_LATEST_BUILD_VERSION = :ZEALOT_LATEST_VERSION
|
13
|
+
ZEALOT_LATEST_VERSION = :ZEALOT_LATEST_VERSION
|
14
|
+
ZEALOT_LATEST_RELEASE_URL = :ZEALOT_LATEST_RELEASE_URL
|
15
|
+
ZEALOT_LATEST_QRCODE_URL = :ZEALOT_LATEST_QRCODE_URL
|
16
|
+
ZEALOT_LATEST_INSTALL_URL = :ZEALOT_LATEST_INSTALL_URL
|
17
|
+
ZEALOT_LATEST_CONTEXT = :ZEALOT_LATEST_CONTEXT
|
11
18
|
end
|
12
19
|
|
13
20
|
class ZealotVersionCheckAction < Action
|
@@ -32,6 +39,17 @@ module Fastlane
|
|
32
39
|
Actions.lane_context[SharedValues::ZEALOT_VERSION_EXISTED] = is_existed
|
33
40
|
|
34
41
|
if is_existed
|
42
|
+
context = response.body
|
43
|
+
|
44
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_RELEASE_ID] = context['id']
|
45
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_RELEASE_VERSION] = context['release_version']
|
46
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_BUILD_VERSION] = context['build_version']
|
47
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_VERSION] = context['version']
|
48
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_RELEASE_URL] = context['release_url']
|
49
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_INSTALL_URL] = context['install_url']
|
50
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_QRCODE_URL] = context['qrcode_url']
|
51
|
+
Actions.lane_context[SharedValues::ZEALOT_LATEST_CONTEXT] = context
|
52
|
+
|
35
53
|
UI.important 'Found app version, you can skip upload it'
|
36
54
|
else
|
37
55
|
UI.success 'Not found app version, you can upload it'
|
@@ -93,6 +111,12 @@ module Fastlane
|
|
93
111
|
optional: true,
|
94
112
|
default_value: true,
|
95
113
|
type: Boolean),
|
114
|
+
FastlaneCore::ConfigItem.new(key: :hide_user_token,
|
115
|
+
env_name: 'ZEALOT_HIDE_USER_TOKEN',
|
116
|
+
description: 'replase user token to *** to keep secret',
|
117
|
+
optional: true,
|
118
|
+
default_value: true,
|
119
|
+
type: Boolean),
|
96
120
|
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
97
121
|
env_name: 'ZEALOT_FAIL_ON_ERROR',
|
98
122
|
description: 'Should an error http request cause a failure? (true/false)',
|
@@ -57,7 +57,7 @@ module Fastlane
|
|
57
57
|
rescue Faraday::ConnectionFailed
|
58
58
|
show_error('Can not connecting to Zealot', params[:fail_on_error])
|
59
59
|
rescue Faraday::TimeoutError
|
60
|
-
show_error('Uploading build to
|
60
|
+
show_error('Uploading build to Zealot timed out ⏳', params[:fail_on_error])
|
61
61
|
end
|
62
62
|
|
63
63
|
def upload_app_params(params)
|
@@ -71,14 +71,16 @@ module Fastlane
|
|
71
71
|
end
|
72
72
|
|
73
73
|
UPLOAD_APP_PARAMS_KEYS = %w[
|
74
|
-
name changelog release_type slug branch
|
75
|
-
|
74
|
+
name changelog release_type slug branch password
|
75
|
+
git_commit custom_fields source ci_url
|
76
76
|
].freeze
|
77
77
|
|
78
78
|
def avialable_upload_app_params(params)
|
79
79
|
UPLOAD_APP_PARAMS_KEYS.each_with_object({}) do |key, obj|
|
80
80
|
value = params.fetch(key.to_sym, ask: false)
|
81
81
|
value = JSON.dump(value) if key == 'custom_fields' && value
|
82
|
+
value = detect_ci_url(params) if key == 'ci_url'
|
83
|
+
value = detect_source(params) if key == 'source'
|
82
84
|
obj[key.to_sym] = value if value && !value.empty?
|
83
85
|
end
|
84
86
|
end
|
@@ -133,8 +135,30 @@ module Fastlane
|
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
138
|
+
#######################################
|
139
|
+
|
140
|
+
def sync_deivce(params, device)
|
141
|
+
body = { token: params[:token], name: device.name, model: device.model }
|
142
|
+
http_request(:put, "/api/devices/#{device.udid}", body, params)
|
143
|
+
end
|
144
|
+
|
145
|
+
def build_table_data(params, devices)
|
146
|
+
data = {
|
147
|
+
'Endpoint' => params[:endpoint],
|
148
|
+
'Token' => params[:token],
|
149
|
+
"Devices (#{devices.size})" => devices.map {|d| "#{d.name}: #{d.udid}"}.join("\n")
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
136
153
|
#####################################
|
137
154
|
|
155
|
+
def http_request(method, uri, body, params)
|
156
|
+
connection = make_connection(params[:endpoint], params[:verify_ssl])
|
157
|
+
connection.run_request(method, uri, body, nil) do |req|
|
158
|
+
req.options.timeout = params[:timeout] if params[:timeout]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
138
162
|
def make_connection(endpoint, verify_ssl = true)
|
139
163
|
require 'faraday'
|
140
164
|
require 'faraday_middleware'
|
@@ -155,6 +179,7 @@ module Fastlane
|
|
155
179
|
rows.delete(k) if hidden_keys.include?(k.to_sym)
|
156
180
|
rows[k] = rows[k].path if rows[k].is_a?(UploadIO)
|
157
181
|
end
|
182
|
+
|
158
183
|
puts Terminal::Table.new(
|
159
184
|
title: "Summary for #{title} #{Fastlane::Zealot::VERSION}".green,
|
160
185
|
rows: rows
|
@@ -178,6 +203,40 @@ module Fastlane
|
|
178
203
|
|
179
204
|
[:token]
|
180
205
|
end
|
206
|
+
|
207
|
+
def detect_source(params)
|
208
|
+
return 'jenkins' if jenkins?
|
209
|
+
return 'gitlab-ci' if gitlab?
|
210
|
+
|
211
|
+
params[:source]
|
212
|
+
end
|
213
|
+
|
214
|
+
def detect_ci_url(params)
|
215
|
+
return params[:ci_url] if params[:ci_url]
|
216
|
+
|
217
|
+
if ENV['BUILD_URL']
|
218
|
+
# Jenkins
|
219
|
+
return ENV['BUILD_URL']
|
220
|
+
elsif ENV['CI_JOB_URL']
|
221
|
+
# Gitlab >= 11.1, Runner 0.5
|
222
|
+
return ENV['CI_JOB_URL']
|
223
|
+
elsif ENV['CI_PROJECT_URL']
|
224
|
+
# Gitlab >= 8.10, Runner 0.5
|
225
|
+
return "#{ENV['CI_PROJECT_URL']}/-/jobs/#{ENV['CI_BUILD_ID']}"
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def jenkins?
|
230
|
+
%w(JENKINS_URL JENKINS_HOME).each do |current|
|
231
|
+
return true if ENV.key?(current)
|
232
|
+
end
|
233
|
+
|
234
|
+
return false
|
235
|
+
end
|
236
|
+
|
237
|
+
def gitlab?
|
238
|
+
ENV.key?('GITLAB_CI')
|
239
|
+
end
|
181
240
|
end
|
182
241
|
end
|
183
242
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-zealot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icyleaf
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 2.137.0
|
167
|
-
description:
|
167
|
+
description:
|
168
168
|
email: icyleaf.cn@gmail.com
|
169
169
|
executables: []
|
170
170
|
extensions: []
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/fastlane/plugin/zealot.rb
|
176
176
|
- lib/fastlane/plugin/zealot/actions/zealot_action.rb
|
177
177
|
- lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb
|
178
|
+
- lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb
|
178
179
|
- lib/fastlane/plugin/zealot/actions/zealot_version_check.rb
|
179
180
|
- lib/fastlane/plugin/zealot/helper/zealot_helper.rb
|
180
181
|
- lib/fastlane/plugin/zealot/version.rb
|
@@ -182,7 +183,7 @@ homepage: https://github.com/getzealot/fastlane-plugin-zealot
|
|
182
183
|
licenses:
|
183
184
|
- MIT
|
184
185
|
metadata: {}
|
185
|
-
post_install_message:
|
186
|
+
post_install_message:
|
186
187
|
rdoc_options: []
|
187
188
|
require_paths:
|
188
189
|
- lib
|
@@ -197,8 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
198
|
- !ruby/object:Gem::Version
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
|
-
rubygems_version: 3.
|
201
|
-
signing_key:
|
201
|
+
rubygems_version: 3.1.2
|
202
|
+
signing_key:
|
202
203
|
specification_version: 4
|
203
204
|
summary: Upload a new build to Zealot
|
204
205
|
test_files: []
|