fastlane-plugin-fastci 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c113c3ddc50728aaff7bef64c55a42e4abcfbd9130952c8ddd5dc52efd31795d
4
- data.tar.gz: 1b88cf3206c5697173749fab2d1db948d88f78224e7d2ff6d617bce303c7687b
3
+ metadata.gz: 412038fd44bc6d55aa20d9be09dd4501bef38e2050066ab808e8d88dc60994e7
4
+ data.tar.gz: d6535653192f7f5b4aa0ef9a6126b6df85fb50fb1036daa686920b168f070652
5
5
  SHA512:
6
- metadata.gz: 6b1ba90fe667f603d85d32678b15354677a19a311e2313ba52c2ee71b08d3b738de014b50479b04f59842498302ac851adfbd536094de409e7a786fa19bce334
7
- data.tar.gz: afb7fc6ec870bf1b907ec1e7b6ad986ee479f1a75d85f11a25c4eeaa5b46f64856ec9b9334382de2cbc98d0dbb99db84d07a7f46d0ff7490966a8d3e38fc6bcc
6
+ metadata.gz: 3cb86329414a976f10e924e55f1961462e1e2342b904ecaad5a1ac60ea09b3bd285c81689f0babcbab24a0ce82eaad09f65cf4d7b0247ff0f7a1d3648e2f5b43
7
+ data.tar.gz: 0fc6b479c8b969597e8354a3a20360150935a53581668e72cc34db2311567fec50f0ec86e4664bb41e449c6dbcb1599fce34a044d6caf7e32bf5142a69463fee
data/README.md CHANGED
@@ -1,23 +1,118 @@
1
- # fastci plugin
2
1
 
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-ld)
2
+ # fastlane-plugin-fastci
4
3
 
5
- ## Getting Started
4
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-fastci)
6
5
 
