Skip to content

Commit

Permalink
Update release script
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jun 5, 2024
1 parent 4eb40e9 commit f397195
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions release.ps1
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
$array = @("KKABMX", "KKSABMX", "ECABMX", "AIABMX", "PHABMX", "HS2ABMX")

# Env setup ---------------
if ($PSScriptRoot -match '.+?\\bin\\?') {
$dir = $PSScriptRoot + "\"
}
else {
$dir = $PSScriptRoot + "\bin\"
}

$out = $dir + "BepInEx\plugins\"
New-Item -ItemType Directory -Force -Path $out
$copy = $dir + "\copy\BepInEx\plugins"

New-Item -ItemType Directory -Force -Path ($dir + "out\")
if ((Get-ChildItem -Path $dir -Filter *.dll).Length -gt 0)
{

$pluginDir = $dir
}
else
{
$pluginDir = $dir + "\BepInEx\plugins"
}
Write-Information -MessageData ("Using " + $pluginDir + " as plugin directory")

New-Item -ItemType Directory -Force -Path ($dir + "\out\")

function CreateZip ($element)
# Create releases ---------
function CreateZip ($pluginFile)
{
Remove-Item -Force -Path ($out + "*")
New-Item -ItemType Directory -Force -Path $out
Remove-Item -Force -Path ($dir + "\copy") -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $copy

Copy-Item -Path ($dir + $element + ".dll") -Destination $out
Copy-Item -Path ($dir + $element + ".xml") -Destination $out
# 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

$ver = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dir + $element + ".dll").FileVersion.ToString()
# 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 + "BepInEx") -Force -CompressionLevel "Optimal" -DestinationPath ($dir + "out\" + $element + "_" + $ver + ".zip")
Compress-Archive -Path ($copy + "\..\") -Force -CompressionLevel "Optimal" -DestinationPath ($dir + "\out\" + $pluginFile.BaseName + "_" + "v" + $ver + ".zip")
}

foreach ($element in $array)
foreach ($pluginFile in Get-ChildItem -Path $pluginDir -Filter *.dll)
{
try
{
CreateZip ($element)
CreateZip ($pluginFile)
}
catch
{
# retry
CreateZip ($element)
CreateZip ($pluginFile)
}
}

Remove-Item -Force -Path ($out + "*")
Remove-Item -Force -Path ($dir + "BepInEx") -Recurse

Remove-Item -Force -Path ($dir + "\copy") -Recurse

0 comments on commit f397195

Please sign in to comment.