From cf293165363fa461243ff5e7e2e7ea027bd2067a Mon Sep 17 00:00:00 2001 From: ManlyMarco Date: Tue, 21 Sep 2021 15:26:05 +0200 Subject: [PATCH] Upgrade release script --- release.ps1 | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/release.ps1 b/release.ps1 index 9ab74ce..f4ec7f7 100644 --- a/release.ps1 +++ b/release.ps1 @@ -1,5 +1,4 @@ -$array = @("KKAPI", "ECAPI", "AIAPI", "PHAPI", "HS2API", "KKSAPI") - +# Env setup --------------- if ($PSScriptRoot -match '.+?\\bin\\?') { $dir = $PSScriptRoot + "\" } @@ -7,36 +6,39 @@ 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\") +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 $dir -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 \ No newline at end of file + +Remove-Item -Force -Path ($dir + "\copy") -Recurse