easyci 0.6.0 → 0.7.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: ad95be0f7bbfcd56c10ee8bb7cc8593b50e169601b2ed7c1f9be37ba8def4cd4
4
- data.tar.gz: b1e0b30cb955bf1139c25049d783e1edd56f45743f5e835421f63cab9c048cff
3
+ metadata.gz: 93e85d54f39687dd87189fe75a8f2500e6ac30e6195b1579d0a9f26145a0d53e
4
+ data.tar.gz: 844a0177557c48cbb462e7cb369e8c69c48e0b9d23b534593f5a388f1ddaee43
5
5
  SHA512:
6
- metadata.gz: f835032e51afb9bc6ccf19993a9a933d49827c18a51188502d73c73ac8e26a90f91f21095f0e552c1dde85014ce9812e3375644ab8245dc89d4ec2201055d857
7
- data.tar.gz: 4765d4151b5252ba1e6f1cebb1744ff7453acd46876511fb2fa08c5b5ec16c07c0ba257e50d700142da4063e6804a992873cbb125b9ddbd55031b469dde65074
6
+ metadata.gz: 23b253fac7ea57d0f50fdfca93b4108dc264a036307e42e2f124ff7467c4655856a8426fc289b4d76d8e437831595417c4220385f5b141a3aaca98ea0af37857
7
+ data.tar.gz: 6acd0d3b11ed1c80b6cfddd59074df5b664c61edc56da7f2b1ee6f230edc18beceaf84655bd8b3c19565ca64115e8819fbea3c5d0992636656d46df4e6794694
@@ -78,7 +78,7 @@ module EasyCI
78
78
  unity_path = find_unity_path(runner_dir)
79
79
  puts "运行Unity截图任务..."
80
80
  FileUtils.chdir(runner_dir)
81
- system("#{unity_path} -projectPath #{runner_dir} -executeMethod -logFile screenshot-log.txt")
81
+ system("#{unity_path} -projectPath #{runner_dir} -executeMethod SpineAutoImporter.CIRunner -logFile screenshot-log.txt")
82
82
 
83
83
  # 压缩截图
84
84
  puts "开始压缩截图..."
@@ -17,12 +17,33 @@ module EasyCI
17
17
  "/opt/unity/hub/editor/*/Editor/Unity"
18
18
  ]
19
19
 
