Skip to content

Commit 05e03fc

Browse files
committed
Add release script
1 parent 48d452e commit 05e03fc

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

release.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Env setup ---------------
2+
if ($PSScriptRoot -match '.+?\\bin\\?') {
3+
$dir = $PSScriptRoot + "\"
4+
}
5+
else {
6+
$dir = $PSScriptRoot + "\bin\"
7+
}
8+
9+
$copy = $dir + "\copy\BepInEx\plugins"
10+
$plugins = $dir + "\Release"
11+
12+
# Create releases ---------
13+
function CreateZip ($pluginFile)
14+
{
15+
Remove-Item -Force -Path ($dir + "\copy") -Recurse -ErrorAction SilentlyContinue
16+
New-Item -ItemType Directory -Force -Path $copy
17+
18+
Copy-Item -Path $pluginFile.FullName -Destination $copy -Recurse -Force
19+
20+
# 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)
21+
$ver = (Get-ChildItem -Path ($copy) -Filter "*.dll" -Recurse -Force)[0].VersionInfo.FileVersion.ToString() -replace "^([\d+\.]+?\d+)[\.0]*$", '${1}'
22+
23+
Compress-Archive -Path ($copy + "\..\") -Force -CompressionLevel "Optimal" -DestinationPath ($dir + $pluginFile.BaseName + "_" + "r" + $ver + ".zip")
24+
}
25+
26+
foreach ($pluginFile in Get-ChildItem -Path $plugins)
27+
{
28+
try
29+
{
30+
CreateZip ($pluginFile)
31+
}
32+
catch
33+
{
34+
# retry
35+
CreateZip ($pluginFile)
36+
}
37+
}
38+
39+
Remove-Item -Force -Path ($dir + "\copy") -Recurse
40+
41+
# Create Starup profiler release
42+
$profilerdir = $dir + "\..\src\SimpleProfiler\bin"
43+
44+
Get-ChildItem -Path ($profilerdir) | Where{$_.Name -Match "^MonoProfiler(32|64)\.(?!dll)"} | Remove-Item
45+
46+
$ver = (Get-ChildItem -Path $profilerdir -Filter "MonoProfilerController.dll" -Recurse -Force)[0].VersionInfo.FileVersion.ToString() -replace "^([\d+\.]+?\d+)[\.0]*$", '${1}'
47+
48+
Compress-Archive -Path ($profilerdir + "\*") -Force -CompressionLevel "Optimal" -DestinationPath ($dir + "SimpleMonoProfiler_" + "r" + $ver + ".zip")

0 commit comments

Comments
 (0)