ocean_package 0.11.0 → 0.14.0

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: df5f1fd000b7d02b3625d23d9c84b75bde227f1675739c743cd8c1147905ce4f
4
- data.tar.gz: e59dfeff667bb1d68c95f3cd2c03da8f9d5a10a2b3894b763c8c41763460d820
3
+ metadata.gz: 65d0074f1b3760d6b4012238dcf78594b486f5c542f08715a05823a31fbe1287
4
+ data.tar.gz: 75d9b7e786ab83e4543f0605a5742c5651f79e620b1996e941d8a541d687fc03
5
5
  SHA512:
6
- metadata.gz: 2e3db7f612b4b0639f58caa093769306c43a3b99874d735948dd192b98578f64816c6768d620cc2f6d08ff9af24c6b9e7fe7e124b3ccbc3c8c2cea1b4eeb8675
7
- data.tar.gz: 727f0b9332fff05106eff0d660646408b74f2ceea3d905f93344921897e50e42ce3a5f239229c1a9bac1e8e084db3c5740d2695257ec4e36397d340e0366e592
6
+ metadata.gz: 7c5504cac2244dac99129a5aa61c84cbdba90a5502af1b4d5ce6b804f7c8a1566de3a6f767ce38232d8371bddc36fbb5cbc8a3f531998409fcfbdfd712d50570
7
+ data.tar.gz: 2d193b4b39545aa82f16fcf9bee364e98e1dfbf7d2eb6262687dcec41875c37885d252db866cac66ef72075d71eb016e23a3c08b0925e9b4db778d08ad882dd1
@@ -20,10 +20,38 @@
20
20
  <orderEntry type="library" scope="PROVIDED" name="httparty (v0.18.1, ruby-2.6.3-p62) [gem]" level="application" />
21
21
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.3.1, ruby-2.6.3-p62) [gem]" level="application" />
22
22
  <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2020.0512, ruby-2.6.3-p62) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.12.0, ruby-2.6.3-p62) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, ruby-2.6.3-p62) [gem]" level="application" />
24
24
  <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, ruby-2.6.3-p62) [gem]" level="application" />
25
25
  <orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.1.1, ruby-2.6.3-p62) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.6.3-p62) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="semantic_logger (v4.7.1, ruby-2.6.3-p62) [gem]" level="application" />
28
28
  </component>
29
+ <component name="RakeTasksCache">
30
+ <option name="myRootTask">
31
+ <RakeTaskImpl id="rake">
32
+ <subtasks>
33
+ <RakeTaskImpl description="Build ocean_package-0.14.0.gem into the pkg directory" fullCommand="build" id="build" />
34
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
35
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
36
+ <RakeTaskImpl description="Build and install ocean_package-0.14.0.gem into system gems" fullCommand="install" id="install" />
37
+ <RakeTaskImpl id="install">
38
+ <subtasks>
39
+ <RakeTaskImpl description="Build and install ocean_package-0.14.0.gem into system gems without network access" fullCommand="install:local" id="local" />
40
+ </subtasks>
41
+ </RakeTaskImpl>
42
+ <RakeTaskImpl description="Create tag v0.14.0 and build and push ocean_package-0.14.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
43
+ <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
44
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
45
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
46
+ <RakeTaskImpl id="release">
47
+ <subtasks>
48
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
49
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
50
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
51
+ </subtasks>
52
+ </RakeTaskImpl>
53
+ </subtasks>
54
+ </RakeTaskImpl>
55
+ </option>
56
+ </component>
29
57
  </module>
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ocean_package (0.10.0)
4
+ ocean_package (0.14.0)
5
5
  CFPropertyList
6
6
  dingbot
7
7
  faraday
data/README.md CHANGED
@@ -39,8 +39,11 @@ sudo gem install multipart-post
39
39
 
40
40
  ## Usage
41
41
 
42
+ > 打包 - 上传到 fir 或 蒲公英平台 - 发送消息到钉钉群
43
+
44
+
42
45
  ```
43
- oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --pgy-api-key=蒲公英平台的apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
46
+ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --pgy-api-key=蒲公英平台的apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号 --extra-export-params="-allowProvisioningUpdates,IPHONEOS_DEPLOYMENT_TARGET=11.0"
44
47
  ```
45
48
 
46
49
  - `--workspace-path`: `.xcworkspace` 文件路径
@@ -57,7 +60,25 @@ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --
57
60
  - `--oss-endpoint`: `oss` 的 `endpoint`
58
61
  - `--ding-token`: 钉钉群机器人的`token`
59
62
  - `--at-mobiles`: 钉钉群需要 @ 的人手机号,多个用 `,` 拼接
63
+ - `--extra-export-params`: 打包的额外参数,多个用 `,` 拼接,例如 `"-allowProvisioningUpdates,IPHONEOS_DEPLOYMENT_TARGET=11.0"`
64
+ - `--open-finder`: 打包完成是否打开对应的文件目录,`--no-open-finder`表示`false`, `--open-finder` 表示 `true`
65
+
60
66
 
67
+ > 指定 ipa 文件
68
+
69
+ - 上传到蒲公英平台命令格式如下:
70
+
71
+ ```
72
+ oceanpackage --configuration=Debug --ipa-file-path=/Users/ocean/Documents/myipas/test.ipa --company-name=company2 --pgy-api-key=蒲公英平台apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
73
+ ```
74
+
75
+ > 只用到上传ipa
76
+
77
+ ```
78
+ oceanpackage --ipa-file-path=${ipa_file_path} \
79
+ --pgy-api-key=${pgy_api_key} \
80
+ --change-log="${update_desc}" \
81
+ ```
61
82
 
62
83
  ## Development
63
84
 
@@ -1,6 +1,7 @@
1
1
 
2
2
  module OceanPackage
3
3
  class Command
4
+ include OceanPackage::TimeFlow::Mixin
4
5
 
5
6
  # xcodebuild 打包相关
6
7
  attr_accessor :package
@@ -25,6 +26,7 @@ module OceanPackage
25
26
  # 自定义的ipa文件路径
26
27
  attr_accessor :custom_ipa_file_path
27
28
 
29
+
28
30
  def initialize(params = [])
29
31
  argv = CLAide::ARGV.new(params)
30
32
 
@@ -58,10 +60,13 @@ module OceanPackage
58
60
  extra_export_params = argv.option("extra-export-params", "")
59
61
  Log.info("extra-export-params: #{extra_export_params}")
60
62
 
63
+ open_finder = argv.flag?("open-finder", false )
64
+ Log.info("open-finder: #{open_finder}")
65
+
61
66
  # 自定义ipa文件,使用该文件作为 archive path
62
67
  tmp_archive_path = has_custom_ipa_file ? File.dirname("#{ipa_file_path}") : archive_path
63
68
  Log.info("tmp_archive_path: #{tmp_archive_path}")
64
- @package = OceanPackage::Package.new(workspace_path, scheme, configuration, tmp_archive_path, company_name, export_options_plist, extra_export_params)
69
+ @package = OceanPackage::Package.new(workspace_path, scheme, configuration, tmp_archive_path, company_name, export_options_plist, extra_export_params, open_finder)
65
70
 
66
71
  fir_token = argv.option("fir-token", "")
67
72
  Log.info("fir_token: #{fir_token}")
@@ -121,6 +126,7 @@ module OceanPackage
121
126
 
122
127
  # 运行
123
128
  def run
129
+ time_flow.point_start_time
124
130
  # 没有自定义ipa文件,需要执行打包命令
125
131
  unless has_custom_ipa_file
126
132
  package.run
@@ -132,6 +138,8 @@ module OceanPackage
132
138
 
133
139
  # 上传 ipa 文件
134
140
  def upload
141
+ time_flow.point_upload_ipa_time
142
+
135
143
  can_fir = fir.check
136
144
  can_pgy = pgy.check
137
145
  if can_fir
@@ -210,6 +218,8 @@ module OceanPackage
210
218
 
211
219
  # 发送打包信息到钉钉
212
220
  def send_ding_talk_msg
221
+ time_flow.point_notify_group_time
222
+
213
223
  # 消息卡片,富文本
214
224
  title = make_web_hook_message_title
215
225
  content = make_web_hook_message
@@ -220,11 +230,33 @@ module OceanPackage
220
230
 
221
231
  # 打包完成
222
232
  def finished
233
+ time_flow.point_end_time
234
+ write_time_flow_data
235
+
223
236
  Log.divider
224
237
  Log.info("package finished")
225
238
  Log.divider
226
239
  end
227
240
 
241
+ def write_time_flow_data
242
+ time_flow_dir = @package.final_archive_path
243
+ time_flow_file_path = "#{time_flow_dir}timeflow.json"
244
+ params = time_flow.make_all_points
245
+ params['timeFlowPath'] = time_flow_file_path
246
+ json = JSON.dump(params)
247
+
248
+ unless File.exist?(time_flow_file_path)
249
+ FileUtils.touch(time_flow_file_path)
250
+ end
251
+ a_file = File.new(time_flow_file_path, "r+")
252
+ if a_file
253
+ a_file.syswrite(json)
254
+ Log.info("write time flow to path(success): #{time_flow_file_path}")
255
+ else
256
+ Log.error("write time flow to path(fail): #{time_flow_file_path}")
257
+ end
258
+ end
259
+
228
260
  end
229
261
 
230
262
  end
@@ -8,7 +8,6 @@ module OceanPackage
8
8
  DEFAULT_CONFIGURATION = "Debug"
9
9
  DEFAULT_COMPANY_NAME = "YourCompanyName"
10
10
  DEFAULT_ARCHIVE_PATH = "#{Dir.home}/Documents/Ipas/"
11
-
12
11
  end
13
12
 
14
13
  end
@@ -2,6 +2,7 @@
2
2
  module OceanPackage
3
3
 
4
4
  class Package
5
+ include OceanPackage::TimeFlow::Mixin
5
6
 
6
7
  # .xcworkspace 文件路径
7
8
  attr_accessor :workspace_path
@@ -27,7 +28,12 @@ module OceanPackage
27
28
  # 结束时间
28
29
  attr_accessor :end_time
29
30
 
30
- def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist, extra_export_params)
31
+ # ipa 最大保存的数目
32
+ attr_accessor :ipa_max_retain_number
33
+ # 打包完成是否打开文件夹
34
+ attr_accessor :open_finder
35
+
36
+ def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist, extra_export_params, open_finder)
31
37
  @workspace_path = workspace_path
32
38
  @scheme = scheme
33
39
  @configuration = configuration
@@ -37,6 +43,8 @@ module OceanPackage
37
43
  @export_options_plist = export_options_plist
38
44
  @extra_export_params = extra_export_params
39
45
 
46
+ @ipa_max_retain_number = 3
47
+ @open_finder = open_finder
40
48
  # 预设置开始时间
41
49
  @start_time = Time.now
42
50
  end
@@ -61,6 +69,8 @@ module OceanPackage
61
69
  @start_time = Time.now
62
70
  # 检查必须参数
63
71
  check
72
+ # 清理历史的ipa
73
+ clean_history_ipa
64
74
  # clean 项目
65
75
  clean
66
76
  # 打包项目
@@ -70,7 +80,9 @@ module OceanPackage
70
80
  @end_time = Time.now
71
81
  # 返回打包成功的 ipa 文件路径
72
82
  ipa_file_path
73
- open_ipa_file_path
83
+ if @open_finder
84
+ open_ipa_file_path
85
+ end
74
86
  end
75
87
 
76
88
  # 一些校验
@@ -109,6 +121,51 @@ module OceanPackage
109
121
 
110
122
  end
111
123
 
124
+ # **************************************
125
+ # clean history
126
+ # **************************************
127
+
128
+ def clean_history_ipa
129
+ path = final_archive_path_company_pro
130
+
131
+ sub_paths = Array.new
132
+ Dir.each_child(path) do |x|
133
+ unless "#{x}".eql?(".DS_Store")
134
+ sub_paths.push("#{x}")
135
+ end
136
+ end
137
+
138
+ if sub_paths.length > @ipa_max_retain_number
139
+ Log.divider
140
+ Log.info("clean history ipas: begin =======")
141
+
142
+ count = sub_paths.length - @ipa_max_retain_number
143
+ deleted_paths = sub_paths.first(count)
144
+
145
+ deleted_paths.each do |p|
146
+ new_path = path + p
147
+ Log.info(new_path)
148
+ delete_directory(new_path)
149
+ end
150
+
151
+ Log.info("clean history ipas: end =======")
152
+ Log.divider
153
+ end
154
+ end
155
+
156
+ def delete_directory(dirPath)
157
+ if File.directory?(dirPath)
158
+ Dir.foreach(dirPath) do |subFile|
159
+ if subFile != '.' and subFile != '..'
160
+ delete_directory(File.join(dirPath, subFile));
161
+ end
162
+ end
163
+ Dir.rmdir(dirPath)
164
+ else
165
+ File.delete(dirPath)
166
+ end
167
+ end
168
+
112
169
  # **************************************
113
170
  # clean
114
171
  # **************************************
@@ -130,6 +187,8 @@ module OceanPackage
130
187
 
131
188
  # clean
132
189
  def clean
190
+ time_flow.point_clean_time
191
+
133
192
  res = system(clean_cmd)
134
193
  Log.info("clean result: #{res}")
135
194
 
@@ -152,8 +211,8 @@ module OceanPackage
152
211
  end
153
212
  end
154
213
 
155
- # 最终的打包路径
156
- def final_archive_path
214
+ # 最终的打包路径,包含了公司,项目名称
215
+ def final_archive_path_company_pro
157
216
  path = processed_archive_path
158
217
  unless "#{@company_name}".empty?
159
218
  path += @company_name + '/'
@@ -161,6 +220,13 @@ module OceanPackage
161
220
  unless "#{project_name}".empty?
162
221
  path += project_name + '/'
163
222
  end
223
+
224
+ path
225
+ end
226
+
227
+ # 最终的打包路径
228
+ def final_archive_path
229
+ path = final_archive_path_company_pro
164
230
  path += @date_time + '/'
165
231
 
166
232
  Log.info("final archive path: #{path}")
@@ -190,6 +256,7 @@ module OceanPackage
190
256
  cmd += ' -configuration ' + @configuration
191
257
  cmd += ' -archivePath ' + archive_file_path
192
258
  cmd += ' archive'
259
+ cmd += ' -allowProvisioningUpdates'
193
260
 
194
261
  Log.divider
195
262
  Log.info("archive command: #{cmd}")
@@ -200,6 +267,8 @@ module OceanPackage
200
267
 
201
268
  # archive
202
269
  def archive
270
+ time_flow.point_archive_time
271
+
203
272
  res = system(archive_cmd)
204
273
 
205
274
  Log.info("archive result: #{res}")
@@ -241,6 +310,8 @@ module OceanPackage
241
310
  end
242
311
 
243
312
  def export
313
+ time_flow.point_export_time
314
+
244
315
  res = system(export_cmd)
245
316
 
246
317
  Log.info("export result: #{res}")
@@ -0,0 +1,123 @@
1
+ module OceanPackage
2
+ class TimeFlow
3
+
4
+ # 开始时间
5
+ attr_accessor :start_time
6
+ # git拉取仓库时间
7
+ attr_accessor :pull_git_time
8
+ # 安装相关依赖时间
9
+ attr_accessor :pull_dependency_time
10
+ # clean 项目时间
11
+ attr_accessor :clean_time
12
+ # archive 项目时间
13
+ attr_accessor :archive_time
14
+ # 加固 项目时间
15
+ attr_accessor :reinforce_time
16
+ # 导出ipa包时间
17
+ attr_accessor :export_time
18
+ # 上传ipa到分发平台时间
19
+ attr_accessor :upload_ipa_time
20
+ # 上传dsym符号表时间
21
+ attr_accessor :upload_dsym_time
22
+ # 群通知时间(钉钉群)
23
+ attr_accessor :notify_group_time
24
+ # 整个流程完成时间
25
+ attr_accessor :end_time
26
+
27
+ public
28
+
29
+ def self.instance
30
+ @instance ||= new
31
+ end
32
+
33
+ class << self
34
+ attr_writer :instance
35
+ end
36
+
37
+ def initialize()
38
+ @start_time = get_seconds
39
+ @pull_git_time = 0
40
+ @pull_dependency_time = 0
41
+ @clean_time = 0
42
+ @archive_time = 0
43
+ @reinforce_time = 0
44
+ @export_time = 0
45
+ @upload_ipa_time = 0
46
+ @upload_dsym_time = 0
47
+ @notify_group_time = 0
48
+ end
49
+
50
+ def get_seconds
51
+ Time.now.to_i
52
+ end
53
+
54
+ def point_pull_git_time
55
+ @pull_git_time = get_seconds
56
+ end
57
+
58
+ def point_pull_dependency_time
59
+ @pull_dependency_time = get_seconds
60
+ end
61
+
62
+ def point_clean_time
63
+ @clean_time = get_seconds
64
+ end
65
+
66
+ def point_archive_time
67
+ @archive_time = get_seconds
68
+ end
69
+
70
+ def point_reinforce_time
71
+ @reinforce_time = get_seconds
72
+ end
73
+
74
+ def point_export_time
75
+ @export_time = get_seconds
76
+ end
77
+
78
+ def point_upload_ipa_time
79
+ @upload_ipa_time = get_seconds
80
+ end
81
+
82
+ def point_upload_dsym_time
83
+ @upload_dsym_time = get_seconds
84
+ end
85
+
86
+ def point_notify_group_time
87
+ @notify_group_time = get_seconds
88
+ end
89
+
90
+ def point_start_time
91
+ @start_time = get_seconds
92
+ end
93
+
94
+ def point_end_time
95
+ @end_time = get_seconds
96
+ end
97
+
98
+ def make_all_points
99
+ params = {
100
+ "startTime" => @start_time,
101
+ "pullGitTime" => @pull_git_time,
102
+ "pullDependencyTime" => @pull_dependency_time,
103
+ "cleanTime" => @clean_time,
104
+ "archiveTime" => @archive_time,
105
+ "reinforceTime" => @reinforce_time,
106
+ "exportTime" => @export_time,
107
+ "uploadIpaTime" => @upload_ipa_time,
108
+ "uploadDsymTime" => @upload_dsym_time,
109
+ "notifyGroupTime" => @notify_group_time,
110
+ "endTime" => @end_time
111
+ }
112
+ json = JSON.dump(params)
113
+ json
114
+ end
115
+
116
+ module Mixin
117
+ def time_flow
118
+ TimeFlow.instance
119
+ end
120
+ end
121
+
122
+ end
123
+ end
@@ -1,3 +1,3 @@
1
1
  module OceanPackage
2
- VERSION = "0.11.0"
2
+ VERSION = "0.14.0"
3
3
  end
data/lib/ocean_package.rb CHANGED
@@ -5,10 +5,13 @@ require 'semantic_logger'
5
5
  require 'multipart_post'
6
6
  require 'net/http/post/multipart'
7
7
  require 'json'
8
+ require 'find'
8
9
 
9
10
  # 注意:这里使用 require_relative 来引用文件
10
11
  require_relative 'ocean_package/version'
11
12
  require_relative 'ocean_package/config'
13
+ # 放在前面
14
+ require_relative 'ocean_package/time_flow'
12
15
  require_relative 'ocean_package/command'
13
16
  require_relative 'ocean_package/constants'
14
17
  require_relative 'ocean_package/fir'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ocean
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dingbot
@@ -160,13 +160,14 @@ files:
160
160
  - lib/ocean_package/oss.rb
161
161
  - lib/ocean_package/package.rb
162
162
  - lib/ocean_package/pgy.rb
163
+ - lib/ocean_package/time_flow.rb
163
164
  - lib/ocean_package/version.rb
164
165
  - ocean_package.gemspec
165
166
  homepage: https://github.com/oceanfive/ocean_package
166
167
  licenses:
167
168
  - MIT
168
169
  metadata: {}
169
- post_install_message:
170
+ post_install_message:
170
171
  rdoc_options: []
171
172
  require_paths:
172
173
  - lib
@@ -181,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  - !ruby/object:Gem::Version
182
183
  version: '0'
183
184
  requirements: []
184
- rubygems_version: 3.0.3
185
- signing_key:
185
+ rubygems_version: 3.1.4
186
+ signing_key:
186
187
  specification_version: 4
187
188
  summary: ocean package
188
189
  test_files: []