20
+ # 从路径中提取Unity版本号
21
+ # @param path [String] Unity可执行文件路径
22
+ # @return [String, nil] 提取的版本号,如果无法提取则返回nil
23
+ def self.extract_version_from_path(path)
24
+ # macOS路径格式: /Applications/Unity/Hub/Editor/2021.3.45f1/Unity.app/Contents/MacOS/Unity
25
+ # macOS路径格式(变体): /Applications/Unity/Hub/Editor/2021.3.45f1c1/Unity.app/Contents/MacOS/Unity
26
+ # Windows路径格式: C:/Program Files/Unity/Hub/Editor/2021.3.45f1/Editor/Unity.exe
27
+ # Windows路径格式(变体): C:/Program Files/Unity/Hub/Editor/2021.3.45f1c1/Editor/Unity.exe
28
+
29
+ # 尝试匹配 macOS 路径格式
30
+ if match = path.match(/Editor\/([\d.]+[a-zA-Z]\d+(?:c\d+)?)\//)
31
+ return match[1]
32
+ end
33
+
34
+ # 尝试匹配 Windows 路径格式
35
+ if match = path.match(/([\d.]+[a-zA-Z]\d+(?:c\d+)?)\/Editor\//)
36
+ return match[1]
37
+ end
38
+
39
+ nil
40
+ end
41
+
20
42
  # 查找Unity可执行文件路径
21
43
  # @param project_path [String] Unity项目路径
22
44
  # @param verbose [Boolean] 是否显示详细信息
23
45
  # @return [String] Unity可执行文件路径
24
46
  def self.find_unity_executable(project_path = nil, verbose = false)
25
- unity_path = nil
26
47
  project_version = nil
27
48
 
28
49
  # 如果提供了项目路径,尝试从ProjectVersion.txt中读取版本
@@ -37,117 +58,131 @@ module EasyCI
37
58
  end
38
59
  end
39
60
 
40
- # 如果找到项目版本,尝试定位对应的Unity
61
+ if project_version.nil?
62
+ puts "未找到项目Unity版本信息" if verbose
63
+ end
64
+
65
+ # 如果找到了项目版本,提取主要版本号(例如:2021.3)
66
+ unity_major_version = nil
41
67
  if project_version
42
- # 检查macOS路径
43
- if RUBY_PLATFORM =~ /darwin/
44
- mac_path = "/Applications/Unity/Hub/Editor/#{project_version}/Unity.app/Contents/MacOS/Unity"
45
- if File.exist?(mac_path)
46
- unity_path = mac_path
47
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
48
- end
49
- # 检查Windows路径
50
- elsif RUBY_PLATFORM =~ /mswin|mingw|cygwin/
51
- win_path = "C:/Program Files/Unity/Hub/Editor/#{project_version}/Editor/Unity.exe"
52
- if File.exist?(win_path)
53
- unity_path = win_path
54
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
68
+ unity_major_version = project_version.split('.')[0..1].join('.')
69
+ puts "项目Unity主要版本: #{unity_major_version}" if verbose
70
+ end
71
+
72
+ # 获取所有可能的Unity版本及路径
73
+ unity_versions = []
74
+
75
+ # 获取当前平台的Unity路径集合
76
+ paths = case RUBY_PLATFORM
77
+ when /darwin/
78
+ UNITY_MAC_PATHS
79
+ when /mswin|mingw|cygwin/
80
+ UNITY_WINDOWS_PATHS
81
+ when /linux/
82
+ UNITY_LINUX_PATHS
83
+ else
84
+ []
85
+ end
86
+
87
+ # 查找所有可用的Unity版本
88
+ paths.each do |path|
89
+ if path.include?("*")
90
+ Dir.glob(path).each do |expanded_path|
91
+ version = extract_version_from_path(expanded_path)
92
+ if version
93
+ major_version = version.split('.')[0..1].join('.')
94
+ unity_versions << {
95
+ path: expanded_path,
96
+ version: version,
97
+ major_version: major_version
98
+ }
99
+ puts "找到Unity版本: #{version} 路径: #{expanded_path}" if verbose
100
+ end
55
101
  end
56
- # 检查Linux路径
57
- elsif RUBY_PLATFORM =~ /linux/
58
- linux_path = "/opt/unity/hub/editor/#{project_version}/Editor/Unity"
59
- if File.exist?(linux_path)
60
- unity_path = linux_path
61
- puts "找到匹配版本的Unity: #{unity_path}" if verbose
102
+ elsif File.exist?(path)
103
+ version = extract_version_from_path(path)
104
+ if version
105
+ major_version = version.split('.')[0..1].join('.')
106
+ unity_versions << {
107
+ path: path,
108
+ version: version,
109
+ major_version: major_version
110
+ }
111
+ puts "找到Unity版本: #{version} 路径: #{path}" if verbose
62
112
  end
63
113
  end
64
114
  end
65
115
 
66
- # 如果没有找到匹配版本,尝试查找最新版本
67
- if unity_path.nil?
68
- puts "没有找到匹配的Unity版本,尝试查找最新版本" if verbose
69
- unity_path = find_latest_unity(verbose)
116
+ if unity_versions.empty?
117
+ puts "未找到任何Unity版本" if verbose
118
+ raise "未找到任何Unity版本,请确保Unity已正确安装"
70
119
  end
71
120
 
72
- # 如果仍然找不到,抛出错误
73
- raise "无法找到Unity可执行文件,请确保Unity已正确安装" if unity_path.nil?
74
-
75
- unity_path
76
- end
77
-
78
- # 查找最新版本的Unity
79
- # @param verbose [Boolean] 是否显示详细信息
80
- # @return [String] Unity可执行文件路径
81
- def self.find_latest_unity(verbose = false)
82
- # 检查macOS路径
83
- if RUBY_PLATFORM =~ /darwin/
84
- hub_path = "/Applications/Unity/Hub/Editor"
85
- if Dir.exist?(hub_path)
86
- # 获取所有版本并按版本号排序
87
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
88
- v.split('.').map(&:to_i)
89
- end
90
-
91
- if versions.any?
92
- latest_version = versions.last
93
- mac_path = "#{hub_path}/#{latest_version}/Unity.app/Contents/MacOS/Unity"
94
- if File.exist?(mac_path)
95
- puts "使用最新Unity版本 #{latest_version}: #{mac_path}" if verbose
96
- return mac_path
97
- end
98
- end
121
+ # 如果找到项目版本,尝试精确匹配
122
+ if project_version
123
+ # 1. 精确匹配版本号
124
+ exact_matches = unity_versions.select { |v| v[:version] == project_version }
125
+ if !exact_matches.empty?
126
+ unity_path = exact_matches.first[:path]
127
+ puts "找到精确匹配的Unity版本 #{project_version}: #{unity_path}" if verbose
128
+ return unity_path
99
129
  end
100
130
 
101
- # 查找传统路径
102
- traditional_path = "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
103
- if File.exist?(traditional_path)
104
- puts "使用传统路径Unity: #{traditional_path}" if verbose
105
- return traditional_path
106
- end
107
- # 检查Windows路径
108
- elsif RUBY_PLATFORM =~ /mswin|mingw|cygwin/
109
- hub_path = "C:/Program Files/Unity/Hub/Editor"
110
- if Dir.exist?(hub_path)
111
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
112
- v.split('.').map(&:to_i)
113
- end
131
+ # 2. 如果没有精确匹配,尝试按主要版本号匹配(如2021.3.x)
132
+ if unity_major_version
133
+ major_matches = unity_versions.select { |v| v[:major_version] == unity_major_version }
114
134
 
115
- if versions.any?
116
- latest_version = versions.last
117
- win_path = "#{hub_path}/#{latest_version}/Editor/Unity.exe"
118
- if File.exist?(win_path)
119
- puts "使用最新Unity版本 #{latest_version}: #{win_path}" if verbose
120
- return win_path
135
+ if !major_matches.empty?
136
+ # 按版本号排序
137
+ sorted_versions = major_matches.sort_by do |v|
138
+ # 解析版本号为数组,如 "2021.3.45f1" => [2021, 3, 45, 1]
139
+ if v[:version] =~ /(\d+)\.(\d+)\.(\d+)f(\d+)/
140
+ [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
141
+ else
142
+ [0, 0, 0, 0]
143
+ end
121
144
  end
122
- end
123
- end
124
-
125
- # 查找传统路径
126
- traditional_path = "C:/Program Files/Unity/Editor/Unity.exe"
127
- if File.exist?(traditional_path)
128
- puts "使用传统路径Unity: #{traditional_path}" if verbose
129
- return traditional_path
130
- end
131
- # 检查Linux路径
132
- elsif RUBY_PLATFORM =~ /linux/
133
- hub_path = "/opt/unity/hub/editor"
134
- if Dir.exist?(hub_path)
135
- versions = Dir.entries(hub_path).select { |e| e =~ /[\d\.]+/ }.sort_by do |v|
136
- v.split('.').map(&:to_i)
137
- end
138
-
139
- if versions.any?
140
- latest_version = versions.last
141
- linux_path = "#{hub_path}/#{latest_version}/Editor/Unity"
142
- if File.exist?(linux_path)
143
- puts "使用最新Unity版本 #{latest_version}: #{linux_path}" if verbose
144
- return linux_path
145
+
146
+ # 标准版本(如2021.3.45f1)优先于特殊版本(如2021.3.45f1c1)
147
+ standard_versions = sorted_versions.select { |v| v[:version] =~ /^[\d\.]+f\d+$/ }
148
+
149
+ if !standard_versions.empty?
150
+ unity_path = standard_versions.last[:path] # 取最新的标准版本
151
+ puts "找到主要版本号匹配的标准Unity版本 #{standard_versions.last[:version]}: #{unity_path}" if verbose
152
+ return unity_path
153
+ else
154
+ unity_path = sorted_versions.last[:path] # 取最新版本
155
+ puts "找到主要版本号匹配的Unity版本 #{sorted_versions.last[:version]}: #{unity_path}" if verbose
156
+ return unity_path
145
157
  end
146
158
  end
147
159
  end
148
160
  end
149
161
 
150
- nil
162
+ # 3. 如果没有找到匹配的版本,使用最新版本
163
+ puts "未找到匹配项目版本的Unity,将使用最新可用版本" if verbose
164
+
165
+ # 按版本号排序
166
+ sorted_all_versions = unity_versions.sort_by do |v|
167
+ if v[:version] =~ /(\d+)\.(\d+)\.(\d+)f(\d+)/
168
+ [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
169
+ else
170
+ [0, 0, 0, 0]
171
+ end
172
+ end
173
+
174
+ # 标准版本优先
175
+ standard_versions = sorted_all_versions.select { |v| v[:version] =~ /^[\d\.]+f\d+$/ }
176
+
177
+ if !standard_versions.empty?
178
+ unity_path = standard_versions.last[:path] # 取最新的标准版本
179
+ puts "使用最新标准Unity版本 #{standard_versions.last[:version]}: #{unity_path}" if verbose
180
+ return unity_path
181
+ else
182
+ unity_path = sorted_all_versions.last[:path] # 取最新版本
183
+ puts "使用最新可用Unity版本 #{sorted_all_versions.last[:version]}: #{unity_path}" if verbose
184
+ return unity_path
185
+ end
151
186
  end
152
187
 
153
188
  # 验证Unity可执行文件路径是否有效
@@ -1,3 +1,3 @@
1
1
  module EasyCI
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade