fast_pack 0.3.1 → 0.3.4

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: 961562f8d95682a46c2f9ad8b8fb086898fd854dc0f54b4a485b12a60c082d0f
4
- data.tar.gz: e1047b517bef568796d2d0b231d2e1d03efccdbacfef316cdf40b320ee92d60b
3
+ metadata.gz: 56b76321cbc99b6332e24ff16d35aa00200a23bccea0288640e97929c9bc4733
4
+ data.tar.gz: 990894a1d13a216970560cef95f4c240552d25b7ed3bf270f3b252862512f915
5
5
  SHA512:
6
- metadata.gz: 5501a5de9d3f5ba309a3f11d5230f573e9546b59d85094c9ec0bbe95e41c15c14dfae7854e8e96710823ba401d5287e3601f229f91e78ced68ac001b604af873
7
- data.tar.gz: c998a9d1a4299be0ea0d7ede83873a5cc8449825608c838a58be26ca84aeae708f01b1b0d39fc739cc34bd9811ca07dfd9796ea0bc85d97c312fd34443c56865
6
+ metadata.gz: f6c15ba3e8418a94201d88bd419e406531e1ff5d8c9df4c7baf7f8472ff6f486df13ecfdf8145ebbb0f86f82a70711cec11c743ef5fa92088ca92cad037b59d9
7
+ data.tar.gz: b068e5065c2122006903ebbd0f427e020f30fa6552bf4a30b7398bba5f222450194edf1145b16654ac694164c7570d19888bc2115d5b81ea031b678814f5eaea
@@ -41,11 +41,15 @@ module Pod
41
41
  uki_config.dsym = @dsym
42
42
  uki_config.release = @release
43
43
  uki_config.no_build = @no_build
44
+ uki_config.build_time = Time.now.to_i
45
+ uki_config.upload_time = 0
44
46
 
45
47
  end
46
48
 
47
49
  def run
48
50
  if verify_workspace_exists?
51
+ shell.export_xcode_env
52
+
49
53
  if uki_config.no_build
50
54
  #直接导出
51
55
  shell.export
@@ -62,7 +66,7 @@ module Pod
62
66
  uki_config.auto_work_space_name
63
67
  unless uki_config.workspace_name
64
68
  puts("大兄弟,请前往xxxx.workspace同级目录执行哦")
65
- return false
69
+ exit
66
70
  end
67
71
 
68
72
  return true
@@ -1,33 +1,70 @@
1
1
  require 'cocoapods-uki-packager/uki_config.rb'
2
2
  require 'cocoapods'
3
+ require 'net/https'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'socket'
7
+
3
8
 
4
9
  class Shell_Command
5
10
 
6
11
  include Uki_config::Mixin
7
12
 
8
- def build
9
-
10
- puts %x{echo "********************************************************* 开始编译"}
11
-
12
- log = %x{
13
+ def export_xcode_env
14
+ puts("********************************************************* 开始导出Xcode环境变量")
15
+
16
+ log = %x{
17
+ rootPath=`pwd`
18
+ fireName="xcode_env.json"
19
+ full_path="${rootPath}/${fireName}"
20
+ if [ -f "$full_path" ]
21
+ then
22
+ echo "存在xcode_env.json"
23
+ else
24
+ echo "不存在xcode_env.json 创建一个"
25
+ touch ${full_path}
26
+ fi
27
+
28
+ if [ -f "$full_path" ]
29
+ then
30
+ echo `xcodebuild -showBuildSettings -json` > "$full_path"
31
+ fi
32
+ }
33
+
34
+ if !File.exist?(uki_config.xcode_env_path)
35
+ puts("当前目录未查找到xcode_env.json文件, 请检查执行目录")
36
+ exit
37
+ end
38
+
39
+ json_from_file = File.read(uki_config.xcode_env_path)
40
+ uki_config.xcode_envs = JSON.parse(json_from_file).first
41
+
42
+ if uki_config.verbose?
43
+ puts(log)
44
+ end
13
45
 
14
- xcodebuild build -workspace #{uki_config.workspace} -scheme #{uki_config.scheme} -destination generic/platform=iOS -configuration #{uki_config.configuration} DEBUG_INFORMATION_FORMAT=#{uki_config.dsym_config} DWARF_DSYM_FOLDER_PATH=#{uki_config.dsym_path}
46
+ end
15
47
 
16
- if [[ $? -ne 0 ]]; then
17
- echo "************************************* 编译失败 *************************************"
18
- exit 1
19
- fi
20
- }
48
+ def build
21
49
 
22
- puts %x{echo "********************************************************* 编译完成"}
50
+ puts("********************************************************* 开始编译")
23
51
 
24
52
  if uki_config.verbose?
