gct 0.3.92 → 0.4.1
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 +4 -4
- data/lib/gct/command.rb +2 -3
- data/lib/gct/command/autotag.rb +102 -19
- data/lib/gct/command/clean.rb +15 -0
- data/lib/gct/command/clean/cache.rb +26 -0
- data/lib/gct/command/clean/ci.rb +23 -0
- data/lib/gct/command/clean/lint.rb +28 -0
- data/lib/gct/command/init/gitlab-ci.rb +10 -3
- data/lib/gct/command/op.rb +1 -0
- data/lib/gct/command/op/lint.rb +35 -0
- data/lib/gct/command/robot.rb +40 -0
- data/lib/gct/command/robot/finish.rb +18 -22
- data/lib/gct/command/robot/podfile.rb +38 -0
- data/lib/gct/command/robot/start.rb +9 -19
- data/lib/gct/command/setup.rb +9 -0
- data/lib/gct/command/update.rb +4 -1
- data/lib/gct/command/update/analyze.rb +22 -0
- data/lib/gct/command/update/dependency.rb +36 -0
- data/lib/gct/command/update/next.rb +72 -0
- data/lib/gct/command/update/podfile.rb +79 -0
- data/lib/gct/command/update/tag.rb +56 -14
- data/lib/gct/command/update/version.rb +1 -0
- data/lib/gct/constant.rb +4 -0
- data/lib/gct/file_base.rb +90 -0
- data/lib/gct/gct_version.rb +1 -1
- data/lib/gct/generator/gct_file.rb +4 -0
- data/lib/gct/specification.rb +8 -11
- metadata +12 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61f99077edb53ba0cf05eca381a814b9f41a17ecc191cc68a1950c2402dff1b7
|
|
4
|
+
data.tar.gz: 3132fd74ec8fd026ea13921f717e68c8f7bbb4aba1ee1265ba057eef823cd8cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92432f4c66aa5d9a19c27c0c5c22ceb53253ff118e34586934516790134474d3f0c9360ef8dad2b51e8c7cd737d0441e1c019942ff8d4f94d2449d33d109ec19
|
|
7
|
+
data.tar.gz: 83d92ca4f72529e5be6db516fc667bc9dbddc6783e29aa0eaac68f109d91df346545b0c52be5fc14759b2cd03603f86ea8fcd94320e4f6e00ed23f83dd7f569e
|
data/lib/gct/command.rb
CHANGED
|
@@ -27,6 +27,7 @@ module Gct
|
|
|
27
27
|
require 'gct/command/setup'
|
|
28
28
|
require 'gct/command/update'
|
|
29
29
|
require 'gct/command/robot'
|
|
30
|
+
require 'gct/command/clean'
|
|
30
31
|
|
|
31
32
|
self.abstract_command = true
|
|
32
33
|
self.command = 'gct'
|
|
@@ -51,8 +52,6 @@ module Gct
|
|
|
51
52
|
Colored2.disable!
|
|
52
53
|
String.send(:define_method, :colorize) { |string, _| string }
|
|
53
54
|
end
|
|
54
|
-
|
|
55
|
-
config_gitlab
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
def file_contents(project_id, file, branch)
|
|
@@ -62,7 +61,7 @@ module Gct
|
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
def config_gitlab
|
|
65
|
-
if FileBase.exist_root and token
|
|
64
|
+
if FileBase.exist_root and token
|
|
66
65
|
Gitlab.configure do |config|
|
|
67
66
|
config.endpoint = 'https://gi-dev.ccrgt.com/api/v4'
|
|
68
67
|
config.private_token = token
|
data/lib/gct/command/autotag.rb
CHANGED
|
@@ -13,13 +13,18 @@ module Gct
|
|
|
13
13
|
self.arguments = [
|
|
14
14
|
CLAide::Argument.new('PROJECT_ID', true),
|
|
15
15
|
CLAide::Argument.new('BRANCH', true),
|
|
16
|
+
CLAide::Argument.new('VERSION', true),
|
|
16
17
|
]
|
|
17
18
|
|
|
18
19
|
def initialize(argv)
|
|
19
20
|
gitlab_error
|
|
21
|
+
config_gitlab
|
|
20
22
|
@update_ci = argv.flag?('update-ci', false)
|
|
21
|
-
|
|
23
|
+
name = argv.shift_argument
|
|
24
|
+
@project_id = "ios/#{name}"
|
|
25
|
+
@project_name = name
|
|
22
26
|
@branch = argv.shift_argument
|
|
27
|
+
@version = argv.shift_argument
|
|
23
28
|
@file = 'Podfile'
|
|
24
29
|
super
|
|
25
30
|
end
|
|
@@ -34,11 +39,25 @@ module Gct
|
|
|
34
39
|
super
|
|
35
40
|
help! '请输入项目名.' unless @project_id
|
|
36
41
|
help! '请输入分支名.' unless @branch
|
|
42
|
+
help! '请输入版本号.' unless @version
|
|
37
43
|
end
|
|
38
44
|
|
|
39
45
|
def run
|
|
40
46
|
FileBase.root_err
|
|
41
|
-
|
|
47
|
+
puts "开始分析podfile文件".green
|
|
48
|
+
puts ""
|
|
49
|
+
FileBase.write_version_message(@version, @project_name, @branch)
|
|
50
|
+
exist_dep = FileBase.exist_dependency
|
|
51
|
+
if exist_dep
|
|
52
|
+
tmp_podspecs
|
|
53
|
+
priority_map = FileBase.yaml_dependency_read
|
|
54
|
+
create_tag_by_priority(priority_map)
|
|
55
|
+
else
|
|
56
|
+
untagged_specs = analyze_dependencies
|
|
57
|
+
priority_map = priority_rank(untagged_specs)
|
|
58
|
+
generate_dependency_file(priority_map)
|
|
59
|
+
create_tag_by_priority(priority_map)
|
|
60
|
+
end
|
|
42
61
|
end
|
|
43
62
|
|
|
44
63
|
def check_branch(branch)
|
|
@@ -48,10 +67,10 @@ module Gct
|
|
|
48
67
|
|
|
49
68
|
def podfile
|
|
50
69
|
# if check_branch_can_be_update('zeus')
|
|
51
|
-
if check_branch('ft/tag') # TODO: Test branch
|
|
70
|
+
# if check_branch('ft/tag') # TODO: Test branch
|
|
52
71
|
contents = file_contents(@project_id, @file, @branch)
|
|
72
|
+
# puts contents
|
|
53
73
|
contents.force_encoding('UTF-8')
|
|
54
|
-
puts contents
|
|
55
74
|
temp_local_file = TempLocalFile.new(contents, @file)
|
|
56
75
|
temp_local_file.write
|
|
57
76
|
full_path = temp_local_file.full_path
|
|
@@ -60,25 +79,30 @@ module Gct
|
|
|
60
79
|
podfile = Pod::Podfile.from_ruby(full_path, contents)
|
|
61
80
|
podfile
|
|
62
81
|
end
|
|
63
|
-
end
|
|
82
|
+
# end
|
|
64
83
|
end
|
|
65
84
|
|
|
66
|
-
def
|
|
85
|
+
def tmp_podspecs
|
|
67
86
|
untagged_git_dependencies = podfile.dependencies.select { |dependency| dependency.external? && dependency.external_source[:tag].nil? && dependency.external_source[:branch] == Constant.DefaultTagBranch}
|
|
68
87
|
|
|
69
|
-
|
|
88
|
+
spec_files = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
|
|
70
89
|
file_name = "#{dep.name}.podspec"
|
|
71
90
|
podspec_contents = file_contents("#{Constant.NameSpace}#{dep.name}", file_name, Constant.DefaultTagBranch)
|
|
72
91
|
temp_local_spec_file = TempLocalFile.new(podspec_contents, file_name)
|
|
73
92
|
temp_local_spec_file.write
|
|
74
|
-
|
|
93
|
+
temp_local_spec_file.full_path
|
|
94
|
+
end
|
|
95
|
+
spec_files
|
|
96
|
+
end
|
|
75
97
|
|
|
98
|
+
def analyze_dependencies
|
|
99
|
+
untagged_specs = tmp_podspecs.map do |spec_file|
|
|
76
100
|
# 创建podspec对象
|
|
77
101
|
spec = Pod::Specification.from_file(spec_file)
|
|
78
102
|
gct_spec = Specification.new()
|
|
79
103
|
gct_spec.name = spec.name
|
|
80
104
|
gct_spec.priority = 1000
|
|
81
|
-
gct_spec.status = SpecPublishStatus::
|
|
105
|
+
gct_spec.status = SpecPublishStatus::WAITING
|
|
82
106
|
gct_spec.tag = "0"
|
|
83
107
|
dependencySpecs = Array.new()
|
|
84
108
|
if spec.subspecs.length == 0
|
|
@@ -86,7 +110,7 @@ module Gct
|
|
|
86
110
|
sub_spec = Specification.new()
|
|
87
111
|
sub_spec.name = dep.root_name
|
|
88
112
|
sub_spec.priority = 1000
|
|
89
|
-
sub_spec.status = SpecPublishStatus::
|
|
113
|
+
sub_spec.status = SpecPublishStatus::WAITING
|
|
90
114
|
sub_spec.tag = "0"
|
|
91
115
|
sub_spec
|
|
92
116
|
end
|
|
@@ -97,7 +121,7 @@ module Gct
|
|
|
97
121
|
sub_spec = Specification.new()
|
|
98
122
|
sub_spec.name = dep.root_name
|
|
99
123
|
sub_spec.priority = 1000
|
|
100
|
-
sub_spec.status = SpecPublishStatus::
|
|
124
|
+
sub_spec.status = SpecPublishStatus::WAITING
|
|
101
125
|
sub_spec.tag = "0"
|
|
102
126
|
sub_spec
|
|
103
127
|
end
|
|
@@ -108,8 +132,7 @@ module Gct
|
|
|
108
132
|
gct_spec.dependencySpecs = dependencySpecs
|
|
109
133
|
gct_spec
|
|
110
134
|
end
|
|
111
|
-
|
|
112
|
-
priority_rank(untagged_specs)
|
|
135
|
+
untagged_specs
|
|
113
136
|
end
|
|
114
137
|
|
|
115
138
|
def eqlBetweenHash(hash1, hash2)
|
|
@@ -133,12 +156,10 @@ module Gct
|
|
|
133
156
|
temp_spec_map[spec.name] = spec
|
|
134
157
|
end
|
|
135
158
|
temp_spec_map_copy = Hash.new()
|
|
136
|
-
count = 1
|
|
137
159
|
|
|
138
160
|
while !(eqlBetweenHash(temp_spec_map, temp_spec_map_copy)) do
|
|
139
161
|
# 深拷贝
|
|
140
162
|
temp_spec_map_copy = Marshal.load(Marshal.dump(temp_spec_map))
|
|
141
|
-
puts "--- times == #{count} ---"
|
|
142
163
|
specs.map do |spec|
|
|
143
164
|
temp_spec = temp_spec_map[spec.name]
|
|
144
165
|
spec.dependencySpecs.map do |subspec|
|
|
@@ -150,11 +171,73 @@ module Gct
|
|
|
150
171
|
end
|
|
151
172
|
end
|
|
152
173
|
end
|
|
153
|
-
count += 1
|
|
154
|
-
temp_spec_map.each { |key, value|
|
|
155
|
-
puts "#{key} => #{value.priority}"
|
|
156
|
-
}
|
|
157
174
|
end
|
|
175
|
+
dependency_map = Hash.new()
|
|
176
|
+
priority_map = Hash.new()
|
|
177
|
+
temp_spec_map.each do |key, value|
|
|
178
|
+
dependency_map[key] = {"priority" => value.priority, "tag" => value.tag, "status" => value.status}
|
|
179
|
+
end
|
|
180
|
+
priority = 1000
|
|
181
|
+
while priority <= 1000 do
|
|
182
|
+
tmp_hash = Hash.new()
|
|
183
|
+
dependency_map.each do |key, value|
|
|
184
|
+
if (value["priority"] == priority)
|
|
185
|
+
tmp_hash.store(key, {"tag" => value["tag"], "status" => value["status"]})
|
|
186
|
+
dependency_map.delete(value)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
if (tmp_hash.keys.count == 0)
|
|
190
|
+
priority = 1001
|
|
191
|
+
else
|
|
192
|
+
priority_map[priority.to_s] = tmp_hash
|
|
193
|
+
priority -= 1
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
priority_map
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def generate_dependency_file(priority_map)
|
|
200
|
+
yaml_path = "#{Generator::GctFile.temp_folder_path}/#{Constant.DependencyName}"
|
|
201
|
+
FileBase.yaml_write_map(yaml_path, priority_map)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# 按优先级打tag, 触发第一个优先级,其他的上一优先级打完之后自动触发
|
|
205
|
+
def create_tag_by_priority(priority_map)
|
|
206
|
+
priority = get_current_need_tag_priority
|
|
207
|
+
puts "priority is #{priority}"
|
|
208
|
+
value = priority_map[priority.to_s]
|
|
209
|
+
raise "没有需要打tag的库".red if value.keys.count == 0
|
|
210
|
+
value.each do |key, val|
|
|
211
|
+
if val["status"].eql?(SpecPublishStatus::WAITING) || val["status"].eql?(SpecPublishStatus::CANCELED) || val["status"].eql?(SpecPublishStatus::FAILED)
|
|
212
|
+
is_skip = val["status"].eql?(SpecPublishStatus::FAILED) || val["status"].eql?(SpecPublishStatus::CANCELED)
|
|
213
|
+
status = SpecPublishStatus::PENDING
|
|
214
|
+
val["status"] = status
|
|
215
|
+
system "gct update dependency #{key} status #{status}"
|
|
216
|
+
puts "gct update tag #{key} --auto-tag #{is_skip ? "--skip-tag" : ""}"
|
|
217
|
+
system "gct update tag #{key} --auto-tag --update-ci #{is_skip ? "--skip-tag" : ""}"
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# 当前优先级是否已打完
|
|
223
|
+
def get_current_need_tag_priority
|
|
224
|
+
priority = 1000
|
|
225
|
+
content_map = FileBase.yaml_dependency_read
|
|
226
|
+
priority_map = content_map[priority.to_s]
|
|
227
|
+
is_all_done = true
|
|
228
|
+
while is_all_done do
|
|
229
|
+
priority_map.each do |k, v|
|
|
230
|
+
if !v["status"].eql?(SpecPublishStatus::SUCCESS)
|
|
231
|
+
is_all_done = false
|
|
232
|
+
break
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
if is_all_done
|
|
236
|
+
priority -= 1
|
|
237
|
+
priority_map = content_map[priority.to_s]
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
priority
|
|
158
241
|
end
|
|
159
242
|
end
|
|
160
243
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'gct/command/clean/cache'
|
|
2
|
+
require 'gct/command/clean/ci'
|
|
3
|
+
require 'gct/command/clean/lint'
|
|
4
|
+
|
|
5
|
+
module Gct
|
|
6
|
+
class Command
|
|
7
|
+
class Clean < Command
|
|
8
|
+
self.abstract_command = true
|
|
9
|
+
self.summary = '清理缓存的相关操作'
|
|
10
|
+
self.description = <<-DESC
|
|
11
|
+
清理lint缓存,Xcode build缓存,ci build 缓存
|
|
12
|
+
DESC
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Clean < Command
|
|
4
|
+
class Cache < Clean
|
|
5
|
+
|
|
6
|
+
self.summary = '清理Xcode build缓存'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
清理Xcode build缓存
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
def initialize(argv)
|
|
12
|
+
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run
|
|
17
|
+
home_path = Generator::GctFile.get_system_home_path().rstrip
|
|
18
|
+
xcache_path = "#{home_path}/Library/Developer/Xcode/DerivedData/"
|
|
19
|
+
`rm -rf #{xcache_path}`
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Clean < Command
|
|
4
|
+
class Ci < Clean
|
|
5
|
+
|
|
6
|
+
self.summary = '清除ci缓存'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
清除ci缓存,默认清除所有
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
self.arguments = [
|
|
12
|
+
CLAide::Argument.new('POD_NAME', false),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
def initialize(argv)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Clean < Command
|
|
4
|
+
class Lint < Clean
|
|
5
|
+
|
|
6
|
+
self.summary = '清除lint缓存'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
清除lint缓存,默认清除所有
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
self.arguments = [
|
|
12
|
+
CLAide::Argument.new('POD_NAME', false),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
def initialize(argv)
|
|
16
|
+
@pod_name = argv.shift_argument
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
home_path = Generator::GctFile.get_system_home_path().rstrip
|
|
22
|
+
lintcahce_path = "#{home_path}/Library/Caches/CocoaPods/Pods/External/#{@pod_name}"
|
|
23
|
+
`rm -rf #{lintcahce_path}`
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -5,11 +5,15 @@ stages:
|
|
|
5
5
|
push_pod:
|
|
6
6
|
stage: push
|
|
7
7
|
script:
|
|
8
|
-
- gct robot start
|
|
8
|
+
- gct robot start --test
|
|
9
9
|
- echo "开始lint 和 push podspec"
|
|
10
|
+
- gct update dependency $CI_PROJECT_NAME "status" "deploying"
|
|
11
|
+
- gct clean lint $CI_PROJECT_NAME
|
|
10
12
|
- gct repo update
|
|
11
13
|
- gct repo push
|
|
12
|
-
- gct robot finish true
|
|
14
|
+
- gct robot finish true --test
|
|
15
|
+
- gct update dependency $CI_PROJECT_NAME "tag" $CI_COMMIT_REF_NAME
|
|
16
|
+
- gct update next
|
|
13
17
|
only:
|
|
14
18
|
- tags
|
|
15
19
|
tags:
|
|
@@ -18,7 +22,10 @@ push_pod:
|
|
|
18
22
|
on_failure:
|
|
19
23
|
stage: failure
|
|
20
24
|
script:
|
|
21
|
-
- gct robot finish false
|
|
25
|
+
- gct robot finish false --test
|
|
26
|
+
- gct update dependency $CI_PROJECT_NAME "status" "failed"
|
|
22
27
|
when: on_failure
|
|
28
|
+
only:
|
|
29
|
+
- tags
|
|
23
30
|
tags:
|
|
24
31
|
- iOS
|
data/lib/gct/command/op.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Op < Command
|
|
4
|
+
class Lint < Op
|
|
5
|
+
|
|
6
|
+
self.summary = '打开lint 缓存文件夹'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
打开lint 缓存文件夹
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
self.arguments = [
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
def initialize(argv)
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def validate!
|
|
19
|
+
super
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def run
|
|
23
|
+
openLintCache
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def openLintCache
|
|
27
|
+
lintCache = '~/Library/Caches/CocoaPods/Pods/External/'
|
|
28
|
+
puts "Xcode缓存路径为:#{lintCache}".green
|
|
29
|
+
system "open #{lintCache}"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
data/lib/gct/command/robot.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
require 'gct/command/robot/start'
|
|
2
2
|
require 'gct/command/robot/finish'
|
|
3
|
+
require 'gct/command/robot/podfile'
|
|
4
|
+
require 'net/https'
|
|
5
|
+
require 'json'
|
|
3
6
|
|
|
4
7
|
module Gct
|
|
5
8
|
class Command
|
|
@@ -9,6 +12,43 @@ module Gct
|
|
|
9
12
|
self.description = <<-DESC
|
|
10
13
|
发送jenkins和gitlab机器人消息
|
|
11
14
|
DESC
|
|
15
|
+
|
|
16
|
+
def self.options
|
|
17
|
+
[
|
|
18
|
+
['--test', '测试机器人,测试webhook'],
|
|
19
|
+
].concat(super)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize(argv)
|
|
23
|
+
@test = argv.flag?('test', false)
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def robot_send(content)
|
|
28
|
+
if @test
|
|
29
|
+
webhook = FileBase.get_config("gitlab-robot-webhook-test")
|
|
30
|
+
else
|
|
31
|
+
webhook = FileBase.get_config("gitlab-robot-webhook")
|
|
32
|
+
end
|
|
33
|
+
raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
|
|
34
|
+
url = URI(webhook)
|
|
35
|
+
|
|
36
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
37
|
+
if url.scheme == "https"
|
|
38
|
+
http.use_ssl = true
|
|
39
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
data = {
|
|
43
|
+
"msgtype": "markdown",
|
|
44
|
+
"markdown": {
|
|
45
|
+
"content": "#{content}"
|
|
46
|
+
}
|
|
47
|
+
}.to_json
|
|
48
|
+
|
|
49
|
+
header = {'content-type':'application/json'}
|
|
50
|
+
response = http.post(url, data, header)
|
|
51
|
+
end
|
|
12
52
|
end
|
|
13
53
|
end
|
|
14
54
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
require 'json'
|
|
1
|
+
|
|
3
2
|
|
|
4
3
|
module Gct
|
|
5
4
|
class Command
|
|
@@ -15,6 +14,12 @@ module Gct
|
|
|
15
14
|
CLAide::Argument.new('BUILD_STATUS', true),
|
|
16
15
|
]
|
|
17
16
|
|
|
17
|
+
def self.options
|
|
18
|
+
[
|
|
19
|
+
['--test', '测试机器人,测试webhook'],
|
|
20
|
+
].concat(super)
|
|
21
|
+
end
|
|
22
|
+
|
|
18
23
|
def initialize(argv)
|
|
19
24
|
@project_name = ENV['CI_PROJECT_NAME']
|
|
20
25
|
@user_name = ENV['GITLAB_USER_NAME']
|
|
@@ -22,31 +27,22 @@ module Gct
|
|
|
22
27
|
@build_status = argv.shift_argument
|
|
23
28
|
@commit_sha = ENV['CI_COMMIT_SHA']
|
|
24
29
|
@ci_url = ENV['CI_PIPELINE_URL']
|
|
30
|
+
@test = argv.flag?('test', false)
|
|
25
31
|
super
|
|
26
32
|
end
|
|
27
33
|
|
|
28
34
|
def run
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
http = Net::HTTP.new(url.host, url.port)
|
|
36
|
-
if url.scheme == "https"
|
|
37
|
-
http.use_ssl = true
|
|
38
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
35
|
+
puts @build_status.class
|
|
36
|
+
puts "build_status == #{@build_status}"
|
|
37
|
+
if @build_status.eql?("false")
|
|
38
|
+
build_text = "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
|
|
39
|
+
elsif @build_status.eql?("true")
|
|
40
|
+
build_text = "<font color=\"info\">CI运行成功</font>"
|
|
39
41
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"content": "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
|
|
45
|
-
}
|
|
46
|
-
}.to_json
|
|
47
|
-
|
|
48
|
-
header = {'content-type':'application/json'}
|
|
49
|
-
response = http.post(url, data, header)
|
|
42
|
+
ci_text = "[点击跳转](#{@ci_url})"
|
|
43
|
+
|
|
44
|
+
content = "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
|
|
45
|
+
robot_send(content)
|
|
50
46
|
end
|
|
51
47
|
end
|
|
52
48
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'net/https'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module Gct
|
|
5
|
+
class Command
|
|
6
|
+
class Robot < Command
|
|
7
|
+
class Podfile < Robot
|
|
8
|
+
|
|
9
|
+
self.summary = 'podfile更新通知'
|
|
10
|
+
self.description = <<-DESC
|
|
11
|
+
podfile更新通知
|
|
12
|
+
DESC
|
|
13
|
+
|
|
14
|
+
self.arguments = [
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
def self.options
|
|
18
|
+
[
|
|
19
|
+
['--test', '测试机器人,测试webhook'],
|
|
20
|
+
].concat(super)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initialize(argv)
|
|
24
|
+
@project_name = ENV['CI_PROJECT_NAME']
|
|
25
|
+
@tag = ENV['CI_COMMIT_REF_NAME']
|
|
26
|
+
@test = argv.flag?('test', false)
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run
|
|
31
|
+
message = " <font color=\"info\">podfile 更新完毕</font>"
|
|
32
|
+
content = "#{message}"
|
|
33
|
+
robot_send(content)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -14,33 +14,23 @@ module Gct
|
|
|
14
14
|
self.arguments = [
|
|
15
15
|
]
|
|
16
16
|
|
|
17
|
+
def self.options
|
|
18
|
+
[
|
|
19
|
+
['--test', '测试机器人,测试webhook'],
|
|
20
|
+
].concat(super)
|
|
21
|
+
end
|
|
22
|
+
|
|
17
23
|
def initialize(argv)
|
|
18
24
|
@project_name = ENV['CI_PROJECT_NAME']
|
|
19
25
|
@tag = ENV['CI_COMMIT_REF_NAME']
|
|
26
|
+
@test = argv.flag?('test', false)
|
|
20
27
|
super
|
|
21
28
|
end
|
|
22
29
|
|
|
23
30
|
def run
|
|
24
|
-
webhook = FileBase.get_config("gitlab-robot-webhook")
|
|
25
|
-
raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
|
|
26
|
-
url = URI(webhook)
|
|
27
|
-
|
|
28
|
-
http = Net::HTTP.new(url.host, url.port)
|
|
29
|
-
if url.scheme == "https"
|
|
30
|
-
http.use_ssl = true
|
|
31
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
32
|
-
end
|
|
33
|
-
|
|
34
31
|
message = " <font color=\"info\">#{@tag}</font> 开始打tag"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"markdown": {
|
|
38
|
-
"content": "**#{@project_name}** #{message}"
|
|
39
|
-
}
|
|
40
|
-
}.to_json
|
|
41
|
-
|
|
42
|
-
header = {'content-type':'application/json'}
|
|
43
|
-
response = http.post(url, data, header)
|
|
32
|
+
content = "**#{@project_name}** #{message}"
|
|
33
|
+
robot_send(content)
|
|
44
34
|
end
|
|
45
35
|
end
|
|
46
36
|
end
|
data/lib/gct/command/setup.rb
CHANGED
|
@@ -15,9 +15,18 @@ module Gct
|
|
|
15
15
|
create_root_folder
|
|
16
16
|
create_temp_folder
|
|
17
17
|
create_config_file
|
|
18
|
+
create_backup_folder
|
|
18
19
|
puts "setup success!".green
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
def create_backup_folder
|
|
23
|
+
backup_path = Generator::GctFile.backup_folder_path
|
|
24
|
+
if !File.exist?(backup_path)
|
|
25
|
+
system "mkdir #{backup_path}", exception: true
|
|
26
|
+
puts "#{backup_path} 创建成功!".green
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
def create_root_folder
|
|
22
31
|
gct_path = Generator::GctFile.root_folder_path
|
|
23
32
|
if !File.exist?(gct_path)
|
data/lib/gct/command/update.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Update < Command
|
|
4
|
+
class Analyze < Update
|
|
5
|
+
self.summary = '编译'
|
|
6
|
+
self.description = <<-DESC
|
|
7
|
+
下一个优先级打tag
|
|
8
|
+
DESC
|
|
9
|
+
|
|
10
|
+
def initialize(argv)
|
|
11
|
+
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Update < Command
|
|
4
|
+
class Dependency < Update
|
|
5
|
+
|
|
6
|
+
self.summary = '更新依赖文件'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
更新依赖文件
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
self.arguments = [
|
|
12
|
+
# CLAide::Argument.new('PRIORITY', false),
|
|
13
|
+
CLAide::Argument.new('POD_NAME', false),
|
|
14
|
+
CLAide::Argument.new('KEY', false),
|
|
15
|
+
CLAide::Argument.new('VALUE', false),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
def initialize(argv)
|
|
19
|
+
# @priority = argv.shift_argument
|
|
20
|
+
@pod_name = argv.shift_argument
|
|
21
|
+
@key = argv.shift_argument
|
|
22
|
+
@value = argv.shift_argument
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def validate!
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run
|
|
31
|
+
FileBase.yaml_dependency_update(@pod_name, @key, @value)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Update < Command
|
|
4
|
+
class Next < Update
|
|
5
|
+
self.summary = '编译'
|
|
6
|
+
self.description = <<-DESC
|
|
7
|
+
下一个优先级打tag
|
|
8
|
+
DESC
|
|
9
|
+
|
|
10
|
+
def initialize(argv)
|
|
11
|
+
config_gitlab
|
|
12
|
+
@project_name = ENV['CI_PROJECT_NAME']
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run
|
|
17
|
+
batch_tag
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def batch_tag
|
|
21
|
+
specs = next_specs
|
|
22
|
+
if specs.nil?
|
|
23
|
+
return
|
|
24
|
+
end
|
|
25
|
+
if specs.keys.count == 0
|
|
26
|
+
puts "tag已全部打完!!!".green
|
|
27
|
+
# 执行更新podfile的操作
|
|
28
|
+
system "gct update podfile"
|
|
29
|
+
else
|
|
30
|
+
specs.each do |key, val|
|
|
31
|
+
if val["status"].eql?(SpecPublishStatus::WAITING) || val["status"].eql?(SpecPublishStatus::CANCELED) || val["status"].eql?(SpecPublishStatus::FAILED)
|
|
32
|
+
status = SpecPublishStatus::PENDING
|
|
33
|
+
val["status"] = status
|
|
34
|
+
system "gct update dependency #{key} status #{status}"
|
|
35
|
+
system "gct update tag #{key} --auto-tag --update-ci"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def next_specs
|
|
42
|
+
content_map = FileBase.yaml_dependency_read
|
|
43
|
+
if content_map.nil?
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
priority = 1000
|
|
47
|
+
content_map.each do |k, v|
|
|
48
|
+
if v.keys.include?(@project_name)
|
|
49
|
+
priority = k
|
|
50
|
+
break
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
priority_map = content_map[priority.to_s]
|
|
55
|
+
is_all_done = true
|
|
56
|
+
priority_map.each do |k, v|
|
|
57
|
+
if !v["status"].eql?(SpecPublishStatus::SUCCESS)
|
|
58
|
+
is_all_done = false
|
|
59
|
+
break
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if is_all_done
|
|
64
|
+
content_map[(priority.to_i - 1).to_s]
|
|
65
|
+
else
|
|
66
|
+
nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module Gct
|
|
2
|
+
class Command
|
|
3
|
+
class Update < Command
|
|
4
|
+
class Podfile < Update
|
|
5
|
+
|
|
6
|
+
self.summary = '更新podfile文件'
|
|
7
|
+
self.description = <<-DESC
|
|
8
|
+
更新podfile文件
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
self.arguments = [
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
def initialize(argv)
|
|
15
|
+
config_gitlab
|
|
16
|
+
@version = argv.shift_argument
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def validate!
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run
|
|
25
|
+
version_map = FileBase.read_version
|
|
26
|
+
@name = "ios/#{version_map["name"]}"
|
|
27
|
+
@branch = version_map["branch"]
|
|
28
|
+
@verison = version_map["version"]
|
|
29
|
+
@file = "Podfile"
|
|
30
|
+
puts @version
|
|
31
|
+
update_podfile
|
|
32
|
+
remove_and_backup
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update_podfile
|
|
36
|
+
podspec_content = file_contents(@name, @file, @branch)
|
|
37
|
+
|
|
38
|
+
remove_regex = /dev_pod .*/
|
|
39
|
+
podspec_content = podspec_content.gsub!(remove_regex, "")
|
|
40
|
+
|
|
41
|
+
# dependency
|
|
42
|
+
dependency_map = FileBase.yaml_dependency_read
|
|
43
|
+
dependencies = Array.new()
|
|
44
|
+
dependency_map.each do |k, v|
|
|
45
|
+
dependencies << v
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
dependencies.each { |dep|
|
|
49
|
+
dep.keys.each { |k|
|
|
50
|
+
value = dep[k]
|
|
51
|
+
tag = value["tag"]
|
|
52
|
+
update_regex = /.*#{k}.*/
|
|
53
|
+
update_match = update_regex.match(podspec_content).to_s
|
|
54
|
+
podspec_content = podspec_content.gsub!(update_match, " pod '#{k}', '#{tag}'")
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
edit_file(podspec_content)
|
|
59
|
+
system "gct robot podfile"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def edit_file(content)
|
|
63
|
+
Gitlab.edit_file(@name, @file, @branch, content, "@config #{@version}版本 podfile更新")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# 删除和备份
|
|
67
|
+
def remove_and_backup
|
|
68
|
+
d_name = Constant.DependencyName
|
|
69
|
+
Dir.chdir(FileBase.tmp_path) do
|
|
70
|
+
# 备份dependency文件到backup文件夹下
|
|
71
|
+
system "cp #{d_name} ../backup/#{d_name}-#{@version}"
|
|
72
|
+
# 删除tmp文件夹下所有文件
|
|
73
|
+
system "rm -rf *"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -17,21 +17,26 @@ module Gct
|
|
|
17
17
|
[
|
|
18
18
|
['--skip-tag', '是否忽略tag,直接触发ci'],
|
|
19
19
|
['--update-ci', '是否更新CI'],
|
|
20
|
+
['--auto-tag', '自动化'],
|
|
20
21
|
].concat(super)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def initialize(argv)
|
|
25
|
+
config_gitlab
|
|
24
26
|
@update_version_branch = 'develop'
|
|
25
27
|
@skip_tag = argv.flag?('skip-tag', false)
|
|
26
28
|
@update_ci = argv.flag?('update-ci', false)
|
|
27
|
-
@
|
|
28
|
-
name = argv.shift_argument
|
|
29
|
-
@name = name.nil? ? @spec.name : name
|
|
29
|
+
@auto_tag = argv.flag?('auto-tag', false)
|
|
30
|
+
@name = argv.shift_argument
|
|
30
31
|
@tag = argv.shift_argument
|
|
32
|
+
@file = get_spec_file
|
|
33
|
+
if @name.nil?
|
|
34
|
+
@name = @spec.name
|
|
35
|
+
end
|
|
31
36
|
@project_id = "#{Constant.NameSpace}#{@name}"
|
|
32
37
|
super
|
|
33
38
|
end
|
|
34
|
-
|
|
39
|
+
|
|
35
40
|
def run
|
|
36
41
|
update_ci_method if @update_ci
|
|
37
42
|
if @skip_tag
|
|
@@ -44,8 +49,22 @@ module Gct
|
|
|
44
49
|
def skip_tag_method
|
|
45
50
|
@new_tag = @spec.version
|
|
46
51
|
puts "tag == #{@new_tag}"
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
if !@update_ci
|
|
53
|
+
isEmptyMR = mr_to_master
|
|
54
|
+
if !isEmptyMR
|
|
55
|
+
accept_merge_request
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
# remove tag
|
|
59
|
+
command = `git rev-parse --is-inside-work-tree`
|
|
60
|
+
if command.eql?("true")
|
|
61
|
+
`git tag -d #{@new_tag}`
|
|
62
|
+
`git push origin :refs/tags/#{@new_tag}`
|
|
63
|
+
else
|
|
64
|
+
remove_tag
|
|
65
|
+
end
|
|
66
|
+
# create tag
|
|
67
|
+
create_tag
|
|
49
68
|
end
|
|
50
69
|
|
|
51
70
|
def update_ci_method
|
|
@@ -54,16 +73,29 @@ module Gct
|
|
|
54
73
|
path = File.expand_path("../../init", __FILE__)
|
|
55
74
|
ci_content = temp_local_file.read_path_file(path, "gitlab-ci.rb")
|
|
56
75
|
edit_file('.gitlab-ci.yml', ci_content, 'update ci')
|
|
57
|
-
mr_to_master
|
|
58
|
-
|
|
76
|
+
isEmptyMR = mr_to_master
|
|
77
|
+
if !isEmptyMR
|
|
78
|
+
accept_merge_request
|
|
79
|
+
end
|
|
59
80
|
end
|
|
60
81
|
|
|
61
82
|
def get_spec_file
|
|
83
|
+
spec_file = nil
|
|
84
|
+
full_path = nil
|
|
85
|
+
if @auto_tag
|
|
86
|
+
raise "podspec名不能为空!!!".red if spec_file.nil? if @name.nil?
|
|
87
|
+
Dir.chdir(FileBase.tmp_path) do
|
|
88
|
+
spec_file = Pathname.glob("#{@name}.podspec").first
|
|
89
|
+
full_path = spec_file.realpath
|
|
90
|
+
raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
|
|
91
|
+
end
|
|
92
|
+
else
|
|
62
93
|
spec_file = Pathname.glob('*.podspec').first
|
|
94
|
+
full_path = spec_file
|
|
63
95
|
raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
end
|
|
97
|
+
@spec = Pod::Specification.from_file(full_path)
|
|
98
|
+
spec_file
|
|
67
99
|
end
|
|
68
100
|
|
|
69
101
|
def update_podspec_version
|
|
@@ -90,12 +122,18 @@ module Gct
|
|
|
90
122
|
|
|
91
123
|
def mr_to_master
|
|
92
124
|
puts "正在创建MR请求将develop分支合并到master!".green
|
|
93
|
-
mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "
|
|
125
|
+
mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "mr", { source_branch: "#{@update_version_branch}", target_branch: 'master' })
|
|
126
|
+
# puts mr.to_hash
|
|
94
127
|
@id = mr.iid
|
|
95
128
|
puts mr.merge_status
|
|
96
|
-
|
|
129
|
+
isEmptyMR = mr.diff_refs.base_sha.eql?(mr.diff_refs.head_sha)
|
|
130
|
+
# puts mr.diff_refs.base_sha
|
|
131
|
+
# puts mr.diff_refs.head_sha
|
|
132
|
+
close_mr if isEmptyMR
|
|
133
|
+
if mr.merge_status == 'cannot_be_merged' && !isEmptyMR
|
|
97
134
|
raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{Constant.NameSpace}#{@name}/merge_requests/#{@id} 解决".red
|
|
98
135
|
end
|
|
136
|
+
isEmptyMR
|
|
99
137
|
end
|
|
100
138
|
|
|
101
139
|
def accept_merge_request
|
|
@@ -105,7 +143,11 @@ module Gct
|
|
|
105
143
|
end
|
|
106
144
|
end
|
|
107
145
|
|
|
108
|
-
def
|
|
146
|
+
def close_mr
|
|
147
|
+
Gitlab.update_merge_request("#{@project_id}", @id, {state_event: 'close'})
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def remove_tag
|
|
109
151
|
Gitlab.delete_tag("#{@project_id}", "#{@new_tag}")
|
|
110
152
|
end
|
|
111
153
|
|
data/lib/gct/constant.rb
CHANGED
data/lib/gct/file_base.rb
CHANGED
|
@@ -7,6 +7,57 @@ module Gct
|
|
|
7
7
|
@path = path
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
def read_version
|
|
11
|
+
path = version_path
|
|
12
|
+
if !File.exist?(path)
|
|
13
|
+
return nil
|
|
14
|
+
end
|
|
15
|
+
config_map = YAML.load(File.open(path, "r"))
|
|
16
|
+
config_map
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def write_version_message(verison, name, branch)
|
|
20
|
+
yaml_path = "#{Generator::GctFile.temp_folder_path}/version"
|
|
21
|
+
content_map = {"version" => verison, "name" => name, "branch" => branch}
|
|
22
|
+
yaml_write_map(yaml_path, content_map)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def yaml_dependency_read
|
|
26
|
+
path = dependency_path
|
|
27
|
+
if !File.exist?(path)
|
|
28
|
+
return nil
|
|
29
|
+
end
|
|
30
|
+
config_map = YAML.load(File.open(path, "r"))
|
|
31
|
+
config_map
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def yaml_dependency_update(pod_name, key, value)
|
|
35
|
+
path = dependency_path
|
|
36
|
+
if !File.exist?(dependency_path)
|
|
37
|
+
return
|
|
38
|
+
end
|
|
39
|
+
begin
|
|
40
|
+
config_map = YAML.load(File.open(path, "r"))
|
|
41
|
+
config_map = Hash.new() if !config_map
|
|
42
|
+
config_map.each do |k, v|
|
|
43
|
+
v.each do |sk, sv|
|
|
44
|
+
if sk.eql?(pod_name)
|
|
45
|
+
sv[key] = value
|
|
46
|
+
if key.eql?("tag")
|
|
47
|
+
sv["status"] = SpecPublishStatus::SUCCESS
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
yaml_file = File.open(path, "w")
|
|
53
|
+
YAML::dump(config_map, yaml_file)
|
|
54
|
+
rescue IOError => e
|
|
55
|
+
raise e.message
|
|
56
|
+
ensure
|
|
57
|
+
yaml_file.close unless yaml_file.nil?
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
10
61
|
def yaml_write(key, value)
|
|
11
62
|
begin
|
|
12
63
|
config_map = YAML.load(File.open(@path, "r"))
|
|
@@ -21,6 +72,28 @@ module Gct
|
|
|
21
72
|
end
|
|
22
73
|
end
|
|
23
74
|
|
|
75
|
+
def yaml_write_map(path, content)
|
|
76
|
+
begin
|
|
77
|
+
yaml_file = File.open(path, "w")
|
|
78
|
+
YAML::dump(content, yaml_file)
|
|
79
|
+
rescue IOError => e
|
|
80
|
+
raise e.message
|
|
81
|
+
ensure
|
|
82
|
+
yaml_file.close unless yaml_file.nil?
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def yaml_read_map(path, key)
|
|
87
|
+
begin
|
|
88
|
+
yaml_file = YAML.load(File.open(path, "r"))
|
|
89
|
+
if yaml_file
|
|
90
|
+
yaml_file[key]
|
|
91
|
+
end
|
|
92
|
+
rescue IOError => e
|
|
93
|
+
raise e.message
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
24
97
|
def yaml_read(key)
|
|
25
98
|
begin
|
|
26
99
|
yaml_file = YAML.load(File.open(@path, "r"))
|
|
@@ -48,11 +121,28 @@ module Gct
|
|
|
48
121
|
"#{Generator::GctFile.config_file_path}"
|
|
49
122
|
end
|
|
50
123
|
|
|
124
|
+
def dependency_path
|
|
125
|
+
"#{Generator::GctFile.temp_folder_path}/#{Constant.DependencyName}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def version_path
|
|
129
|
+
"#{Generator::GctFile.temp_folder_path}/version"
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def tmp_path
|
|
133
|
+
"#{Generator::GctFile.temp_folder_path}"
|
|
134
|
+
end
|
|
135
|
+
|
|
51
136
|
def exist_root
|
|
52
137
|
root_exist = File.exist?(Generator::GctFile.root_folder_path)
|
|
53
138
|
root_exist
|
|
54
139
|
end
|
|
55
140
|
|
|
141
|
+
def exist_dependency
|
|
142
|
+
root_exist = File.exist?(dependency_path)
|
|
143
|
+
root_exist
|
|
144
|
+
end
|
|
145
|
+
|
|
56
146
|
def root_err
|
|
57
147
|
raise "请先运行命令:gct setup".red if !exist_root
|
|
58
148
|
end
|
data/lib/gct/gct_version.rb
CHANGED
data/lib/gct/specification.rb
CHANGED
|
@@ -30,15 +30,12 @@ module Gct
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
module SpecPublishStatus
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
SUCCESS = '发布成功'
|
|
42
|
-
FAILED = '发布失败'
|
|
43
|
-
CANCELED = '已取消'
|
|
33
|
+
PENDING = 'pending'
|
|
34
|
+
WAITING = 'waiting'
|
|
35
|
+
SKIPPED = 'skipped'
|
|
36
|
+
MERGED = 'merged'
|
|
37
|
+
DEPLOYING = 'deploying'
|
|
38
|
+
SUCCESS = 'success'
|
|
39
|
+
FAILED = 'failed'
|
|
40
|
+
CANCELED = 'canceled'
|
|
44
41
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jieming
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -149,6 +149,10 @@ files:
|
|
|
149
149
|
- lib/gct/command/autotag.rb
|
|
150
150
|
- lib/gct/command/build.rb
|
|
151
151
|
- lib/gct/command/build/r.rb
|
|
152
|
+
- lib/gct/command/clean.rb
|
|
153
|
+
- lib/gct/command/clean/cache.rb
|
|
154
|
+
- lib/gct/command/clean/ci.rb
|
|
155
|
+
- lib/gct/command/clean/lint.rb
|
|
152
156
|
- lib/gct/command/config.rb
|
|
153
157
|
- lib/gct/command/config/get.rb
|
|
154
158
|
- lib/gct/command/config/set.rb
|
|
@@ -163,6 +167,7 @@ files:
|
|
|
163
167
|
- lib/gct/command/op.rb
|
|
164
168
|
- lib/gct/command/op/gems.rb
|
|
165
169
|
- lib/gct/command/op/gitconf.rb
|
|
170
|
+
- lib/gct/command/op/lint.rb
|
|
166
171
|
- lib/gct/command/op/root.rb
|
|
167
172
|
- lib/gct/command/op/xcache.rb
|
|
168
173
|
- lib/gct/command/repo.rb
|
|
@@ -171,11 +176,16 @@ files:
|
|
|
171
176
|
- lib/gct/command/repo/update.rb
|
|
172
177
|
- lib/gct/command/robot.rb
|
|
173
178
|
- lib/gct/command/robot/finish.rb
|
|
179
|
+
- lib/gct/command/robot/podfile.rb
|
|
174
180
|
- lib/gct/command/robot/start.rb
|
|
175
181
|
- lib/gct/command/setup.rb
|
|
176
182
|
- lib/gct/command/spec.rb
|
|
177
183
|
- lib/gct/command/spec/lint.rb
|
|
178
184
|
- lib/gct/command/update.rb
|
|
185
|
+
- lib/gct/command/update/analyze.rb
|
|
186
|
+
- lib/gct/command/update/dependency.rb
|
|
187
|
+
- lib/gct/command/update/next.rb
|
|
188
|
+
- lib/gct/command/update/podfile.rb
|
|
179
189
|
- lib/gct/command/update/tag.rb
|
|
180
190
|
- lib/gct/command/update/version.rb
|
|
181
191
|
- lib/gct/constant.rb
|