From 1eda938706e20dd6eaf47ceee83cfb35b67cea2b Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Wed, 20 May 2020 17:53:20 +0300 Subject: [PATCH] powershell script to automate build release packages --- publish.ps1 | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 publish.ps1 diff --git a/publish.ps1 b/publish.ps1 new file mode 100644 index 0000000..3e585ee --- /dev/null +++ b/publish.ps1 @@ -0,0 +1,51 @@ +# build release packages + + +Function Build($dir, $arch) +{ + # clean dir + if (Test-Path $dir) + { + Remove-Item $dir -Recurse -Force + } + dotnet publish -c Release /p:PublishSingleFile=true --runtime $arch --framework $framework WebAPI +} + +Function Pack($dir, $arch) +{ + + mkdir -p $dir\CharacterEditor\Resources + # copy resources + xcopy /y /s /e CharacterEditor\Resources $dir\CharacterEditor\Resources + # create zip archive in the root + & $zip_exe a -mpass=10 "api.pvpgn.pro_${version}_$arch.zip" .\$dir\* +} + + +$version = Select-String -Path .\WebAPI\WebAPI.csproj -Pattern '(.*)' -AllMatches | %{ $_.Matches.Groups[1] } | %{ $_.Value } + +$framework = "netcoreapp3.1" +$rdir = "WebAPI\bin\Release\$framework" +$zip_exe = "C:\Program Files\7-Zip\7z.exe" + + +echo "Framework: $framework" +echo "App Version: $version" +echo " " + +# build for every architecture +$arch = "win-x64" +$publish = "$rdir\$arch\publish" +Build $publish $arch +Pack $publish $arch + +$arch = "linux-x64" +$publish = "$rdir\$arch\publish" +Build $publish $arch +Pack $publish $arch + +$arch = "osx-x64" +$publish = "$rdir\$arch\publish" +Build $publish $arch +Pack $publish $arch +