25
- # puts(log)
53
+ puts("xcodebuild build -workspace #{uki_config.workspace} -scheme #{uki_config.scheme} -destination generic/platform=iOS -configuration #{uki_config.configuration} DEBUG_INFORMATION_FORMAT=#{uki_config.dsym_config} DWARF_DSYM_FOLDER_PATH=#{uki_config.dsym_path}")
26
54
  end
55
+
56
+ log = %x{
57
+ xcodebuild build -workspace #{uki_config.workspace} -scheme #{uki_config.scheme} -destination generic/platform=iOS -configuration #{uki_config.configuration} DEBUG_INFORMATION_FORMAT=#{uki_config.dsym_config} DWARF_DSYM_FOLDER_PATH=#{uki_config.dsym_path}
58
+ }
27
59
 
28
- # 直接开始导出
29
- self.export
30
-
60
+ if log[/BUILD SUCCEEDED/]
61
+ puts("********************************************************* 编译完成")
62
+ # 直接开始导出
63
+ self.export
64
+ elsif
65
+ puts("********************************************************* 失败")
66
+ exit
67
+ end
31
68
  end
32
69
 
33
70
  # 暂时先不copy到跟目录, 防止Git提交代码时提交上去
@@ -37,7 +74,7 @@ class Shell_Command
37
74
 
38
75
  unless uki_config.build_exe_path
39
76
  puts "未生成目标文件目录"
40
- return
77
+ exit
41
78
  end
42
79
 
43
80
  puts %x{echo "********************************************************* 开始导出ipa"}
@@ -55,9 +92,6 @@ class Shell_Command
55
92
 
56
93
  fir_log="fir auto release"
57
94
 
58
- #计时
59
- SECONDS=0
60
-
61
95
  APP=$(find $product_path -type d | grep ".app$" | head -n 1)
62
96
  APP=${APP%.*}
63
97
 
@@ -70,29 +104,171 @@ class Shell_Command
70
104
  zip -r -q "$APP.ipa" ./Payload;
71
105
  rm -rf ./Payload;
72
106
 
73
- echo "===生成ipa开始上传 time: ${SECONDS}s==="
107
+ # echo "===生成ipa开始上传 ==="
74
108
 
109
+ #计时
110
+ SECONDS=0
75
111
 
76
112
  fir_token="207c7aad886da8009a73486d5154a7a6"
77
- fir publish "$APP.ipa" -T $fir_token -c "$fir_log" -Q -q
113
+ fir publish "$APP.ipa" -T $fir_token -c "$fir_log" -R
78
114
 
79
115
  size=$(ls -l $APP.ipa | awk '{ print $5 }')
80
116
 
81
117
  sizeM=`echo "scale=2; ${size}/1024.0/1024" | bc`
82
118
  #sizeM="$((${size}/1000.0))
83
- echo -e "===size=${sizeM}m==="
119
+
120
+ echo -e "包体积=${sizeM}m\n"
84
121
 
85
122
  notification="Did uploaded to fir caost time:${SECONDS}s"
86
- echo "===$notification==="
123
+ echo "===$notification===%"
87
124
 
88
125
  osascript -e 'display notification "size:'$sizeM'm\ncaost:'$SECONDS's" with title "Uploaded to fir!" sound name "default" '
126
+
127
+ echo "upload_time=${SECONDS}"
89
128
  }
90
129
 
130
+ ipa_size = log[/包体积.*$/].split('=').last
131
+
132
+ url = log[/http:.*$/]
133
+ array = log.split('%')
134
+ uki_config.upload_time = array.last.split("=").last.to_i
135
+ uki_config.build_time = Time.now.to_i - uki_config.build_time - uki_config.upload_time
136
+ uki_config.fir_url = url
137
+ uki_config.ipa_size = ipa_size
138
+
139
+ unless !url.empty?
140
+ puts("导出失败")
141
+ exit
142
+ end
143
+
91
144
  puts("恭喜打包完成")
92
145
 
93
146
  if uki_config.verbose?
94
147
  puts(log)
95
148
  end
