-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmatrix.ps1
43 lines (35 loc) · 1.17 KB
/
matrix.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
param (
[string[]]$paths
)
$allFolderObjects = @()
foreach ($path in $paths) {
$folders = Get-ChildItem -Path $path -Directory
$filteredFolders = $folders | Where-Object { $_.Name -ne "origin" }
$supportVersionFile = "$mcLoader\$mcLoader-$mcVersion\support_version.txt"
# 读取 support_version.txt 文件内容
if (Test-Path $supportVersionFile) {
$supportVersion = Get-Content -Path $supportVersionFile | Out-String
$supportVersion = $supportVersion.Trim()
} else {
$supportVersion = $mcVersion
}
# 根据 mcLoader 设置 publishLoaders
if ($mcLoader -eq "fabric") {
$publishLoaders = "fabric quilt"
} else {
$publishLoaders = $mcLoader
}
$folderObjects = $filteredFolders | ForEach-Object {
[PSCustomObject]@{
"mc-version" = $_.Name.Replace("$path-", "")
"mc-loader" = $path
"publish-loaders" = $publishLoaders
"publish-version" = $supportVersion
}
}
$allFolderObjects += $folderObjects
}
$json = [PSCustomObject]@{
"config" = $allFolderObjects
} | ConvertTo-Json -Compress
Write-Output "::set-output name=matrix::$json"