fastlane-plugin-zealot 0.2.2 → 0.5.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 +0 -1
- data/lib/fastlane/plugin/zealot/helper/zealot_helper.rb +65 -6
- data/lib/fastlane/plugin/zealot/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a36e272df98dd1c84814b23963f8dd1acd6f3771838e1b281ebf38e2e331e6
|
4
|
+
data.tar.gz: 7105ed9cb6ddca628ff9285c12f2cd66dda401dbb1094d1e679000730bed4725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a9fdca9ac0e41266fee8f26a65949bb176ac62950d4a5e4157ae26e8cafa893ee967302e961db19dc41553adcde6070b93c0d5b87774be97dc7748242d5d0dc
|
7
|
+
data.tar.gz: baedb7e2dad95eb159d0c6640c525f216858055c72a38ace22ab81f04cefca82d855eee191d3cd5dc1cf7146577fa24a2217d05b27b39659d42fc269a80ca7f5
|
@@ -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
|
@@ -22,7 +22,7 @@ module Fastlane
|
|
22
22
|
end
|
23
23
|
rescue Faraday::ConnectionFailed
|
24
24
|
show_error('Can not connecting to Zealot', params[:fail_on_error])
|
25
|
-
rescue Faraday::
|
25
|
+
rescue Faraday::TimeoutError
|
26
26
|
show_error('Uploading build to Zealot timed out ⏳', params[:fail_on_error])
|
27
27
|
end
|
28
28
|
end
|
@@ -56,8 +56,8 @@ module Fastlane
|
|
56
56
|
end
|
57
57
|
rescue Faraday::ConnectionFailed
|
58
58
|
show_error('Can not connecting to Zealot', params[:fail_on_error])
|
59
|
-
rescue Faraday::
|
60
|
-
show_error('Uploading build to
|
59
|
+
rescue Faraday::TimeoutError
|
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
|
@@ -97,7 +99,7 @@ module Fastlane
|
|
97
99
|
end
|
98
100
|
rescue Faraday::ConnectionFailed
|
99
101
|
show_error('Can not connecting to Zealot', params[:fail_on_error])
|
100
|
-
rescue Faraday::
|
102
|
+
rescue Faraday::TimeoutError
|
101
103
|
show_error('Check app version from Zealot timed out ⏳', params[:fail_on_error])
|
102
104
|
end
|
103
105
|
|
@@ -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,15 +1,29 @@
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icyleaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: fastlane-plugin-debug_file
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +175,7 @@ files:
|
|
161
175
|
- lib/fastlane/plugin/zealot.rb
|
162
176
|
- lib/fastlane/plugin/zealot/actions/zealot_action.rb
|
163
177
|
- lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb
|
178
|
+
- lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb
|
164
179
|
- lib/fastlane/plugin/zealot/actions/zealot_version_check.rb
|
165
180
|
- lib/fastlane/plugin/zealot/helper/zealot_helper.rb
|
166
181
|
- lib/fastlane/plugin/zealot/version.rb
|