Class: Fastlane::Actions::ZealotDebugFileAction

Inherits:
Action
  • Object
show all
Extended by:
Helper::ZealotHelper
Defined in:
lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb

Constant Summary collapse

PLATFORM =
%I[ios mac macos osx android].freeze

Constants included from Helper::ZealotHelper

Helper::ZealotHelper::UPLOAD_APP_PARAMS_KEYS

Documentation collapse

Class Method Summary collapse

Methods included from Helper::ZealotHelper

avialable_upload_app_params, build_app_version_check_params, build_table_data, check_app_version, detect_ci_url, detect_source, gitlab?, hidden_keys, http_request, jenkins?, make_connection, print_table, show_error, sync_deivce, upload_app, upload_app_params, upload_debug_file, upload_debug_file_params

Class Method Details

.authorsObject



252
253
254
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 252

def self.authors
  ['icyleaf']
end

.available_optionsObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 107

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :endpoint,
                                 env_name: 'ZEALOT_ENDPOINT',
                                 description: 'The endpoint of zealot',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :token,
                                 env_name: 'ZEALOT_TOKEN',
                                 description: 'The token of user',
                                 sensitive: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
                                 end,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :channel_key,
                                 env_name: 'ZEALOT_CHANNEL_KEY',
                                 description: 'Any channel key of app',
                                 verify_block: proc do |value|
                                   UI.user_error!("No channel key of app, pass using `channel_key: 'channel_key'`") if value.nil? || value.empty?
                                 end,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :zip_file,
                                 env_name: 'DF_DSYM_ZIP_FILE',
                                 description: "Using given the path of zip file to direct upload",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: 'ZEALOT_PLATFORM',
                                 description: "The name of platfrom, avaiable value are #{PLATFORM.join(',')}",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: 'ZEALOT_PATH',
                                 description: 'The path of debug file (iOS/macOS is archive path for Xcode, Android is path for app project)',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :xcode_scheme,
                                 env_name: 'ZEALOT_XCODE_SCHEME',
                                 description: 'The scheme name of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :android_build_type,
                                 env_name: 'ZEALOT_ANDROID_BUILD_TYPE',
                                 description: 'The build type of app',
                                 default_value: Fastlane::Actions::ProguardAction::RELEASE_TYPE,
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :android_flavor,
                                 env_name: 'ZEALOT_ANDROID_FLAVOR',
                                 description: 'The product flavor of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :extra_files,
                                 env_name: 'ZEALOT_EXTRA_FILES',
                                 description: 'A set file names',
                                 optional: true,
                                 default_value: [],
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :output_path,
                                 env_name: 'DF_DSYM_OUTPUT_PATH',
                                 description: "The output path of compressed dSYM file",
                                 default_value: '.',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :release_version,
                                 env_name: 'ZEALOT_RELEASE_VERSION',
                                 description: 'The release version of app (Android needs)',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :build_version,
                                 env_name: 'ZEALOT_BUILD_VERSION',
                                 description: 'The build version of app (Android needs)',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :overwrite,
                                 env_name: 'DF_DSYM_OVERWRITE',
                                 description: "Overwrite output compressed file if it existed",
                                 default_value: false,
                                 type: Boolean),
    FastlaneCore::ConfigItem.new(key: :timeout,
                                 env_name: 'ZEALOT_TIMEOUT',
                                 description: 'Request timeout in seconds',
                                 type: Integer,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :verify_ssl,
                                 env_name: 'ZEALOT_VERIFY_SSL',
                                 description: 'Should verify SSL of zealot service',
                                 optional: true,
                                 default_value: true,
                                 type: Boolean),
    FastlaneCore::ConfigItem.new(key: :fail_on_error,
                                 env_name: 'ZEALOT_FAIL_ON_ERROR',
                                 description: 'Should an error uploading app cause a failure? (true/false)',
                                 optional: true,
                                 default_value: false,
                                 type: Boolean)
  ]
end

.categoryObject



248
249
250
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 248

def self.category
  :misc
end

.descriptionObject



103
104
105
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 103

def self.description
  'Upload dSYM/Proguard files to Zealot which it provides a self-host Over The Air Server for deployment of Android and iOS apps.'
end

.example_codeObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 206

def self.example_code
  [
    'zealot_debug_file(
      endpoint: "...",
      token: "...",
      channel_key: "...",
      platform: :ios
    )',
    'zealot_debug_file(
      endpoint: "...",
      token: "...",
      channel_key: "...",
      platform: :ios,
      xcode_scheme: "AppName"
    )',
    'zealot_debug_file(
      endpoint: "...",
      token: "...",
      channel_key: "...",
      platform: :android,
      android_build_type: "release",
      android_flavor: "google_play",
      release_version: "1.1.0",
      build_version: "1",
    )',
    'zealot_debug_file(
      endpoint: "...",
      token: "...",
      channel_key: "...",
      zip_file: "...",
      release_version: "1.1.0",
      build_version: "1",
    )',
  ]
end

.generate_dsym_zip(params, archive_path) ⇒ Object



54
55
56
57
58
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 54

def self.generate_dsym_zip(params, archive_path)
  params[:archive_path] = archive_path || Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || Fastlane::Actions::DsymAction::ARCHIVE_PATH
  params[:scheme] = params.delete(:xcode_scheme)
  Fastlane::Actions::DsymAction.run(params)
end

.generate_proguard_zip(params, app_path) ⇒ Object



60
61
62
63
64
65
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 60

def self.generate_proguard_zip(params, app_path)
  params[:app_path] = app_path unless app_path.to_s.empty?
  params[:build_type] = params.delete(:android_build_type)
  params[:flavor] = params.delete(:android_flavor)
  Fastlane::Actions::ProguardAction.run(params)
end

.generate_zip_file(params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 25

def self.generate_zip_file(params)
  new_params = params.all_keys.each_with_object({}) do |key, obj|
    next unless value = params[key]
    obj[key] = value
  end

  if (zip_file = params[:zip_file]) && File.file?(zip_file)
    UI.user_error! "The zip file can not be readable: #{zip_file}" unless File.readable?(zip_file)

    UI.verbose "Using given zip file: #{zip_file}"
    return zip_file
  end

  platform = new_params.delete(:platform)
  if !platform && Fastlane::Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
    return generate_dsym_zip(new_params, nil)
  end

  path = new_params.delete(:path)
  case platform.downcase.to_sym
  when :ios, :mac, :macos, :osx
    generate_dsym_zip(new_params, path)
  when :android
    generate_proguard_zip(new_params, path)
  else
    UI.user_error!("No match value of platform: #{platform}, avaiable value are #{PLATFORM.join(',')}.")
  end
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


256
257
258
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 256

def self.is_supported?(_)
  true
end

.outputObject



242
243
244
245
246
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 242

def self.output
  [
    ['ZEAALOT_ERROR_MESSAGE', 'The error message during upload process']
  ]
end

.run(params) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 15

def self.run(params)
  file = generate_zip_file(params)
  UI.user_error! "Something wrong with compressed debug file" unless file

  response = upload_debug_file(params, file)
  if parse_response(response, params[:endpoint], params[:fail_on_error])
    UI.success('Build successfully uploaded to Zealot.')
  end
end