-
Notifications
You must be signed in to change notification settings - Fork 36
/
release.ps1
71 lines (58 loc) · 2.72 KB
/
release.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Env setup ---------------
if ($PSScriptRoot -match '.+?\\bin\\?') {
$dir = $PSScriptRoot + "\"
}
else {
$dir = $PSScriptRoot + "\bin\"
}
$copy = $dir + "\copy\BepInEx\plugins"
Remove-Item -Force -Path ($dir + "\copy") -Recurse -ErrorAction SilentlyContinue
Remove-Item -Force -Path ($dir + "\out\") -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path ($dir + "\out\")
foreach ($subdir in Get-ChildItem -Path $dir -Directory -Exclude "Out")
{
if ((Get-ChildItem -Path $subdir -Filter *.dll).Length -gt 0)
{
$pluginDir = $subdir
}
else
{
$pluginDir = Get-Item ($subdir.FullName + "\BepInEx\plugins")
}
Write-Information -MessageData ("Using " + $pluginDir + " as plugin directory")
$outdir = $dir + "\out\" + $subdir.BaseName
New-Item -ItemType Directory -Force -Path $outdir
# Create releases ---------
function CreateZip ($pluginFile)
{
Remove-Item -Force -Path ($dir + "\copy") -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $copy
# the actual dll
Copy-Item -Path $pluginFile.FullName -Destination $copy -Recurse -Force
# the docs xml if it exists
Copy-Item -Path ($pluginFile.DirectoryName + "\" + $pluginFile.BaseName + ".xml") -Destination $copy -Recurse -Force -ErrorAction Ignore
Copy-Item -Path ($pluginFile.DirectoryName + "\" + $pluginFile.BaseName) -Destination $copy -Recurse -Force -ErrorAction Ignore
if($pluginFile.Name -clike "*PE.dll")
{
New-Item -ItemType Directory -Force -Path ($dir + "\copy\mods")
Copy-Item -Path ($pluginDir.FullName + "\Joan6694DynamicBoneColliders.zipmod") -Destination ($dir + "\copy\mods") -Force
}
# the replace removes .0 from the end of version up until it hits a non-0 or there are only 2 version parts remaining (e.g. v1.0 v1.0.1)
$ver = (Get-ChildItem -Path ($copy) -Filter "*.dll" -Recurse -Force)[0].VersionInfo.FileVersion.ToString() -replace "^([\d+\.]+?\d+)[\.0]*$", '${1}'
Compress-Archive -Path ($dir + "\copy\*") -Force -CompressionLevel "Optimal" -DestinationPath ($outdir + "\" + $pluginFile.BaseName + "_" + "v" + $ver + ".zip")
}
foreach ($pluginFile in Get-ChildItem -Path $pluginDir -Filter *.dll)
{
try
{
CreateZip ($pluginFile)
}
catch
{
# retry
CreateZip ($pluginFile)
}
}
Compress-Archive -Path ($outdir + "\*") -Force -CompressionLevel "NoCompression" -DestinationPath ($dir + "\out\" + $subdir.BaseName + "_HSPlugins_" + (Get-Date).ToString("yyyy.MM.dd") + ".zip")
}
Remove-Item -Force -Path ($dir + "\copy") -Recurse