149
+
150
+ send_notifi
151
+ end
152
+
153
+ def send_notifi
154
+
155
+ branch = %x{
156
+ if branch=$(git symbolic-ref --short -q HEAD)
157
+ then
158
+ echo $branch
159
+ else
160
+ echo "未知分支"
161
+ fi
162
+ }
163
+
164
+ hostname = Socket.gethostname
165
+ project_name = uki_config.group_name
166
+ project_env = uki_config.release ? "Release": "Debug"
167
+ project_dsym = uki_config.dsym ? "已上传": "无符号表"
168
+
169
+ message = {
170
+ "msg_type": "interactive",
171
+ "card": {
172
+ "elements": [
173
+ {
174
+ "fields": [
175
+ {
176
+ "is_short": true,
177
+ "text": {
178
+ "content": "**打包分支**\n#{branch}",
179
+ "tag": "lark_md"
180
+ }
181
+ },
182
+ {
183
+ "is_short": true,
184
+ "text": {
185
+ "content": "**打包环境**\n#{project_env}",
186
+ "tag": "lark_md"
187
+ }
188
+ },
189
+ {
190
+ "is_short": true,
191
+ "text": {
192
+ "content": "**打包机器**\n#{hostname}",
193
+ "tag": "lark_md"
194
+ }
195
+ },
196
+ {
197
+ "is_short": true,
198
+ "text": {
199
+ "content": "**dsym**\n#{project_dsym}",
200
+ "tag": "lark_md"
201
+ }
202
+ },
203
+ {
204
+ "is_short": true,
205
+ "text": {
206
+ "content": "**App版本**\n#{uki_config.app_version}.#{uki_config.build_version}",
207
+ "tag": "lark_md"
208
+ }
209
+ },
210
+ {
211
+ "is_short": true,
212
+ "text": {
213
+ "content": "**包体积**\n#{uki_config.ipa_size}",
214
+ "tag": "lark_md"
215
+ }
216
+ },
217
+ {
218
+ "is_short": true,
219
+ "text": {
220
+ "content": "**编译耗时**\n#{uki_config.build_time}s",
221
+ "tag": "lark_md"
222
+ }
223
+ },
224
+ {
225
+ "is_short": true,
226
+ "text": {
227
+ "content": "**上传耗时**\n#{uki_config.upload_time}s",
228
+ "tag": "lark_md"
229
+ }
230
+ }
231
+ ],
232
+ "tag": "div"
233
+ },
234
+ {
235
+ "tag": "hr"
236
+ },
237
+ {
238
+ "tag": "action",
239
+ "actions": [
240
+ {
241
+ "tag": "button",
242
+ "text": {
243
+ "tag": "lark_md",
244
+ "content": "点击下载"
245
+ },
246
+ "type": "default",
247
+ "url": "#{uki_config.fir_url}"
248
+ }
249
+ ]
250
+ }
251
+ ],
252
+ "header": {
253
+ "template": "green",
254
+ "title": {
255
+ "content": "#{project_name}",
256
+ "tag": "plain_text"
257
+ }
258
+ }
259
+ }
260
+ }
261
+
262
+ log = %x{
263
+ curl -X POST -H "Content-Type: application/json" -d '#{message.to_json}' "https://open.feishu.cn/open-apis/bot/v2/hook/68c47d38-fc65-4cc5-a386-885a1fbff11b"
264
+ }
265
+
266
+ if uki_config.verbose?
267
+ puts(log)
268
+ end
269
+
270
+ exit
271
+
96
272
  end
97
273
 
98
274
  def self.instance
@@ -4,8 +4,6 @@ class Uki_config
4
4
  # scheme info
5
5
  PROJECT_SCHEME = ['UkiOverseas', 'miaohong'].freeze
6
6
 
7
- # workspace name
8
- PROJECT_WORKSPACENAME = ['UkiOverseas.xcworkspace', 'miaohong.xcworkspace']
9
7
 
10
8
  # 是否展示详细信息
11
9
  attr_accessor :verbose
@@ -17,24 +15,27 @@ class Uki_config
17
15
  attr_accessor :release
18
16
  # 是否产生dsym
19
17
  attr_accessor :dsym
20
- # 自动workspace名称
21
- attr_accessor :workspace_name
18
+ # 自动workspace名称
19
+ attr_accessor :workspace_name
20
+ # 编译耗时
21
+ attr_accessor :build_time
22
+ # 上传耗时
23
+ attr_accessor :upload_time
24
+ # 上传Url
25
+ attr_accessor :fir_url
26
+ # xcode环境变量
27
+ attr_accessor :xcode_envs
28
+ # 包体积
29
+ attr_accessor :ipa_size
22
30
 
23
31
  alias_method :verbose?, :verbose
24
32
 
25
33
  def scheme
26
- unless project_sea
27
- return PROJECT_SCHEME.last
28
- end
29
- return PROJECT_SCHEME.first
34
+ return self.xcode_envs["target"]
30
35
  end
31
36
 
32
37
  def workspace
33
- unless project_sea
34
- return PROJECT_WORKSPACENAME.last
35
- end
36
-
37
- return PROJECT_WORKSPACENAME.first
38
+ return self.workspace_name
38
39
  end
39
40
 
40
41
  def configuration
@@ -83,22 +84,44 @@ class Uki_config
83
84
 
84
85
  Dir.foreach(@installation_root) do |entry|
85
86
  if entry.end_with?('xcworkspace')
86
- @workspace_name = entry.split('.').first
87
+ @workspace_name = entry
87
88
  next
