From 783cd2115a077d24f3a2bdf8bde2acc33075f23e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 23 Dec 2015 17:22:08 +0000 Subject: [PATCH] turn publish into tasks and fix nsis installer --- distribution/windows/build.ps1 | 2 +- distribution/windows/win32.txt | 2 +- scripts/ps/publish.ps1 | 74 ++++++++++++++++++++++++++-------- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/distribution/windows/build.ps1 b/distribution/windows/build.ps1 index 45c83c6b9b..2836e38771 100644 --- a/distribution/windows/build.ps1 +++ b/distribution/windows/build.ps1 @@ -1,3 +1,3 @@ $path = Split-Path $Script:MyInvocation.MyCommand.Path -Write-Output "Building Windows Installer (NSIS script)"; +Write-Host "Building Windows Installer (NSIS script)"; makensis /DVERSION_INCLUDE=$path\win32.txt $path\install.nsi > $path\win32.log; diff --git a/distribution/windows/win32.txt b/distribution/windows/win32.txt index 7d960db79f..a33ea783b6 100644 --- a/distribution/windows/win32.txt +++ b/distribution/windows/win32.txt @@ -1,5 +1,5 @@ !define APPBITS 32 ; Define number of bits for the architecture !define EXTRA_VERSION "Vista, 7, 8.1 and 10" !define APPARCH "win32" ; Define the application architecture -!define BINARY_DIR "${PATH_ROOT}build\Release" +!define BINARY_DIR "${PATH_ROOT}bin" InstallDir "$PROGRAMFILES32\OpenRCT2\" diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index 0cb8f90179..c55e4fb973 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -5,6 +5,9 @@ # - Creates a ZIP for distribution ######################################################### param ( + [Parameter(Position = 1)] + [string]$Task = "all", + [string]$Server = "", [string]$BuildNumber = "", [string]$GitBranch = "", @@ -20,7 +23,7 @@ Import-Module "$scriptsPath\common.psm1" -DisableNameChecking $rootPath = Get-RootPath # Set build attributes -function do-prepareSource() +function Do-PrepareSource() { Write-Host "Setting build #defines..." -ForegroundColor Cyan if ($GitBranch -eq "") @@ -48,19 +51,21 @@ function do-prepareSource() # Set the environment variable which the msbuild project will use $env:OPENRCT2_DEFINES = $defineString; + return 0 } # Building OpenRCT2 -function do-build() +function Do-Build() { Write-Host "Building OpenRCT2..." -ForegroundColor Cyan & "$scriptsPath\build.ps1" all -Rebuild + return $LASTEXITCODE } # Package -function do-package() +function Do-Package() { - Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan + Write-Host "Publishing OpenRCT2 as zip..." -ForegroundColor Cyan $releaseDir = "$rootPath\bin" $distDir = "$rootPath\distribution" $tempDir = "$rootPath\artifacts\temp" @@ -89,19 +94,25 @@ function do-package() if (-not (AppExists($7zcmd))) { Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red - exit 1 + return 1 } } - & $7zcmd a -tzip -mx9 $outZip "$tempDir\*" + & $7zcmd a -tzip -mx9 $outZip "$tempDir\*" | Write-Host + if ($LASTEXITCODE -ne 0) + { + Write-Host "Failed to create zip." -ForegroundColor Red + return 1 + } # Remove temp directory Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue + return 0 } # Installer -function do-installer() +function Do-Installer() { - Write-Host "Publishing OpenRCT2..." -ForegroundColor Cyan + Write-Host "Publishing OpenRCT2 as installer..." -ForegroundColor Cyan $artifactsDir = "$rootPath\artifacts" $installerDir = "$rootPath\distribution\windows" @@ -113,26 +124,57 @@ function do-installer() if ($LASTEXITCODE -ne 0) { Write-Host "Failed to create installer." -ForegroundColor Red - exit 1 + if (Test-Path -PathType Leaf "$installerDir\win32.log") + { + Get-Content "$installerDir\win32.log" | Write-Host + } + return 1 } $binaries = (Get-ChildItem "$installerDir\*.exe" | Sort-Object -Property LastWriteTime -Descending) if ($binaries -eq 0) { Write-Host "Unable to find created installer." -ForegroundColor Red - exit 1 + return 1 } Copy-Item $binaries[0].FullName $artifactsDir + return 0 } -do-prepareSource -do-build -if ($Installer) +function Do-Task-Build() { - do-installer + if (($result = (Do-PrepareSource)) -ne 0) { return $result } + if (($result = (Do-Build )) -ne 0) { return $result } + return 0 } -else + +function Do-Task-Package() { - do-package + if ($Installer) + { + if (($result = (Do-Installer)) -ne 0) { return $result } + } + else + { + if (($result = (Do-Package)) -ne 0) { return $result } + } + return 0 +} + +function Do-Task-All() +{ + if (($result = (Do-Task-Build )) -ne 0) { return $result } + if (($result = (Do-Task-Package)) -ne 0) { return $result } + return 0 +} + +# Script entry point +switch ($Task) +{ + "build" { $result = Do-Task-Build } + "package" { $result = Do-Task-Package } + "all" { $result = Do-Task-All } + default { Write-Host "Unknown publish task." -ForegroundColor Red + $result = 1 } }