fastlane-plugin-fastci 0.0.3 → 0.0.5

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: e8e578e3c451bc288f338c816bf12606c4a2029ff4cdc77c3489950e1bb5e3d5
4
- data.tar.gz: 194ee9f107f474ba5713ac7640929fe981a12cc4f8cbbbbc75018e4afe83fb3e
3
+ metadata.gz: 53ec20d0f578e7220c03e65b98d1ca1907f40d4bdd973fd5bba59fa17870ef20
4
+ data.tar.gz: fe1eb5138294dc9e4a6130b57ed96074f1c0981a344b8272a5d758e9c9edfb74
5
5
  SHA512:
6
- metadata.gz: 6eb4857f9e13960b13383e52516045bb6f73db9625e419e56279cbbb0e7be4be384c70bc81378cb4c2f13b9485781074c8e27f301f720675a85e39925c14fc09
7
- data.tar.gz: 490f206f40a2ebaf94b80cab887d1c12d6a229640577c7aa2605c57c4c4969ff2e7e950dd0291e063ecd3968af1d04d34be0f83e35287f5c23b1836883992d7b
6
+ metadata.gz: f20bf4ddf3b51247b7e7be24ecadda56acb86f10232641db6d2033bcb363c084d121ddec80f92206b3c9d5a3c882273583b62b2f045df05cbfd2efc3a4e230ae
7
+ data.tar.gz: 9a6feee1d0e97c4147bc41d65f3c57330e91d972246a08577e583706114730574bce1b34a55d21a46288954da1263f55bf09ffbf38da46c8bf20287190c010df
data/README.md CHANGED
@@ -1,23 +1,119 @@
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 ` 配置了蒲公英或 fir 参数会自动上传蒲公英或 fir` 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
+ release_notes: options[:release_notes] # 配合 jenkins 传参上传 appstore { "zh-Hans" => "修复问题", "en-US" => "bugfix"} 格式
68
+ )
69
+ ```
70
+
71
+ ### 2. SwiftLint 静态代码分析
72
+ 功能:依赖 ` SwiftLint ` 对项目代码进行静态分析,生成分析报告。
73
+ 使用前需要参考自定义 [` .swiftlint.yml `](/.swiftlint.yml) 文件,并将该文件放到项目根目录。
74
+
75
+ ` commit_hash `: 上一次提交哈希, 会比较该哈希到最新哈希之间的文件
76
+
77
+ ```ruby
78
+ analyze_swiftlint(
79
+ is_all: true, # 是否检查所有文件,默认 true
80
+ configuration: "Debug", # 构建配置,Debug/Release
81
+ commit_hash: nil # 指定 commit hash,仅检查变更文件
82
+ )
83
+ ```
84
+
85
+ ### 3. 检测重复代码
86
+ 功能:检测项目中的重复代码,生成分析报告。
87
+ 使用前需要参考自定义 [` .periphery.yml `](/.periphery.yml) 文件,并将该文件放到项目根目录。
88
+
89
+ ` commit_hash `: 上一次提交哈希, 会比较该哈希到最新哈希之间的文件
90
+
91
+ ```ruby
92
+ detect_duplicity_code(
93
+ is_all: true, # 是否检查所有文件,默认 true
94
+ commit_hash: nil # 指定 commit hash,仅检查变更文件
95
+ )
11
96
  ```
12
97
 
13
- ## About fastci
98
+ ### 4. 检测未使用代码
99
+ 功能:检测项目中未被使用的代码,生成分析报告。
100
+ 默认只支持 ` Debug `,需要支持 ` Release ` 请在 ` Build settings ` 中将 ` Enable Index-While-Building Functionality ` 设置为 ` Yes `。
101
+
102
+ ```ruby
103
+ detect_unused_code(
104
+ configuration: "Debug" # 构建配置,Debug/Release
105
+ )
106
+ ```
14
107
 
15
- 这个插件集成了打包、上传 appstore、上传蒲公英、钉钉通知、无用图片检测、无用代码检测、重复代码检测、swiftlint 代码检测
108
+ ### 5. 检测未使用图片资源
109
+ 功能:检测项目中未被使用的图片资源,生成分析报告。
16
110
 
17
- ## Example
111
+ ```ruby
112
+ detect_unused_image()
113
+ ```
18
114
 
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`.
115
+ ---
20
116
 
21
- ## About _fastlane_
117
+ ## 贡献与支持
22
118
 
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).
119
+ 如需更多帮助或贡献,请提交 Issue PR。
@@ -8,10 +8,10 @@ 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(
14
- certificate_path: File.expand_path(path),
13
+ other_action.import_certificate(
14
+ certificate_path: path,
15
15
  certificate_password: "#{Environment.certificate_password}",
16
16
  keychain_name: "login.keychain",
17
17
  keychain_password: "#{Environment.keychain_password}"
@@ -7,11 +7,11 @@ 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(
14
- path: File.expand_path(path)
13
+ other_action.install_provisioning_profile(
14
+ path: path
15
15
  )
16
16
  end
17
17
  end
@@ -27,9 +27,9 @@ module Fastlane
27
27
  FileUtils.rm_rf(Dir.glob("#{Constants.IPA_OUTPUT_DIR}/*"))
28
28
 
29
29
  # 安装证书
30
- InstallCertificateAction.run({})
30
+ other_action.install_certificate()
31
31
  # 安装 provisioningProfile
32
- InstallProfileAction.run({})
32
+ other_action.install_profile()
33
33
 
34
34
  scheme = Environment.scheme
35
35
 
@@ -115,27 +115,39 @@ module Fastlane
115
115
 
116
116
  if export_method == "app-store"
117
117
  notiText = "🚀🚀🚀🚀🚀🚀\n\n#{scheme}-iOS-打包完成\n\n#{version}_#{build}_#{export_method}\n\n🚀🚀🚀🚀🚀🚀"
118
- NotiDingdingAction.run(notiText: notiText)
118
+ DingdingHelper.sendMarkdown(notiText)
119
119
 
120
120
  if CommonHelper.is_validate_string(Environment.connect_key_id) && CommonHelper.is_validate_string(Environment.connect_issuer_id)
121
121
 
122
- UploadStoreAction.run({})
122
+ other_action.upload_store()
123
123
  notiText = "🚀🚀🚀🚀🚀🚀\n\n#{scheme}-iOS-上传完成\n\n#{version}_#{build}_#{export_method}\n\n🚀🚀🚀🚀🚀🚀"
124
- NotiDingdingAction.run(notiText: notiText)
124
+ DingdingHelper.sendMarkdown(notiText)
125
125
  end
126
126
  else
127
- # 上传蒲公英
128
- pgy_upload_info = UploadPgyAction.run(
129
- "ipa_path": ipa_path
130
- )
131
- qrCode = pgy_upload_info["buildQRCodeURL"]
132
-
133
127
  # 钉钉通知
134
128
  notiText = "🚀🚀🚀🚀🚀🚀\n\n#{scheme}-iOS-打包完成\n\n#{version}_#{build}_#{export_method}\n\n🚀🚀🚀🚀🚀🚀"
135
- if CommonHelper.is_validate_string(qrCode)
136
- notiText << "\n\n⬇️⬇️⬇️ 扫码安装 ⬇️⬇️⬇️\n\n![screenshot](#{qrCode})"
129
+
130
+ # 上传蒲公英
131
+ if CommonHelper.is_validate_string(Environment.pgy_api_key)
132
+ pgy_upload_info = other_action.upload_pgy()
133
+ qrCode = pgy_upload_info[:buildQRCodeURL]
134
+
135
+ if CommonHelper.is_validate_string(qrCode)
136
+ notiText << "\n\n⬇️⬇️⬇️ 扫码安装 ⬇️⬇️⬇️\n\n\n密码: #{Environment.pgy_password}\n![screenshot](#{qrCode})"
137
+ end
137
138
  end
138
- NotiDingdingAction.run(notiText: notiText)
139
+
140
+ # 上传 fir
141
+ if CommonHelper.is_validate_string(Environment.fir_api_token)
142
+ fir_upload_info = other_action.upload_fir()
143
+ download_url = fir_upload_info[:download_url]
144
+
145
+ if CommonHelper.is_validate_string(download_url)
146
+ notiText << "\n\n⬇️⬇️⬇️ 点击链接安装 ⬇️⬇️⬇️\n\n\n密码: #{Environment.fir_password}\n[_点击下载_](#{download_url})"
147
+ end
148
+ end
149
+
150
+ DingdingHelper.sendMarkdown(notiText)
139
151
  end
140
152
 
141
153
  # 代码分析
@@ -182,13 +194,13 @@ module Fastlane
182
194
  UI.message("*************| 跳过未使用图片检查 |*************")
183
195
  end
184
196
 
185
- if is_swiftlint ||
197
+ if is_analyze_swiftlint ||
186
198
  is_detect_duplicity_code ||
187
199
  is_detect_unused_code ||
188
200
  is_detect_unused_image
189
201
  # 钉钉通知
190
202
  notiText = "🚀🚀🚀🚀🚀🚀\n\n#{scheme}-iOS-代码检查完成\n\n#{version}_#{build}_#{export_method}\n\n🚀🚀🚀🚀🚀🚀"
191
- NotiDingdingAction.run(notiText: notiText)
203
+ DingdingHelper.sendMarkdown(notiText)
192
204
  else
193
205
  UI.message("*************| 跳过代码检查 |*************")
194
206
  end
@@ -270,6 +282,12 @@ module Fastlane
270
282
  default_value: false,
271
283
  type: Boolean
272
284
  ),
285
+ FastlaneCore::ConfigItem.new(
286
+ key: :release_notes,
287
+ description: "更新文案, 格式为 { \"zh-Hans\" => \"修复问题\", \"en-US\" => \"bugfix\"} ",
288
+ optional: true,
289
+ type: Hash
290
+ )
273
291
  ]
274
292
  end
275
293
 
@@ -0,0 +1,38 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane/plugin/fir_cli'
3
+ include Fastlane::Helper
4
+
5
+ module Fastlane
6
+ module Actions
7
+ # 上传Fir
8
+ class UploadFirAction < Action
9
+ def self.run(params)
10
+ UI.message("*************| 开始上传Fir |*************")
11
+
12
+ firinfo = other_action.fir_cli(
13
+ api_token: Environment.fir_api_token,
14
+ password: Environment.fir_password,
15
+ )
16
+
17
+ return firinfo
18
+ end
19
+
20
+ def self.description
21
+ "上传Fir"
22
+ end
23
+
24
+ def self.available_options
25
+ []
26
+ end
27
+
28
+ def self.is_supported?(platform)
29
+ platform == :ios
30
+ end
31
+
32
+ def self.category
33
+ :building
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -9,15 +9,7 @@ module Fastlane
9
9
  def self.run(params)
10
10
  UI.message("*************| 开始上传蒲公英 |*************")
11
11
 
12
- unless CommonHelper.is_validate_string(Environment.pgy_api_key)
13
- UI.message("*************| 没有配置 pgy_api_key |*************")
14
- return
15
- end
16
-
17
- ipa_path = params[:ipa_path] || ""
18
-
19
- pgyinfo = PgyerAction.run(
20
- ipa: ipa_path,
12
+ pgyinfo = other_action.pgyer(
21
13
  api_key: Environment.pgy_api_key,
22
14
  password: Environment.pgy_password,
23
15
  install_type: "2"
@@ -21,7 +21,7 @@ module Fastlane
21
21
  force: true,
22
22
  submit_for_review: false,
23
23
  automatic_release: false,
24
- release_notes: params[:release_notes]
24
+ release_notes: params[:release_notes] || ""
25
25
  )
26
26
 
27
27
  end
@@ -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
@@ -0,0 +1,27 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'fileutils'
3
+
4
+ module Fastlane
5
+ module Helper
6
+ class DingdingHelper
7
+
8
+ def self.sendMarkdown(text)
9
+ UI.message("*************| 开始钉钉消息通知 |*************")
10
+
11
+ curl = %Q{
12
+ curl 'https://oapi.dingtalk.com/robot/send?access_token=#{Environment.dingdingToken}' \
13
+ -H 'Content-Type:application/json' \
14
+ -d '{
15
+ "msgtype":"markdown",
16
+ "markdown":{
17
+ "title":"#{Environment.scheme} 打包通知",
18
+ "text":"#{text}"
19
+ }
20
+ }'
21
+ }
22
+ system curl
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -77,6 +77,14 @@ module Fastlane
77
77
  ENV['PGY_PASSWORD']
78
78
  end
79
79
 
80
+ # Fir配置
81
+ def self.fir_api_token
82
+ ENV['FIR_API_TOKEN']
83
+ end
84
+ def self.fir_password
85
+ ENV['FIR_PASSWORD']
86
+ end
87
+
80
88
  # 钉钉配置
81
89
  def self.dingdingToken
82
90
  ENV['DINGDING_TOKEN']
@@ -0,0 +1,29 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'fastlane/plugin/fir_cli'
3
+ require 'fileutils'
4
+
5
+ module Fastlane
6
+ module Helper
7
+ class FirHelper
8
+
9
+ # def self.get_download_url(download_domain, short)
10
+ # "https://#{download_domain}/#{short}"
11
+ # end
12
+
13
+ # def self.get_qrcode(download_url)
14
+ # filePath = File.expand_path(Constants.IPA_OUTPUT_DIR)
15
+ # qrcode_path = "#{filePath}/fir-qrcode.png"
16
+ # generate_rqrcode(download_url, qrcode_path)
17
+
18
+ # qrcode_path
19
+ # end
20
+
21
+ # def self.generate_rqrcode(string, png_file_path)
22
+ # qrcode = ::RQRCode::QRCode.new(string.to_s)
23
+ # qrcode.as_png(size: 500, border_modules: 2, file: png_file_path)
24
+ # png_file_path
25
+ # end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Fastci
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.5"
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.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - watermelon
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.3.2
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.6
25
+ version: 0.3.2
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: fastlane-plugin-versioning
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +37,20 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: 0.7.1
40
+ - !ruby/object:Gem::Dependency
41
+ name: fastlane-plugin-fir_cli
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.21
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.21
40
54
  email: watermelon_lp@163.com
41
55
  executables: []
42
56
  extensions: []
@@ -51,14 +65,16 @@ files:
51
65
  - lib/fastlane/plugin/fastci/actions/detect_unused_image_action.rb
52
66
  - lib/fastlane/plugin/fastci/actions/install_certificate_action.rb
53
67
  - lib/fastlane/plugin/fastci/actions/install_profile_action.rb
54
- - lib/fastlane/plugin/fastci/actions/noti_dingding_action.rb
55
68
  - lib/fastlane/plugin/fastci/actions/package_action.rb
56
69
  - lib/fastlane/plugin/fastci/actions/update_build_number_action.rb
70
+ - lib/fastlane/plugin/fastci/actions/upload_fir_action.rb
57
71
  - lib/fastlane/plugin/fastci/actions/upload_pgy_action.rb
58
72
  - lib/fastlane/plugin/fastci/actions/upload_store_action.rb
59
73
  - lib/fastlane/plugin/fastci/helper/common_helper.rb
60
74
  - lib/fastlane/plugin/fastci/helper/constants.rb
75
+ - lib/fastlane/plugin/fastci/helper/dingding_helper.rb
61
76
  - lib/fastlane/plugin/fastci/helper/environment.rb
77
+ - lib/fastlane/plugin/fastci/helper/fir_helper.rb
62
78
  - lib/fastlane/plugin/fastci/version.rb
63
79
  - lib/fastlane/plugin/python/generate_duplicity_code_html.py
64
80
  - lib/fastlane/plugin/python/generate_lint_html.py
@@ -1,51 +0,0 @@
1
- require 'fastlane/action'
2
- include Fastlane::Helper
3
-
4
- module Fastlane
5
- module Actions
6
- # 钉钉通知
7
- class NotiDingdingAction < Action
8
- def self.run(params)
9
- UI.message("*************| 开始钉钉消息通知 |*************")
10
- notiText = params[:notiText] || ""
11
-
12
- curl = %Q{
13
- curl 'https://oapi.dingtalk.com/robot/send?access_token=#{Environment.dingdingToken}' \
14
- -H 'Content-Type:application/json' \
15
- -d '{
16
- "msgtype":"markdown",
17
- "markdown":{
18
- "title":"#{Environment.scheme} 打包通知",
19
- "text":"#{notiText}"
20
- }
21
- }'
22
- }
23
- system curl
24
- end
25
-
26
- def self.description
27
- "钉钉通知"
28
- end
29
-
30
- def self.available_options
31
- [
32
- FastlaneCore::ConfigItem.new(
33
- key: :notiText,
34
- description: "要发送的钉钉通知内容",
35
- optional: false, # 是否可选
36
- type: String
37
- ),
38
- ]
39
- end
40
-
41
- def self.is_supported?(platform)
42
- platform == :ios
43
- end
44
-
45
- def self.category
46
- :notifications
47
- end
48
-
49
- end
50
- end
51
- end