7
- This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ld`, add it to your project by running:
6
+ 一个集成 iOS CI 与多种自动化操作的 Fastlane 集合插件。
7
+ 简单快速的集成,5 分钟即可上手。
8
+ 配合 Jenkins 实现高度自定义。
8
9
 
9
- ```bash
10
- fastlane add_plugin fastci
10
+ 目前还在 Beta 测试阶段!!!
11
+
12
+ ---
13
+
14
+ ## 安装方法
15
+
16
+ 1、安装 [python3](https://www.python.org/downloads/macos/)
17
+
18
+ 2、安装 [homebrew](https://brew.sh/)
19
+
20
+ 3、安装并初始化 [fastlane](https://docs.fastlane.tools/getting-started/ios/setup/)
21
+
22
+ 4、添加插件 ` fastlane add_plugin fastci `
23
+
24
+ 5、更新插件 ` fastlane update_plugins `
25
+
26
+ ---
27
+
28
+ ## 使用方法
29
+
30
+ 参考 [` Fastfile `](fastlane/Fastfile) 和 [` .env.default `](fastlane/.env.default) 替换项目内 fastlane 文件夹下文件。
31
+ 然后终端进入项目根目录就可以使用 ` fastlane `
32
+
33
+
34
+ ### 使用后会在项目根目录生成文件夹
35
+
36
+ 可以自行在 ` .gitignore ` 中设置忽略等级
37
+
38
+ ```
39
+ fastlane_cache/ # 插件缓存文件夹
40
+ ├── build_logs/ # 编译日志
41
+ ├── html/ # 各种检查报告
42
+ ├── temp/ # 临时文件
43
+ ├── build_cache.txt # build 自动递增缓存
44
+ └── commit_cache.txt # git commit 缓存
45
+ ```
46
+
47
+ ## 支持功能与使用示例
48
+
49
+ ### 1. 自动打包
50
+ 功能:自动编译并导出 ipa 包,支持多种打包方式和集成多项检查。
51
+ 生成完的 ipa 会放在桌面上,非 ` app-store ` 配置了蒲公英参数会自动上传蒲公英,` app-store ` 配置了商店参数会自动上传商店。
52
+
53
+ ` build `: 不指定的话内部有递增逻辑,格式为 ` 20250905.15(日期+当天包的次数) `
54
+
55
+ ` version `: 在 Xcode13 之后创建的项目,不再支持脚本修改。需要兼容请在 ` Build settings ` 中将 ` GENERATE_INFOPLIST_FILE ` 设置为 ` NO `
56
+
57
+ ```ruby
58
+ package(
59
+ configuration: "Debug", # 编译环境 Release/Debug
60
+ export_method: "development", # 打包方式 ad-hoc, enterprise, app-store, development
61
+ version: nil, # 指定 version
62
+ build: nil, # 指定 build 号
63
+ is_analyze_swiftlint: false, # 是否代码分析
64
+ is_detect_duplicity_code: false, # 是否检测重复代码
65
+ is_detect_unused_code: false, # 是否检测未使用代码
66
+ is_detect_unused_image: false # 是否检测未使用图片
67
+ )
68
+ ```
69
+
70
+ ### 2. SwiftLint 静态代码分析
71
+ 功能:依赖 ` SwiftLint ` 对项目代码进行静态分析,生成分析报告。
72
+ 使用前需要参考自定义 [` .swiftlint.yml `](/.swiftlint.yml) 文件,并将该文件放到项目根目录。
73
+
74
+ ` commit_hash `: 上一次提交哈希, 会比较该哈希到最新哈希之间的文件
75
+
76
+ ```ruby
77
+ analyze_swiftlint(
78
+ is_all: true, # 是否检查所有文件,默认 true
79
+ configuration: "Debug", # 构建配置,Debug/Release
80
+ commit_hash: nil # 指定 commit hash,仅检查变更文件
81
+ )
82
+ ```
83
+
84
+ ### 3. 检测重复代码
85
+ 功能:检测项目中的重复代码,生成分析报告。
86
+ 使用前需要参考自定义 [` .periphery.yml `](/.periphery.yml) 文件,并将该文件放到项目根目录。
87
+
88
+ ` commit_hash `: 上一次提交哈希, 会比较该哈希到最新哈希之间的文件
89
+
90
+ ```ruby
91
+ detect_duplicity_code(
92
+ is_all: true, # 是否检查所有文件,默认 true
93
+ commit_hash: nil # 指定 commit hash,仅检查变更文件
94
+ )
11
95
  ```
12
96
 
13
- ## About fastci
97
+ ### 4. 检测未使用代码
98
+ 功能:检测项目中未被使用的代码,生成分析报告。
99
+ 默认只支持 ` Debug `,需要支持 ` Release ` 请在 ` Build settings ` 中将 ` Enable Index-While-Building Functionality ` 设置为 ` Yes `。
100
+
101
+ ```ruby
102
+ detect_unused_code(
103
+ configuration: "Debug" # 构建配置,Debug/Release
104
+ )
105
+ ```
14
106
 
15
- 这个插件集成了打包、上传 appstore、上传蒲公英、钉钉通知、无用图片检测、无用代码检测、重复代码检测、swiftlint 代码检测
107
+ ### 5. 检测未使用图片资源
108
+ 功能:检测项目中未被使用的图片资源,生成分析报告。
16
109
 
17
- ## Example
110
+ ```ruby
111
+ detect_unused_image()
112
+ ```
18
113
 
19
- Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
114
+ ---
20
115
 
21
- ## About _fastlane_
116
+ ## 贡献与支持
22
117
 
23
- _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).
118
+ 如需更多帮助或贡献,请提交 Issue PR。
@@ -21,7 +21,7 @@ module Fastlane
21
21
  if is_from_package == false
22
22
  UI.message("*************| 构建项目以生成索引存储 |*************")
23
23
 
24
- options = {
24
+ other_action.gym(
25
25
  clean: true,
26
26
  silent: true,
27
27
  workspace: Environment.workspace,
@@ -30,9 +30,7 @@ module Fastlane
30
30
  buildlog_path: Constants.BUILD_LOG_DIR,
31
31
  skip_archive: true,
32
32
  skip_package_ipa: true
33
- }
34
- config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
35
- Gym::Manager.new.work(config)
33
+ )
36
34
  end
37
35
 
38
36
  log_dir = File.expand_path(Constants.BUILD_LOG_DIR)
@@ -91,7 +89,13 @@ module Fastlane
91
89
  description: "构建配置",
92
90
  optional: true,
93
91
  default_value: "Release",
94
- type: String
92
+ type: String,
93
+ verify_block: proc do |value|
94
+ valid_params = ["Release", "Debug"]
95
+ unless valid_params.include?(value)
96
+ UI.user_error!("无效的编译环境: #{value}。支持的环境: #{valid_params.join(', ')}")
97
+ end
98
+ end
95
99
  ),
96
100
  FastlaneCore::ConfigItem.new(
97
101
  key: :commit_hash,
@@ -20,7 +20,7 @@ module Fastlane
20
20
  if is_from_package == false
21
21
  puts "*************| 构建项目以生成索引存储 |*************"
22
22
 
23
- options = {
23
+ other_action.gym(
24
24
  clean: true,
25
25
  silent: true,
26
26
  workspace: Environment.workspace,
@@ -29,9 +29,7 @@ module Fastlane
29
29
  buildlog_path: Constants.BUILD_LOG_DIR,
30
30
  skip_archive: true,
31
31
  skip_package_ipa: true
32
- }
33
- config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
34
- Gym::Manager.new.work(config)
32
+ )
35
33
  end
36
34
 
37
35
  log_dir = File.expand_path(Constants.BUILD_LOG_DIR)
@@ -72,20 +70,26 @@ module Fastlane
72
70
 
73
71
  def self.available_options
74
72
  [
75
- FastlaneCore::ConfigItem.new(
76
- key: :is_from_package,
77
- description: "是否从打包流程调用",
78
- optional: true,
79
- default_value: false,
80
- type: Boolean
81
- ),
82
- FastlaneCore::ConfigItem.new(
83
- key: :configuration,
84
- description: "构建配置",
85
- optional: true,
86
- default_value: "Release",
87
- type: String
88
- )
73
+ FastlaneCore::ConfigItem.new(
74
+ key: :is_from_package,
75
+ description: "是否从打包流程调用",
76
+ optional: true,
77
+ default_value: false,
78
+ type: Boolean
79
+ ),
80
+ FastlaneCore::ConfigItem.new(
81
+ key: :configuration,
82
+ description: "构建配置。默认只支持 Debug,需要支持 Release 请在 Build settings 中将 Enable Index-While-Building Functionality 设置为 Yes",
83
+ optional: true,
84
+ default_value: "Debug",
85
+ type: String,
86
+ verify_block: proc do |value|
87
+ valid_params = ["Release", "Debug"]
88
+ unless valid_params.include?(value)
89
+ UI.user_error!("无效的编译环境: #{value}。支持的环境: #{valid_params.join(', ')}")
90
+ end
91
+ end
92
+ )
89
93
  ]
90
94
  end
91
95
 
@@ -8,9 +8,9 @@ module Fastlane
8
8
  def self.run(params)
9
9
  UI.message("*************| 开始安装 p12 证书 |*************")
10
10
 
11
- certificate_paths = Dir.glob("../#{Environment.certificate_folder_name}/*.p12")
11
+ certificate_paths = Dir.glob(File.expand_path("#{Environment.certificate_folder_name}/*.p12"))
12
12
  certificate_paths.each do |path|
13
- import_certificate(
13
+ other_action.import_certificate(
14
14
  certificate_path: File.expand_path(path),
15
15
  certificate_password: "#{Environment.certificate_password}",
16
16
  keychain_name: "login.keychain",
@@ -7,10 +7,10 @@ module Fastlane
7
7
  class InstallProfileAction < Action
8
8
  def self.run(params)
9
9
  UI.message("*************| 开始安装 provisioningProfile |*************")
10
-
11
- provisioning_profile_paths = Dir.glob("../#{Environment.provisioningProfile_folder_name}/*.mobileprovision")
10
+
11
+ provisioning_profile_paths = Dir.glob(File.expand_path("#{Environment.provisioningProfile_folder_name}/*.mobileprovision"))
12
12
  provisioning_profile_paths.each do |path|
13
- install_provisioning_profile(
13
+ other_action.install_provisioning_profile(
14
14
  path: File.expand_path(path)
15
15
  )
16
16
  end
@@ -13,6 +13,7 @@ module Fastlane
13
13
  configuration = params[:configuration] || "Debug"
14
14
  export_method = params[:export_method] || "development"
15
15
  build = params[:build] || nil
16
+ version = params[:version] || nil
16
17
  is_analyze_swiftlint = params[:is_analyze_swiftlint] || false
17
18
  is_detect_duplicity_code = params[:is_detect_duplicity_code] || false
18
19
  is_detect_unused_code = params[:is_detect_unused_code] || false
@@ -31,12 +32,18 @@ module Fastlane
31
32
  InstallProfileAction.run({})
32
33
 
33
34
  scheme = Environment.scheme
35
+
36
+ # 更改项目version
37
+ other_action.increment_version_number(
38
+ version_number: version
39
+ ) if CommonHelper.is_validate_string(version)
40
+
34
41
  # 更改项目build号
35
42
  UpdateBuildNumberAction.run(
36
43
  build: build
37
44
  )
38
45
  time = Time.new.strftime("%Y%m%d%H%M")
39
- version = Actions::GetVersionNumberAction.run(target: "#{Environment.target}")
46
+ version = Actions::GetVersionNumberAction.run(target: Environment.target)
40
47
  build = Actions::GetBuildNumberAction.run({})
41
48
  # 生成ipa包的名字格式
42
49
  ipaName = "#{Environment.scheme}_#{export_method}_#{version}_#{build}.ipa"
@@ -71,7 +78,7 @@ module Fastlane
71
78
 
72
79
  UI.message("*************| 开始打包 |*************")
73
80
 
74
- options = {
81
+ other_action.gym(
75
82
  clean: true,
76
83
  silent: true,
77
84
  workspace: Environment.workspace,
@@ -84,9 +91,7 @@ module Fastlane
84
91
  method: export_method,
85
92
  provisioningProfiles: provisioningProfiles_map
86
93
  }
87
- }
88
- config = FastlaneCore::Configuration.create(Gym::Options.available_options, options)
89
- Gym::Manager.new.work(config)
94
+ )
90
95
 
91
96
  UI.message("*************| 打包完成 |*************")
92
97
 
@@ -177,7 +182,7 @@ module Fastlane
177
182
  UI.message("*************| 跳过未使用图片检查 |*************")
178
183
  end
179
184
 
180
- if is_swiftlint ||
185
+ if is_analyze_swiftlint ||
181
186
  is_detect_duplicity_code ||
182
187
  is_detect_unused_code ||
183
188
  is_detect_unused_image
@@ -201,32 +206,51 @@ module Fastlane
201
206
  key: :configuration,
202
207
  description: "编译环境 Release or Debug",
203
208
  optional: true,
204
- default_value: "Release",
205
- type: String
209
+ default_value: "Debug",
210
+ type: String,
211
+ verify_block: proc do |value|
212
+ valid_params = ["Release", "Debug"]
213
+ unless valid_params.include?(value)
214
+ UI.user_error!("无效的编译环境: #{value}。支持的环境: #{valid_params.join(', ')}")
215
+ end
216
+ end
206
217
  ),
207
218
  FastlaneCore::ConfigItem.new(
208
219
  key: :export_method,
209
220
  description: "打包方式 ad-hoc, enterprise, app-store, development",
210
221
  optional: true,
211
222
  default_value: "development",
223
+ type: String,
224
+ verify_block: proc do |value|
225
+ valid_params = ["ad-hoc", "enterprise", "app-store", "development"]
226
+ unless valid_params.include?(value)
227
+ UI.user_error!("无效的打包方式: #{value}。支持的方式: #{valid_params.join(', ')}")
228
+ end
229
+ end
230
+ ),
231
+ FastlaneCore::ConfigItem.new(
232
+ key: :version,
233
+ description: "自定义 `version`。在 Xcode13 之后创建的项目,不再支持脚本修改。需要兼容请在 Build settings 中将 GENERATE_INFOPLIST_FILE 设置为 NO",
234
+ optional: true,
235
+ default_value: nil,
212
236
  type: String
213
237
  ),
214
238
  FastlaneCore::ConfigItem.new(
215
239
  key: :build,
216
- description: "不采取自动更新,自定义 build 号",
240
+ description: "不采取自动更新,自定义 `build` 号",
217
241
  optional: true,
218
242
  default_value: nil,
219
243
  type: String
220
244
  ),
221
245
  FastlaneCore::ConfigItem.new(
222
- key: :is_analyze_code,
246
+ key: :is_analyze_swiftlint,
223
247
  description: "是否代码分析",
224
248
  optional: true,
225
249
  default_value: false,
226
250
  type: Boolean
227
251
  ),
228
252
  FastlaneCore::ConfigItem.new(
229
- key: :is_detect_code_duplicity,
253
+ key: :is_detect_duplicity_code,
230
254
  description: "是否检查重复代码",
231
255
  optional: true,
232
256
  default_value: false,
@@ -41,7 +41,7 @@ module Fastlane
41
41
  "fastlane_cache/build_logs"
42
42
  end
43
43
  def self.IPA_OUTPUT_DIR
44
- "fastlane_cache/build_products"
44
+ "fastlane_cache/temp"
45
45
  end
46
46
  end
47
47
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Fastci
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-fastci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - watermelon