forked from ManlyMarco/KoikatuGameplayMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.ps1
41 lines (33 loc) · 1.23 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
# Env setup ---------------
if ($PSScriptRoot -match '.+?\\bin\\?') {
$dir = $PSScriptRoot + "\"
}
else {
$dir = $PSScriptRoot + "\bin\"
}
$copy = $dir + "\copy\BepInEx\plugins"
$plugins = $dir + "\BepInEx\plugins"
New-Item -ItemType Directory -Force -Path ($dir + "\out\")
# Create releases ---------
function CreateZip ($pluginFile)
{
Remove-Item -Force -Path ($dir + "\copy") -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $copy
Copy-Item -Path $pluginFile.FullName -Destination $copy -Recurse -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 ($copy + "\..\") -Force -CompressionLevel "Optimal" -DestinationPath ($dir + "\out\" + $pluginFile.BaseName + "_" + "v" + $ver + ".zip")
}
foreach ($pluginFile in Get-ChildItem -Path $plugins)
{
try
{
CreateZip ($pluginFile)
}
catch
{
# retry
CreateZip ($pluginFile)
}
}
Remove-Item -Force -Path ($dir + "\copy") -Recurse