88
89
  end
89
90
  end
90
91
  end
91
92
 
93
+ def app_version
94
+ buildSettings = self.xcode_envs["buildSettings"]
95
+ return buildSettings["MARKETING_VERSION"]
96
+ end
97
+
98
+ def build_version
99
+ buildSettings = self.xcode_envs["buildSettings"]
100
+ return buildSettings["CURRENT_PROJECT_VERSION"]
101
+ end
102
+
92
103
  # 读取产物记录文件
93
104
  def app_file_path
94
105
  return File.join(@installation_root, "app_path")
95
106
  end
96
107
 
97
- # 产物路径
98
- def build_exe_path
108
+ # 产物路径
109
+ def build_exe_path
99
110
  return IO.readlines(app_file_path).first
100
111
  end
101
112
 
113
+ def group_name
114
+ unless @workspace_name == "miaohong.xcworkspace"
115
+ return "iOS海外极速打包完成"
116
+ end
117
+
118
+ return "iOS国内极速打包完成"
119
+ end
120
+
121
+ def xcode_env_path
122
+ return File.join(@installation_root, "xcode_env.json")
123
+ end
124
+
102
125
  def self.instance
103
126
  @instance ||= new
104
127
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Packager
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.4"
5
5
  end
data/lib/packager.rb CHANGED
@@ -0,0 +1,12 @@
1
+
2
+
3
+
4
+
5
+ {"msg_type":"interactive","card":{"elements":[{"fields":[{"is_short":true,"text":{"content":"**打包分支**\nRelease","tag":"lark_md"}},{"is_short":true,"text":{"content":"**打包环境**\nDebug","tag":"lark_md"}},{"is_short":true,"text":{"content":"**打包机器**\nxx的Mac","tag":"lark_md"}},{"is_short":true,"text":{"content":"**dsym**\n无","tag":"lark_md"}},{"is_short":true,"text":{"content":"**编译耗时**\n12s","tag":"lark_md"}},{"is_short":true,"text":{"content":"**上传耗时**\n60s","tag":"lark_md"}}],"tag":"div"},{"tag":"hr"},{"tag":"action","actions":[{"tag":"button","text":{"tag":"lark_md","content":"点击下载"},"type":"default","url":"https://www.baidu.com/"}]}],"header":{"template":"green","title":{"content":"打包已完成","tag":"plain_text"}}}}
6
+ {:msg_type=>"interactive", :card=>{:elements=>[{:fields=>[{:is_short=>true, :text=>{:content=>"**打包分支**\nRelease", :tag=>"lark_md"}}, {:is_short=>true, :text=>{:content=>"**打包环境**\nDebug", :tag=>"lark_md"}}, {:is_short=>true, :text=>{:content=>"**打包机器**\nxx的Mac", :tag=>"lark_md"}}, {:is_short=>true, :text=>{:content=>"**dsym**\n无", :tag=>"lark_md"}}, {:is_short=>true, :text=>{:content=>"**编译耗时**\n12s", :tag=>"lark_md"}}, {:is_short=>true, :text=>{:content=>"**上传耗时**\n60s", :tag=>"lark_md"}}], :tag=>"div"}, {:tag=>"hr"}, {:tag=>"action", :actions=>[{:tag=>"button", :text=>{:tag=>"lark_md", :content=>"点击下载"}, :type=>"default", :url=>"https://www.baidu.com/"}]}], :header=>{:template=>"green", :title=>{:content=>"打包已完成", :tag=>"plain_text"}}}}
7
+
8
+
9
+
10
+ curl -X POST -H "Content-Type: application/json" \
11
+ -d '{"msg_type":"interactive","card":{"elements":[{"fields":[{"is_short":true,"text":{"content":"**打包分支**\nRelease","tag":"lark_md"}},{"is_short":true,"text":{"content":"**打包环境**\nDebug","tag":"lark_md"}},{"is_short":true,"text":{"content":"**打包机器**\nxx的Mac","tag":"lark_md"}},{"is_short":true,"text":{"content":"**dsym**\n无","tag":"lark_md"}},{"is_short":true,"text":{"content":"**编译耗时**\n12s","tag":"lark_md"}},{"is_short":true,"text":{"content":"**上传耗时**\n60s","tag":"lark_md"}}],"tag":"div"},{"tag":"hr"},{"tag":"action","actions":[{"tag":"button","text":{"tag":"lark_md","content":"点击下载"},"type":"default","url":"https://www.baidu.com/"}]}],"header":{"template":"green","title":{"content":"打包已完成","tag":"plain_text"}}}}' \
12
+ https://open.feishu.cn/open-apis/bot/v2/hook/be340a71-08b3-4541-8cc6-2f733dd6f257
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - 耿磊
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods