fastlane-plugin-zealot 0.4.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 876ca038d87e1cd85c34e6f60fec74125e639c7d8a55d5c67b80bd33abb0295a
4
- data.tar.gz: 6346d81d2edddf64242e4d0b3f5891bd2271d143c22b28a37895cbe2e54a0287
3
+ metadata.gz: 5e3bacd2013042608e84e46e51c022b6cea7469876d37b84f044028bf4e591dc
4
+ data.tar.gz: 975d4ca4c3dc22f4d2466b5518675a14eebb797697aaa85f9d9f39e07f49fc5e
5
5
  SHA512:
6
- metadata.gz: 8bfd4fd75beee932bb1a6577c27aba4b1437daa4071d83d21a45a03c7f8f05db30e5449b087a5828135bec636fbdb26f2fa770319cef79e09e003478b806b0e6
7
- data.tar.gz: bbc559185354975864ce0f1f12fc1341ed1ca85bd9d319a1dcbdda275a07509775c821d5c3fb6f77d5891fa5953e052aacce1a50b43d40e8853dc565bae9d1a6
6
+ metadata.gz: c4e2e25c7bbf317204dc6c8eb118f5ada4cc8397c1c10ebd6be4b5a7fbd089e3bde4207f7a07aebf32826d255dae2fc11ef5fc42dab01b3a7cde8233ce4a94dc
7
+ data.tar.gz: 71e61f001f6b684dad1060371e8bb71c542bb2bb2fcb4b21c706961abe70c063267319a0b785f2529a59a60b5183c720e9cdedef5f8cfe221c1d9ef7e5109773
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Zealot plugin
1
+ # fastlane-plugin-zealot
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-zealot)
4
4
 
5
- 上传移动应用(iPhone、Android)到 [Zealot](https://github.com/getzealot/zealot) 自建 App 分发系统。
5
+ 上传移动应用(iPhone、Android)到 [Zealot](https://github.com/tryzealot/zealot) 自建 App 分发系统。
6
6
 
7
- > Zealot 是一个开源、可自建服务的移动应用上传没有如此简单、解放开发打包的烦恼,轻松放权给测试、产品、运营等使用 App 的人员,深度与 Jenkins 和 Gitlab 集成。
7
+ > Zealot 是一个开源自部署移动应用分发平台,提供 iOS、Android SDK、fastlane 等丰富组件库,打包分发流程、上传应用竟然如此简单、解决开发人员频繁打包的烦恼 🖖
8
8
 
9
9
  ## 快速上手
10
10
 
@@ -14,50 +14,311 @@
14
14
  $ fastlane add_plugin zealot
15
15
  ```
16
16
 
17
- ## 参数说明
17
+ ## 功能列表
18
+
19
+ 插件包含多个 actions 提供大家使用:
20
+
21
+ ### zealot
22
+
23
+ 上传 iOS/Android App 至 Zealot 系统,插件会通过参数和 CI 系统自动获取很多辅助信息。包括但不仅限于:
24
+
25
+ - 使用 gym 或 gradle 打包生成的 app 文件路径
26
+ - 解析应用获取的应用名称、打包类型
27
+ - Git 提交日志
28
+ - Git 分支名
29
+ - Git 最后一次提交的 Commit Hash
30
+ - CI 系统的名称
31
+ - CI 系统本次构建的 URL
32
+
33
+ #### 参数和返回值
34
+
35
+ ```
36
+ +-----------------+-----------------------------------+------------------------+----------+
37
+ | zealot Options |
38
+ +-----------------+-----------------------------------+------------------------+----------+
39
+ | Key | Description | Env Var | Default |
40
+ +-----------------+-----------------------------------+------------------------+----------+
41
+ | endpoint | The endpoint of zealot | ZEALOT_ENDPOINT | |
42
+ | token | The token of user | ZEALOT_TOKEN | |
43
+ | channel_key | The key of app's channel | ZEALOT_CHANNEL_KEY | |
44
+ | file | The path of app file. Optional | ZEALOT_FILE | |
45
+ | | if you use the `gym`, `ipa`, | | |
46
+ | | `xcodebuild` or `gradle` action. | | |
47
+ | name | The name of app to display on | ZEALOT_NAME | |
48
+ | | zealot | | |
49
+ | changelog | The changelog of app | ZEALOT_CHANGELOG | |
50
+ | slug | The slug of app | ZEALOT_SLUG | |
51
+ | release_type | The release type of app | ZEALOT_RELEASE_TYPE | |
52
+ | branch | The name of git branch | ZEALOT_BRANCH | |
53
+ | git_commit | The hash of git commit | ZEALOT_GIT_COMMIT | |
54
+ | custom_fields | The key-value hash of custom | ZEALOT_CUSTOM_FIELDS | |
55
+ | | fields | | |
56
+ | password | The password of app to download | ZEALOT_PASSWORD | |
57
+ | source | The name of upload source | ZEALOT_SOURCE | fastlane |
58
+ | ci_url | The name of upload source | ZEALOT_CI_CURL | |
59
+ | timeout | Request timeout in seconds | ZEALOT_TIMEOUT | |
60
+ | hide_user_token | replase user token to *** to | ZEALOT_HIDE_USER_TOKEN | true |
61
+ | | keep secret | | |
62
+ | verify_ssl | Should verify SSL of zealot | ZEALOT_VERIFY_SSL | true |
63
+ | | service | | |
64
+ | fail_on_error | Should an error uploading app | ZEALOT_FAIL_ON_ERROR | false |
65
+ | | cause a failure | | |
66
+ +-----------------+-----------------------------------+------------------------+----------+
67
+ * = default value is dependent on the user's system
68
+
69
+ +-----------------------+---------------------------------------------+
70
+ | zealot Output Variables |
71
+ +-----------------------+---------------------------------------------+
72
+ | Key | Description |
73
+ +-----------------------+---------------------------------------------+
74
+ | ZEALOT_APP_ID | The id of app |
75
+ | ZEALOT_RELEASE_ID | The id of app's release |
76
+ | ZEALOT_RELEASE_URL | The release URL of the newly uploaded build |
77
+ | ZEALOT_INSTALL_URL | The install URL of the newly uploaded build |
78
+ | ZEALOT_QRCODE_URL | The QRCode URL of the newly uploaded build |
79
+ | ZEAALOT_ERROR_MESSAGE | The error message during upload process |
80
+ +-----------------------+---------------------------------------------+
81
+ ```
82
+
83
+ #### 样例
84
+
85
+ ```ruby
86
+ # 自动根据上面结果来获取信息上传
87
+ lane :automatic_upload do
88
+ # iOS
89
+ gym
90
+
91
+ # Android
92
+ gradle
93
+
94
+ # 根据 CI 系统自动获取提交日志
95
+ ci_changelog
96
+
97
+ zealot(
98
+ endpoint: 'http://localhost:3000',
99
+ token: '...',
100
+ channel_key: '...'
101
+ )
102
+
103
+ # 或者通过环境变量配置参数
104
+ ENV['ZEALOT_ENDPOINT'] = 'http://localhost:3000'
105
+ ENV['ZEALOT_TOKEN'] = '...'
106
+ ENV['ZEALOT_CHANNEL_KEY'] = '...'
107
+
108
+ # 这里就无需再配置参数
109
+ zealot
110
+ end
111
+
112
+ # 上传指定文件
113
+ lane :upload_file do
114
+ zealot(
115
+ endpoint: 'http://localhost:3000',
116
+ token: '...',
117
+ channel_key: '...',
118
+ file: '.ipa_or_apk',
119
+ custom_fields: {
120
+ api_env: '测试环境'
121
+ }
122
+ )
123
+ end
124
+ ```
125
+
126
+ ### zealot_debug_file
127
+
128
+ 上传 iOS 的 dSYM 或 Android 的 Proguard 调试文件到 Zealot
129
+
130
+ #### 参数和返回值
18
131
 
19
132
  ```
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
- +-----------------+-------------------------------------------------+------------------------+----------+
133
+ +--------------------+-----------------------------------+---------------------------+---------+
134
+ | zealot_debug_file Options |
135
+ +--------------------+-----------------------------------+---------------------------+---------+
136
+ | Key | Description | Env Var | Default |
137
+ +--------------------+-----------------------------------+---------------------------+---------+
138
+ | endpoint | The endpoint of zealot | ZEALOT_ENDPOINT | |
139
+ | token | The token of user | ZEALOT_TOKEN | |
140
+ | channel_key | Any channel key of app | ZEALOT_CHANNEL_KEY | |
141
+ | zip_file | Using given the path of zip file | DF_DSYM_ZIP_FILE | |
142
+ | | to direct upload | | |
143
+ | platform | The name of platfrom, avaiable | ZEALOT_PLATFORM | |
144
+ | | value are | | |
145
+ | | ios,mac,macos,osx,android | | |
146
+ | path | The path of debug file | ZEALOT_PATH | |
147
+ | | (iOS/macOS is archive path for | | |
148
+ | | Xcode, Android is path for app | | |
149
+ | | project) | | |
150
+ | xcode_scheme | The scheme name of app | ZEALOT_XCODE_SCHEME | |
151
+ | android_build_type | The build type of app | ZEALOT_ANDROID_BUILD_TYPE | release |
152
+ | android_flavor | The product flavor of app | ZEALOT_ANDROID_FLAVOR | |
153
+ | extra_files | A set file names | ZEALOT_EXTRA_FILES | [] |
154
+ | output_path | The output path of compressed | DF_DSYM_OUTPUT_PATH | . |
155
+ | | dSYM file | | |
156
+ | release_version | The release version of app | ZEALOT_RELEASE_VERSION | |
157
+ | | (Android needs) | | |
158
+ | build_version | The build version of app | ZEALOT_BUILD_VERSION | |
159
+ | | (Android needs) | | |
160
+ | overwrite | Overwrite output compressed file | DF_DSYM_OVERWRITE | false |
161
+ | | if it existed | | |
162
+ | timeout | Request timeout in seconds | ZEALOT_TIMEOUT | |
163
+ | verify_ssl | Should verify SSL of zealot | ZEALOT_VERIFY_SSL | true |
164
+ | | service | | |
165
+ | fail_on_error | Should an error uploading app | ZEALOT_FAIL_ON_ERROR | false |
166
+ | | cause a failure? (true/false) | | |
167
+ +--------------------+-----------------------------------+---------------------------+---------+
168
+ * = default value is dependent on the user's system
169
+
170
+ +-----------------------+-----------------------------------------+
171
+ | zealot_debug_file Output Variables |
172
+ +-----------------------+-----------------------------------------+
173
+ | Key | Description |
174
+ +-----------------------+-----------------------------------------+
175
+ | ZEAALOT_ERROR_MESSAGE | The error message during upload process |
176
+ +-----------------------+-----------------------------------------+
43
177
  ```
44
178
 
45
- ## 举个例子
179
+ #### 样例
180
+
181
+ ```ruby
182
+ # 自动根据上面结果来获取信息上传
183
+ lane :automatic_upload do
184
+ # iOS
185
+ gym
186
+
187
+ # Android
188
+ gradle
46
189
 
47
- 检查[范例 `Fastfile` 文件](fastlane/Fastfile) 来看看如何使用插件吧(其实啥都没有写)
190
+ # 根据 CI 系统自动获取提交日志
191
+ ci_changelog
48
192
 
49
- ## Issues and Feedback
193
+ ENV['ZEALOT_ENDPOINT'] = 'http://localhost:3000'
194
+ ENV['ZEALOT_TOKEN'] = '...'
195
+ ENV['ZEALOT_CHANNEL_KEY'] = '...'
50
196
 
51
- For any other issues and feedback about this plugin, please submit it to this repository.
197
+ # 自动上传 App 和调试文件
198
+ zealot
199
+ zealot_debug_file
200
+ end
201
+ ```
202
+
203
+ ### zealot_sync_device
204
+
205
+ 同步指定 Apple 开发者账号的设备列表信息到 Zealot,主要是为了让使用者更清晰看到每个设备 udid 记录的名称,提供两种授权方式:
206
+
207
+ - [Apple API Key 授权](https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file) **强烈推荐**
208
+ - 密码授权
209
+
210
+ #### 参数和返回值
211
+
212
+ ```
213
+ +---------------+-----------------------------------------------------------------------------+------------------------+---------+
214
+ | zealot_sync_devices Options |
215
+ +---------------+-----------------------------------------------------------------------------+------------------------+---------+
216
+ | Key | Description | Env Var(s) | Default |
217
+ +---------------+-----------------------------------------------------------------------------+------------------------+---------+
218
+ | endpoint | The endpoint of zealot | ZEALOT_ENDPOINT | |
219
+ | token | The token of user | ZEALOT_TOKEN | |
220
+ | username | The apple id (username) of Apple Developer Portal | ZEALOT_USERNAME | * |
221
+ | api_key_path | Path to your App Store Connect API Key JSON file | ZEALOT_API_PATH | |
222
+ | | (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key | | |
223
+ | | -json-file) | | |
224
+ | api_key | Your App Store Connect API Key information | ZEALOT_API_KEY | * |
225
+ | | (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key | | |
226
+ | | -hash-option) | | |
227
+ | team_id | The ID of your Developer Portal team if you're in multiple teams | ZEALOT_APPLE_TEAM_ID | * |
228
+ | team_name | The name of your Developer Portal team if you're in multiple teams | ZEALOT_APPLE_TEAM_NAME | * |
229
+ | platform | The platform to use (optional) | ZEALOT_APPLE_PLATFORM | ios |
230
+ | verify_ssl | Should verify SSL of zealot service | ZEALOT_VERIFY_SSL | true |
231
+ | timeout | Request timeout in seconds | ZEALOT_TIMEOUT | |
232
+ | fail_on_error | Should an error http request cause a failure? (true/false) | ZEALOT_FAIL_ON_ERROR | false |
233
+ +---------------+-----------------------------------------------------------------------------+------------------------+---------+
234
+ ```
235
+
236
+ #### 样例
237
+
238
+ ```ruby
239
+ lane :sync do
240
+ # 使用 Apple API Key 方式授权,无需密码和二次验证
241
+ zealot_sync_devices(
242
+ endpoint: "...",
243
+ token: "...",
244
+ api_key_path: "/path/to/your/api_key_json_file",
245
+ team_id: "..."
246
+ )
247
+
248
+ # 使用传统的密码授权
249
+ zealot_sync_devices(
250
+ endpoint: "...",
251
+ token: "...",
252
+ username: "...",
253
+ team_id: "..."
254
+ )
255
+ end
256
+ ```
257
+
258
+ ### zealot_version_check
259
+
260
+ 检查应用版本是否已经上传,避免重复打包、上传已经上传的应用,目前支持两种方式检查:
261
+
262
+ - bundle_id + git commit
263
+ - bundle_id+ release_version + build_version
264
+
265
+ 参数和各平台实际值对应关系
266
+
267
+ 参数 | iOS | Android
268
+ ---|---|---
269
+ bundle_id | bundle_id | package_name
270
+ release_version | CFBundleShortVersionString | versionName
271
+ build_version | CFBundleVersion | versionCode
272
+
273
+ #### 参数和返回值
274
+
275
+ ```
276
+ +-----------------+---------------------------------+------------------------+---------+
277
+ | zealot_version_check Options |
278
+ +-----------------+---------------------------------+------------------------+---------+
279
+ | Key | Description | Env Var | Default |
280
+ +-----------------+---------------------------------+------------------------+---------+
281
+ | endpoint | The endpoint of zealot | ZEALOT_ENDPOINT | |
282
+ | token | The token of user | ZEALOT_TOKEN | |
283
+ | channel_key | The key of app's channel | ZEALOT_CHANNEL_KEY | |
284
+ | bundle_id | The bundle id(package name) of | ZEALOT_BUNDLE_ID | |
285
+ | | app | | |
286
+ | release_version | The release version of app | ZEALOT_RELEASE_VERSION | |
287
+ | build_version | The build version of app | ZEALOT_BUILD_VERSION | |
288
+ | git_commit | The latest git commit of app | ZEALOT_GIT_COMMIT | |
289
+ | verify_ssl | Should verify SSL of zealot | ZEALOT_VERIFY_SSL | true |
290
+ | | service | | |
291
+ | hide_user_token | replase user token to *** to | ZEALOT_HIDE_USER_TOKEN | true |
292
+ | | keep secret | | |
293
+ | fail_on_error | Should an error http request | ZEALOT_FAIL_ON_ERROR | false |
294
+ | | cause a failure? (true/false) | | |
295
+ +-----------------+---------------------------------+------------------------+---------+
296
+ * = default value is dependent on the user's system
297
+
298
+ +------------------------+---------------------------------------------+
299
+ | zealot_version_check Output Variables |
300
+ +------------------------+---------------------------------------------+
301
+ | Key | Description |
302
+ +------------------------+---------------------------------------------+
303
+ | ZEALOT_VERSION_EXISTED | The result of app verison existed (Boolean) |
304
+ | ZEAALOT_ERROR_MESSAGE | The error message during upload process |
305
+ +------------------------+---------------------------------------------+
306
+ Access the output values using `lane_context[SharedValues::VARIABLE_NAME]`
307
+
308
+ +-----------------------------------+
309
+ | zealot_version_check Return Value |
310
+ +-----------------------------------+
311
+ | Fastlane::Boolean |
312
+ ```
52
313
 
53
- ## Troubleshooting
314
+ ## 更多例子
54
315
 
55
- If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
316
+ 检查[范例 `Fastfile` 文件](fastlane/Fastfile) 来看看如何使用插件吧
56
317
 
57
- ## Using _fastlane_ Plugins
318
+ ## 问题和反馈
58
319
 
59
- For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
320
+ 使用本插件过程中遇到的任何问题和反馈请提交问题。
60
321
 
61
- ## About _fastlane_
322
+ ## 疑惑解答
62
323
 
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).
324
+ 如果你对 fastlane 不了解建议现看看[本教程](https://icyleaf.com/tags/fastlane/),再看看使用插件的[疑惑解答](https://docs.fastlane.tools/plugins/plugins-troubleshooting/)
@@ -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 show_error("Error uploading to Zealot: empty response", fail_on_error) unless response
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
@@ -58,7 +57,7 @@ module Fastlane
58
57
  #####################################################
59
58
 
60
59
  def self.description
61
- 'Upload a new build to Zealot'
60
+ 'Upload IPA/APK files to Zealot which it provides a self-host Over The Air Server for deployment of Android and iOS apps.'
62
61
  end
63
62
 
64
63
  def self.available_options
@@ -14,7 +14,7 @@ module Fastlane
14
14
 
15
15
  def self.run(params)
16
16
  file = generate_zip_file(params)
17
- UI.user_error! "Something wrong with compress debug file" unless file
17
+ UI.user_error! "Something wrong with compressed debug file" unless file
18
18
 
19
19
  response = upload_debug_file(params, file)
20
20
  if parse_response(response, params[:endpoint], params[:fail_on_error])
@@ -27,56 +27,81 @@ module Fastlane
27
27
  next unless value = params[key]
28
28
  obj[key] = value
29
29
  end
30
- path = new_params.delete(:path)
31
- platform = new_params[:platform]
32
30
 
33
- case platform
31
+ if (zip_file = params[:zip_file]) && File.file?(zip_file)
32
+ UI.user_error! "The zip file can not be readable: #{zip_file}" unless File.readable?(zip_file)
33
+
34
+ UI.verbose "Using given zip file: #{zip_file}"
35
+ return zip_file
36
+ end
37
+
38
+ platform = new_params.delete(:platform)
39
+ if !platform && Fastlane::Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
40
+ return generate_dsym_zip(new_params, nil)
41
+ end
42
+
43
+ path = new_params.delete(:path)
44
+ case platform.downcase.to_sym
34
45
  when :ios, :mac, :macos, :osx
35
46
  generate_dsym_zip(new_params, path)
36
47
  when :android
37
48
  generate_proguard_zip(new_params, path)
38
49
  else
39
- UI.user_error!("No match value of platform: #{value}, avaiable value are #{PLATFORM.join(',')}.")
50
+ UI.user_error!("No match value of platform: #{platform}, avaiable value are #{PLATFORM.join(',')}.")
40
51
  end
41
52
  end
42
53
 
43
- def self.generate_dsym_zip(params, path)
44
- params[:archive_path] = if path
45
- path
46
- else
47
- Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || Fastlane::Actions::DsymAction::ARCHIVE_PATH
48
- end
49
-
54
+ def self.generate_dsym_zip(params, archive_path)
55
+ params[:archive_path] = archive_path || Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || Fastlane::Actions::DsymAction::ARCHIVE_PATH
50
56
  params[:scheme] = params.delete(:xcode_scheme)
51
57
  Fastlane::Actions::DsymAction.run(params)
52
58
  end
53
59
 
54
- def self.generate_proguard_zip(params, path)
55
- params[:app_path] = path if path && !path.empty?
60
+ def self.generate_proguard_zip(params, app_path)
61
+ params[:app_path] = app_path unless app_path.to_s.empty?
56
62
  params[:build_type] = params.delete(:android_build_type)
57
63
  params[:flavor] = params.delete(:android_flavor)
58
64
  Fastlane::Actions::ProguardAction.run(params)
59
65
  end
60
66
 
61
67
  def self.parse_response(response, upload_url, fail_on_error)
62
- return show_error("Error uploading to Zealot: empty response", fail_on_error) unless response
68
+ return unless response
63
69
 
64
70
  UI.verbose response.body.to_s
65
-
66
71
  if (body = response.body) && (error = body['error'])
67
- return show_error("Error uploading to Zealot: #{response.body}", fail_on_error)
72
+ return show_error("Error uploading to Zealot[#{response.status}]: #{response.body}", fail_on_error)
68
73
  end
69
74
 
75
+ print_uploaded_data(body)
76
+
70
77
  true
71
78
  end
72
79
  private_class_method :parse_response
73
80
 
81
+ def self.print_uploaded_data(data)
82
+ rows = data.each_with_object({}) do |(key, value), obj|
83
+ if key == 'metadata'
84
+ obj["#{key} (#{value.size})"] = value.each_with_object([]) do |item, obj|
85
+ obj << item.map {|k, v| "#{k}: #{v}" }.join("\n")
86
+ end.join("\n-------------------------\n")
87
+ else
88
+ obj[key] = value.to_s
89
+ end
90
+ end
91
+
92
+ puts Terminal::Table.new(
93
+ title: 'Uploaded debug file information'.green,
94
+ rows: rows
95
+ )
96
+ end
97
+ private_class_method :print_uploaded_data
98
+
74
99
  #####################################################
75
100
  # @!group Documentation
76
101
  #####################################################
77
102
 
78
103
  def self.description
79
- 'Upload a new build to Zealot'
104
+ 'Upload dSYM/Proguard files to Zealot which it provides a self-host Over The Air Server for deployment of Android and iOS apps.'
80
105
  end
81
106
 
82
107
  def self.available_options
@@ -95,15 +120,21 @@ module Fastlane
95
120
  type: String),
96
121
  FastlaneCore::ConfigItem.new(key: :channel_key,
97
122
  env_name: 'ZEALOT_CHANNEL_KEY',
98
- description: 'The key of app\'s channel',
123
+ description: 'Any channel key of app',
124
+ verify_block: proc do |value|
125
+ UI.user_error!("No channel key of app, pass using `channel_key: 'channel_key'`") if value.nil? || value.empty?
126
+ end,
127
+ type: String),
128
+ FastlaneCore::ConfigItem.new(key: :zip_file,
129
+ env_name: 'DF_DSYM_ZIP_FILE',
130
+ description: "Using given the path of zip file to direct upload",
131
+ optional: true,
99
132
  type: String),
100
133
  FastlaneCore::ConfigItem.new(key: :platform,
101
134
  env_name: 'ZEALOT_PLATFORM',
102
135
  description: "The name of platfrom, avaiable value are #{PLATFORM.join(',')}",
103
- verify_block: proc do |value|
104
- UI.user_error!("No match value of platform: #{value}") unless PLATFORM.include?(value)
105
- end,
106
- type: :Symbol),
136
+ optional: true,
137
+ type: String),
107
138
  FastlaneCore::ConfigItem.new(key: :path,
108
139
  env_name: 'ZEALOT_PATH',
109
140
  description: 'The path of debug file (iOS/macOS is archive path for Xcode, Android is path for app project)',
@@ -139,12 +170,12 @@ module Fastlane
139
170
  type: String),
140
171
  FastlaneCore::ConfigItem.new(key: :release_version,
141
172
  env_name: 'ZEALOT_RELEASE_VERSION',
142
- description: 'The release version of app',
173
+ description: 'The release version of app (Android needs)',
143
174
  optional: true,
144
175
  type: String),
145
176
  FastlaneCore::ConfigItem.new(key: :build_version,
146
177
  env_name: 'ZEALOT_BUILD_VERSION',
147
- description: 'The build version of app',
178
+ description: 'The build version of app (Android needs)',
148
179
  optional: true,
149
180
  type: String),
150
181
  FastlaneCore::ConfigItem.new(key: :overwrite,
@@ -174,14 +205,37 @@ module Fastlane
174
205
 
175
206
  def self.example_code
176
207
  [
208
+ 'zealot_debug_file(
209
+ endpoint: "...",
210
+ token: "...",
211
+ channel_key: "...",
212
+ platform: :ios
213
+ )',
214
+ 'zealot_debug_file(
215
+ endpoint: "...",
216
+ token: "...",
217
+ channel_key: "...",
218
+ platform: :ios,
219
+ xcode_scheme: "AppName"
220
+ )',
221
+ 'zealot_debug_file(
222
+ endpoint: "...",
223
+ token: "...",
224
+ channel_key: "...",
225
+ platform: :android,
226
+ android_build_type: "release",
227
+ android_flavor: "google_play",
228
+ release_version: "1.1.0",
229
+ build_version: "1",
230
+ )',
177
231
  'zealot_debug_file(
178
232
  endpoint: "...",
179
233
  token: "...",
180
234
  channel_key: "...",
181
235
  zip_file: "...",
182
- release_version: "...",
183
- build_version: "..."
184
- )'
236
+ release_version: "1.1.0",
237
+ build_version: "1",
238
+ )',
185
239
  ]
186
240
  end
187
241
 
@@ -13,19 +13,34 @@ module Fastlane
13
13
  def self.run(params)
14
14
  require 'spaceship'
15
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
16
  all_platforms = Set[params[:platform]]
22
17
  supported_platforms = all_platforms.select { |platform| self.is_supported?(platform.to_sym) }
23
18
 
24
- devices = supported_platforms.flat_map { |platform| Spaceship::Device.all(mac: platform == "mac") }
19
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path]))
20
+ UI.message('Creating authorization token for App Store Connect API')
21
+ Spaceship::ConnectAPI.token = api_token
22
+
23
+ devices = supported_platforms.flat_map do |platform|
24
+ Spaceship::ConnectAPI::Device.all(filter: { platform: platform == 'ios' ? 'IOS' : 'MAC_OS'})
25
+ end
26
+ else
27
+ username = params[:username]
28
+ UI.message("Login to App Store Connect (#{username})")
29
+ credentials = CredentialsManager::AccountManager.new(user: username)
30
+ Spaceship.login(credentials.user, credentials.password)
31
+ UI.message('Login successful')
32
+ Spaceship.select_team
33
+
34
+ # Fetches all devices includes macOS.
35
+
36
+ devices = supported_platforms.flat_map { |platform| Spaceship::Device.all(mac: platform == 'mac') }
37
+ end
38
+
39
+ UI.message('Fetching list of currently registered devices...')
25
40
 
26
41
  print_table(build_table_data(params, devices), title: 'zealot_sync_devices')
27
42
 
28
- UI.verbose("Syncing devices to #{params[:endpoint]} ...")
43
+ UI.message("Syncing devices to #{params[:endpoint]} ...")
29
44
  failed_devices = []
30
45
  devices.each do |device|
31
46
  begin
@@ -39,7 +54,7 @@ module Fastlane
39
54
 
40
55
  failed = failed_devices.size
41
56
  successed = devices.size - failed
42
- UI.success "Successful Synced devices. success: #{successed}, failed: #{failed}"
57
+ UI.success "Successful Synced devices, success: #{successed}, failed: #{failed}"
43
58
  UI.verbose "Failed devices: #{failed_devices}"
44
59
  end
45
60
 
@@ -66,11 +81,28 @@ module Fastlane
66
81
  end,
67
82
  type: String),
68
83
  FastlaneCore::ConfigItem.new(key: :username,
69
- env_name: 'DELIVER_USER',
84
+ env_name: 'ZEALOT_USERNAME',
70
85
  description: 'The apple id (username) of Apple Developer Portal',
71
86
  default_value_dynamic: true,
72
87
  optional: true,
73
88
  type: String),
89
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
90
+ env_name: 'ZEALOT_API_PATH',
91
+ description: 'Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)',
92
+ optional: true,
93
+ conflicting_options: [:api_key],
94
+ verify_block: proc do |value|
95
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
96
+ end),
97
+ FastlaneCore::ConfigItem.new(key: :api_key,
98
+ env_name: 'ZEALOT_API_KEY',
99
+ description: 'Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)',
100
+ type: Hash,
101
+ default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
102
+ default_value_dynamic: true,
103
+ optional: true,
104
+ sensitive: true,
105
+ conflicting_options: [:api_key_path]),
74
106
  FastlaneCore::ConfigItem.new(key: :team_id,
75
107
  env_name: 'ZEALOT_APPLE_TEAM_ID',
76
108
  description: 'The ID of your Developer Portal team if you\'re in multiple teams',
@@ -79,7 +111,7 @@ module Fastlane
79
111
  optional: true,
80
112
  type: String,
81
113
  verify_block: proc do |value|
82
- ENV["FASTLANE_TEAM_ID"] = value.to_s
114
+ ENV['FASTLANE_TEAM_ID'] = value.to_s
83
115
  end),
84
116
  FastlaneCore::ConfigItem.new(key: :team_name,
85
117
  env_name: 'ZEALOT_APPLE_TEAM_NAME',
@@ -89,7 +121,7 @@ module Fastlane
89
121
  optional: true,
90
122
  type: String,
91
123
  verify_block: proc do |value|
92
- ENV["FASTLANE_TEAM_NAME"] = value.to_s
124
+ ENV['FASTLANE_TEAM_NAME'] = value.to_s
93
125
  end),
94
126
  FastlaneCore::ConfigItem.new(key: :platform,
95
127
  env_name: 'ZEALOT_APPLE_PLATFORM',
@@ -121,6 +153,12 @@ module Fastlane
121
153
 
122
154
  def self.example_code
123
155
  [
156
+ 'zealot_sync_devices(
157
+ endpoint: "...",
158
+ token: "...",
159
+ api_key_path: "...",
160
+ team_id: "..."
161
+ )',
124
162
  'zealot_sync_devices(
125
163
  endpoint: "...",
126
164
  token: "...",
@@ -7,6 +7,14 @@ module Fastlane
7
7
  module Actions
8
8
  module SharedValues
9
9
  ZEALOT_VERSION_EXISTED = :ZEALOT_VERSION_EXISTED
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
10
18
  end
11
19
 
12
20
  class ZealotVersionCheckAction < Action
@@ -31,6 +39,17 @@ module Fastlane
31
39
  Actions.lane_context[SharedValues::ZEALOT_VERSION_EXISTED] = is_existed
32
40
 
33
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
+
34
53
  UI.important 'Found app version, you can skip upload it'
35
54
  else
36
55
  UI.success 'Not found app version, you can upload it'
@@ -92,6 +111,12 @@ module Fastlane
92
111
  optional: true,
93
112
  default_value: true,
94
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),
95
120
  FastlaneCore::ConfigItem.new(key: :fail_on_error,
96
121
  env_name: 'ZEALOT_FAIL_ON_ERROR',
97
122
  description: 'Should an error http request cause a failure? (true/false)',
@@ -138,7 +138,7 @@ module Fastlane
138
138
  #######################################
139
139
 
140
140
  def sync_deivce(params, device)
141
- body = { token: params[:token], name: device.name }
141
+ body = { token: params[:token], name: device.name, model: device.model }
142
142
  http_request(:put, "/api/devices/#{device.udid}", body, params)
143
143
  end
144
144
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fastlane
2
4
  module Zealot
3
- VERSION = "0.4.1"
5
+ VERSION = '0.8.0'
4
6
  end
5
7
  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.1
4
+ version: 0.8.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-05-25 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: fastlane-plugin-debug_file
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.1
33
+ version: 0.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.1
40
+ version: 0.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -156,15 +156,15 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 2.137.0
159
+ version: 2.172.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- version: 2.137.0
167
- description:
166
+ version: 2.172.0
167
+ description:
168
168
  email: icyleaf.cn@gmail.com
169
169
  executables: []
170
170
  extensions: []
@@ -179,11 +179,11 @@ files:
179
179
  - lib/fastlane/plugin/zealot/actions/zealot_version_check.rb
180
180
  - lib/fastlane/plugin/zealot/helper/zealot_helper.rb
181
181
  - lib/fastlane/plugin/zealot/version.rb
182
- homepage: https://github.com/getzealot/fastlane-plugin-zealot
182
+ homepage: https://github.com/tryzealot/fastlane-plugin-zealot
183
183
  licenses:
184
184
  - MIT
185
185
  metadata: {}
186
- post_install_message:
186
+ post_install_message:
187
187
  rdoc_options: []
188
188
  require_paths:
189
189
  - lib
@@ -198,8 +198,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 3.0.3
202
- signing_key:
201
+ rubygems_version: 3.1.4
202
+ signing_key:
203
203
  specification_version: 4
204
- summary: Upload a new build to Zealot
204
+ summary: Upload IPA/APK/dSYM/Proguard files to Zealot which it provides a self-host
205
+ Over The Air Server for deployment of Android and iOS apps.
205
206
  test_files: []