Skip to content

Commit

Permalink
Update release script
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jul 22, 2024
1 parent 07a3fef commit 20670d0
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions release.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$array = @("KK", "EC", "AI", "HS", "HS2", "PH", "KKS", "HC")

if ($PSScriptRoot -match '.+?\\bin\\?') {
$dir = $PSScriptRoot + "\"
}
Expand All @@ -9,36 +7,57 @@ else {

$copy = $dir + "\copy\BepInEx"
Remove-Item -Force -Path ($copy) -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path ($copy + "\plugins")
New-Item -ItemType Directory -Force -Path ($copy + "\plugins") | Out-Null

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

function CreateZip ($element)
{
Write-Output ("Processing " + $element)

Remove-Item -Force -Path ($copy) -Recurse
New-Item -ItemType Directory -Force -Path ($copy + "\plugins")
New-Item -ItemType Directory -Force -Path ($copy + "\plugins") | Out-Null

Copy-Item -Path ($dir + "\BepInEx\plugins\" + $element + "_BepisPlugins") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force
Copy-Item -Path ($dir + "\BepInEx\plugins\" + $element + "_BepisPlugins") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force | Out-Null

Copy-Item -Path ($dir + "\..\README.md") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force
Copy-Item -Path ($dir + "\..\LICENSE") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force
Copy-Item -Path ($dir + "\..\README.md") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force | Out-Null
Copy-Item -Path ($dir + "\..\LICENSE") -Destination ($copy + "\plugins\" + $element + "_BepisPlugins") -Recurse -Force | Out-Null

try
{
$ver = "r" + (Get-ChildItem -Path ($copy + "\plugins") -Filter ($element + "_*.dll") -Recurse -Force)[0].VersionInfo.FileVersion.ToString() -replace "([\d+\.]+?\d+)[\.0]*$", '${1}'
$pluginFiles = (Get-ChildItem -Path ($copy + "\plugins") -Filter ($element + "_*.dll") -Recurse -Force)
if($pluginFiles.Length.Equals(0))
{
$pluginFiles = (Get-ChildItem -Path ($copy + "\plugins") -Filter ("*Sideloader.dll") -Recurse -Force)
}
$pluginFile = $pluginFiles[0]

$ver = "r" + $pluginFile.VersionInfo.FileVersion.ToString() -replace "([\d+\.]+?\d+)[\.0]*$", '${1}'
if(!$ver.Contains("."))
{
$ver = $ver + ".0"
}
}
catch
{
$ver = "r" + (Get-ChildItem -Path ($copy) -Filter ("*.dll") -Recurse -Force)[0].VersionInfo.FileVersion.ToString()
{
Write-Warning ("Failed to extract version number - " + $_)
$pluginFile = (Get-ChildItem -Path ($copy) -Filter ("*.dll") -Recurse -Force)[0]
$ver = "r" + $pluginFile.VersionInfo.FileVersion.ToString()
}

Write-Output ("Version " + $ver + " extracted from " + $pluginFile)

& robocopy ($dir + "\BepInEx\patchers\") ($copy + "\patchers") ($element + "_*.*") /R:5 /W:5
& robocopy ($dir + "\BepInEx\patchers\") ($copy + "\patchers") ($element + "_*.*") /R:5 /W:5 /nfl /ndl /njh /njs /ns /nc /np

Compress-Archive -Path $copy -Force -CompressionLevel "Optimal" -DestinationPath ($dir + "out\" + $element + "_BepisPlugins_" + $ver + ".zip")
}

$array = Get-ChildItem -Path ($dir + "\BepInEx\plugins\") -Filter "*_BepisPlugins"

foreach ($element in $array)
{
$element = $element.Name.Substring(0, $element.Name.IndexOf("_"))

try
{
CreateZip ($element)
Expand Down

0 comments on commit 20670d0

Please sign in to comment.