From c9042c6174be487c58bbb473fa88765ad2846395 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 26 Jan 2016 18:48:09 +0000 Subject: [PATCH 1/5] add code signing to AppVeyor CI --- appveyor.yml | 25 ++++-- distribution/windows/build.ps1 | 8 +- .../code-sign-key-openrct2.org.pfx.enc | Bin 0 -> 4368 bytes scripts/ps/appveyor_run.ps1 | 32 ++++++++ scripts/ps/publish.ps1 | 75 +++++++++++++++++- 5 files changed, 128 insertions(+), 12 deletions(-) create mode 100644 distribution/windows/code-sign-key-openrct2.org.pfx.enc create mode 100644 scripts/ps/appveyor_run.ps1 diff --git a/appveyor.yml b/appveyor.yml index c2beb58a80..4ec9361b08 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,27 @@ version: 0.0.4.{build} -os: Previous Visual Studio 2015 +os: Visual Studio 2015 +environment: + ENCKEY: + secure: saYAIpqXzpq0U+JH+MNi/isRQ6Y51PZhm4BrnePDiAPptFO5htxFOLegrYqxdy67 + CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD: + secure: bzYmf0ElxisSGyZnIjUOYQ== +install: +- nuget install secure-file -ExcludeVersion +- secure-file\tools\secure-file -decrypt distribution\windows\code-sign-key-openrct2.org.pfx.enc -secret %enckey% +- cinst nsis.portable -pre +- ps: >- + curl "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip" -OutFile nsisxtra.zip + + 7z x nsisxtra.zip + + cp FindProcDLL.dll "C:\ProgramData\chocolatey\lib\nsis.portable\tools\nsis-3.0b1\Plugins\x86-ansi" build_script: - ps: >- .\setenv.ps1 - install - - publish -Server AppVeyor -BuildNumber $env:APPVEYOR_BUILD_NUMBER -GitBranch $env:APPVEYOR_REPO_BRANCH + appveyor_run artifacts: - path: .\artifacts\openrct2.zip - name: OpenRCT2 + name: OpenRCT2-portable +- path: .\artifacts\*.exe + name: OpenRCT2-installer diff --git a/distribution/windows/build.ps1 b/distribution/windows/build.ps1 index 21d0d383e5..2dd5770727 100644 --- a/distribution/windows/build.ps1 +++ b/distribution/windows/build.ps1 @@ -1,9 +1,11 @@ param ( [Parameter(Position = 1)] - [string]$BuildNumber = "", - [string]$GitBranch = "" + [string]$VersionExtra = "" ) $path = Split-Path $Script:MyInvocation.MyCommand.Path Write-Host "Building Windows Installer (NSIS script)"; -makensis /DAPPV_BUILD=$BuildNumber /DAPPV_EXTRA=-$GitBranch-b$BuildNumber /DVERSION_INCLUDE=$path\win32.txt $path\install.nsi > $path\win32.log; +Write-Host " $VersionExtra"; +makensis /DAPPV_EXTRA=-$VersionExtra ` + /DVERSION_INCLUDE=$path\win32.txt ` + $path\install.nsi > $path\win32.log; diff --git a/distribution/windows/code-sign-key-openrct2.org.pfx.enc b/distribution/windows/code-sign-key-openrct2.org.pfx.enc new file mode 100644 index 0000000000000000000000000000000000000000..99f16381c5ba5ae2b40db625d6763c5685b5758b GIT binary patch literal 4368 zcmV+r5%2EkxE&NG6`V8-sWjO2rsdjgQQoD@RYDmBR8@-6=|^d+sVPwtj?qPZM?T9i z{{-gny?(=@xDKE#P^6R+Z;SGQh{ly2+~)`He`TN4RfMP`pFV_(Yyg7cjY`*6hIwY( z)Dd{Qq>b3+*&yC(A=O$$;J!jQ0waZ9^r5k}( zWjf4;Q;|1}lJ-;*`xcG*hFQ$W4zy&kc9fR>iZr4ZQkIj;rh7x<_J>fFa*hakh95kJ ztqlgabyu$bDpvQ+jqRQ0RM6CW_l+^)#l_VkzqfO?G|j4vB_6;Z1u<5{p$RIiOk1VI zwOv94&7%@ppW$-Dtq)D~Y^js=S&7@q1x786`)jsw?$AU{a8h4OHoCsIP5<-bO0JT# zGvbRQ#G~510&boZxUUDAO9Cvwc0_%(1a0EMAiKC|#B1O!>LZ;GO@E}=5Emnh)ReNl z7y{BMxrhfGSI*O75t-PrEIm1Al4JN>&*hv=I!YGazl*!kBWgWQ^uxjBYm1#=kf)07 zCo+yrQW2$z?eUtzeYwfsh)ap^Q`Dnz8Q#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Dfwx20eOPZyLVfC4 z0Rm?>eZ_9Ocg^2a2#loQb7d9-KKv*8DXybKb9cvOh9b<{_>1CYXu+MHbX;DvkhS?I K8B3MZD}2J`mWDV0 literal 0 HcmV?d00001 diff --git a/scripts/ps/appveyor_run.ps1 b/scripts/ps/appveyor_run.ps1 new file mode 100644 index 0000000000..97724a7197 --- /dev/null +++ b/scripts/ps/appveyor_run.ps1 @@ -0,0 +1,32 @@ +######################################################### +# Script to build OpenRCT2 on AppVeyor +######################################################### + +# Install dependencies +install -Quiet + +# Build OpenRCT2 +publish build ` + -Server AppVeyor ` + -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` + -GitBranch $env:APPVEYOR_REPO_BRANCH ` + -CodeSign + +if ($LASTEXITCODE -ne 0) +{ + exit 1 +} + +# Create a Portable ZIP +publish package ` + -Server AppVeyor ` + -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` + -GitBranch $env:APPVEYOR_REPO_BRANCH + +# Create an Installer +publish package ` + -Installer ` + -Server AppVeyor ` + -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` + -GitBranch $env:APPVEYOR_REPO_BRANCH ` + -CodeSign diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index 4e83208408..ce77846642 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -11,7 +11,8 @@ param ( [string]$Server = "", [string]$BuildNumber = "", [string]$GitBranch = "", - [switch]$Installer = $false + [switch]$Installer = $false, + [switch]$CodeSign = $false ) # Setup @@ -59,7 +60,23 @@ function Do-Build() { Write-Host "Building OpenRCT2..." -ForegroundColor Cyan & "$scriptsPath\build.ps1" all -Rebuild - return $LASTEXITCODE + if ($LASTEXITCODE -ne 0) + { + Write-Host "Failed to build OpenRCT2" -ForegroundColor Red + return 1 + } + + if ($CodeSign) + { + $releaseDir = "$rootPath\bin" + $exePath = "$releaseDir\openrct2.exe" + $dllPath = "$releaseDir\openrct2.dll" + + if (-not (Sign-Binary($exePath))) { return 1 } + if (-not (Sign-Binary($dllPath))) { return 1 } + } + + return 0 } # Package @@ -121,7 +138,9 @@ function Do-Installer() New-Item -Force -ItemType Directory $artifactsDir > $null # Create installer - & "$installerDir\build.ps1" -BuildNumber $BuildNumber -GitBranch $GitBranch + $GitCommitSha1Short = (git rev-parse --short HEAD) + $VersionExtra = "$GitBranch-$GitCommitSha1Short" + & "$installerDir\build.ps1" -VersionExtra $VersionExtra if ($LASTEXITCODE -ne 0) { Write-Host "Failed to create installer." -ForegroundColor Red @@ -139,7 +158,14 @@ function Do-Installer() return 1 } - Move-Item $binaries[0].FullName $artifactsDir + $installerPath = $binaries[0].FullName + + if ($CodeSign) + { + if (-not (Sign-Binary($installerPath))) { return 1 } + } + + Move-Item -Force $installerPath $artifactsDir return 0 } @@ -170,6 +196,47 @@ function Do-Task-All() return 0 } +function Sign-Binary($binaryPath) +{ + $pfxPath = "$rootPath\distribution\windows\code-sign-key-openrct2.org.pfx" + $pfxPassword = ${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD} + $timestampUrl = "http://timestamp.comodoca.com/authenticode" + + if (-not (Test-Path -PathType Leaf $pfxPath)) + { + Write-Host "Unable to sign, code signature key was not found." -ForegroundColor Red + return 1 + } + + if ($pfxPassword -eq $null) + { + Write-Host "Unable to sign, %CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD% was not set." -ForegroundColor Red + return 1 + } + + # Resolve signtool path + $signtoolcmd = "signtool" + if (-not (AppExists($signtoolcmd))) + { + $signtoolcmd = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\SignTool.exe" + if (-not (AppExists($signtoolcmd))) + { + Write-Host "Publish script requires signtool to be in PATH" -ForegroundColor Red + return 1 + } + } + + # Sign the binary + & $signtoolcmd sign /f $pfxPath /p $pfxPassword /t $timestampUrl $binaryPath + if ($LASTEXITCODE -ne 0) + { + Write-Host "Failed to sign binary." -ForegroundColor Red + return 1 + } + + return 0 +} + # Script entry point switch ($Task) { From 818ff719c2da47f06c0e15101f4879da80ee7fc3 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 26 Jan 2016 23:12:52 +0000 Subject: [PATCH 2/5] add pushing of builds to OpenRCT2.org --- appveyor.yml | 6 ++++-- scripts/ps/appveyor_run.ps1 | 32 ++++++++++++++++++++++++++++++++ scripts/ps/publish.ps1 | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4ec9361b08..ebc413671f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,10 +5,12 @@ environment: secure: saYAIpqXzpq0U+JH+MNi/isRQ6Y51PZhm4BrnePDiAPptFO5htxFOLegrYqxdy67 CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD: secure: bzYmf0ElxisSGyZnIjUOYQ== + OPENRCT2.ORG_TOKEN: + secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw== install: - nuget install secure-file -ExcludeVersion -- secure-file\tools\secure-file -decrypt distribution\windows\code-sign-key-openrct2.org.pfx.enc -secret %enckey% -- cinst nsis.portable -pre +- secure-file\tools\secure-file -decrypt distribution\windows\code-sign-key-openrct2.org.pfx.enc -secret %ENCKEY% +- cinst nsis.portable -pre > nul - ps: >- curl "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip" -OutFile nsisxtra.zip diff --git a/scripts/ps/appveyor_run.ps1 b/scripts/ps/appveyor_run.ps1 index 97724a7197..d69b8c128b 100644 --- a/scripts/ps/appveyor_run.ps1 +++ b/scripts/ps/appveyor_run.ps1 @@ -2,6 +2,22 @@ # Script to build OpenRCT2 on AppVeyor ######################################################### +function Push-Build($file, $name, $version, $flavourId) +{ + curl.exe -s -o - ` + --form "key=${env:OPENRCT2.ORG_TOKEN}" ` + --form "fileName=$name" ` + --form "version=$version" ` + --form "gitHash=${env:APPVEYOR_REPO_COMMIT}" ` + --form "gitBranch=${env:APPVEYOR_REPO_BRANCH}" ` + --form "flavourId=$flavourId" ` + --form "file=@$file" ` + "https://openrct2.org/altapi/?command=push-build" +} + +# Provide a short commit SHA1 too +${env:APPVEYOR_REPO_COMMIT_SHORT} = (${env:APPVEYOR_REPO_COMMIT}).Substring(0, 7) + # Install dependencies install -Quiet @@ -30,3 +46,19 @@ publish package ` -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` -GitBranch $env:APPVEYOR_REPO_BRANCH ` -CodeSign + +$version = "0.0.4.0" +$pushFileName = "OpenRCT2-$version-windows-${env:APPVEYOR_REPO_COMMIT_SHORT}" + +# Push portable zip +Write-Host "Sending portable zip to OpenRCT2.org" -ForegroundColor Cyan +Push-Build -file ".\artifacts\openrct2.zip" ` + -name "$pushFileName.zip" ` + -version $version ` + -flavourId 1 + +Write-Host "Sending installer to OpenRCT2.org" -ForegroundColor Cyan +Push-Build -file ".\artifacts\openrct2-install.exe" ` + -name "$pushFileName.exe" ` + -version $version ` + -flavourId 2 diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index ce77846642..bd70effaf9 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -165,7 +165,7 @@ function Do-Installer() if (-not (Sign-Binary($installerPath))) { return 1 } } - Move-Item -Force $installerPath $artifactsDir + Move-Item -Force $installerPath "$artifactsDir\openrct2-install.exe" return 0 } From 7e0d49ecc6e6e06d34216fa36e0876c3c313a9e1 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 27 Jan 2016 18:47:06 +0000 Subject: [PATCH 3/5] replace build number with branch, commit or tag --- appveyor.yml | 2 +- scripts/ps/appveyor_run.ps1 | 120 ++++++++++++++++++++++++++++-------- scripts/ps/publish.ps1 | 69 ++++++++++++++------- 3 files changed, 142 insertions(+), 49 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ebc413671f..ae5bb97bfc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ install: - ps: >- curl "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip" -OutFile nsisxtra.zip - 7z x nsisxtra.zip + 7z x nsisxtra.zip > $null cp FindProcDLL.dll "C:\ProgramData\chocolatey\lib\nsis.portable\tools\nsis-3.0b1\Plugins\x86-ansi" build_script: diff --git a/scripts/ps/appveyor_run.ps1 b/scripts/ps/appveyor_run.ps1 index d69b8c128b..baab8d99bb 100644 --- a/scripts/ps/appveyor_run.ps1 +++ b/scripts/ps/appveyor_run.ps1 @@ -15,18 +15,61 @@ function Push-Build($file, $name, $version, $flavourId) "https://openrct2.org/altapi/?command=push-build" } +$server = "AppVeyor" + # Provide a short commit SHA1 too ${env:APPVEYOR_REPO_COMMIT_SHORT} = (${env:APPVEYOR_REPO_COMMIT}).Substring(0, 7) +# Current version +$version = "0.0.4.0" + +# Tagged builds will hide branch and commit SHA1 +$tag = $null +if (${env:APPVEYOR_REPO_TAG} -ne $null) +{ + $tag = ${env:APPVEYOR_REPO_TAG_NAME} +} + +# Enable code signing if password environment variable is set +$codeSign = $false +if (${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD} -ne $null) +{ + $codeSign = $true +} + +# Enable pushing builds to OpenRCT2.org if token environment variable is set +$pushBuilds = $false +$installer = $false +if (${env:OPENRCT2.ORG_TOKEN} -ne $null) +{ + $pushBuilds = $true + $installer = $true +} + +# Write out summary of the build +Write-Host "AppVeyor CI Build" -ForegroundColor Green +if ($tag -ne $null) +{ + Write-Host " $version-$tag" -ForegroundColor Green +} +else +{ + Write-Host " $version-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT_SHORT" -ForegroundColor Green +} +Write-Host " Signed: $codeSign" -ForegroundColor Green +Write-Host " Push : $pushBuilds" -ForegroundColor Green + # Install dependencies install -Quiet # Build OpenRCT2 publish build ` - -Server AppVeyor ` - -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` - -GitBranch $env:APPVEYOR_REPO_BRANCH ` - -CodeSign + -Server $server ` + -GitTag $tag ` + -GitBranch $env:APPVEYOR_REPO_BRANCH ` + -GitSha1 $env:APPVEYOR_REPO_COMMIT ` + -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT ` + -CodeSign $codeSign if ($LASTEXITCODE -ne 0) { @@ -34,31 +77,54 @@ if ($LASTEXITCODE -ne 0) } # Create a Portable ZIP -publish package ` - -Server AppVeyor ` - -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` - -GitBranch $env:APPVEYOR_REPO_BRANCH +publish package ` + -Server $server ` + -GitTag $tag ` + -GitBranch $env:APPVEYOR_REPO_BRANCH ` + -GitSha1 $env:APPVEYOR_REPO_COMMIT ` + -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT ` + -CodeSign $codeSign # Create an Installer -publish package ` - -Installer ` - -Server AppVeyor ` - -BuildNumber $env:APPVEYOR_BUILD_NUMBER ` - -GitBranch $env:APPVEYOR_REPO_BRANCH ` - -CodeSign +if ($installer) +{ + publish package ` + -Installer ` + -Server $server ` + -GitTag $tag ` + -GitBranch $env:APPVEYOR_REPO_BRANCH ` + -GitSha1 $env:APPVEYOR_REPO_COMMIT ` + -GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT ` + -CodeSign $codeSign +} -$version = "0.0.4.0" -$pushFileName = "OpenRCT2-$version-windows-${env:APPVEYOR_REPO_COMMIT_SHORT}" +if ($pushBuilds) +{ + $versionExtension = "" + if ($tag -ne $null) + { + $versionExtension = "-$tag" + } + else + { + $versionExtension = "-${env:APPVEYOR_REPO_BRANCH}-${env:APPVEYOR_REPO_COMMIT_SHORT}" + } + $pushFileName = "OpenRCT2-${version}${versionExtension}-windows" -# Push portable zip -Write-Host "Sending portable zip to OpenRCT2.org" -ForegroundColor Cyan -Push-Build -file ".\artifacts\openrct2.zip" ` - -name "$pushFileName.zip" ` - -version $version ` - -flavourId 1 + # Push portable zip + Write-Host "Sending portable zip to OpenRCT2.org" -ForegroundColor Cyan + Push-Build -file ".\artifacts\openrct2.zip" ` + -name "$pushFileName.zip" ` + -version $version ` + -flavourId 1 -Write-Host "Sending installer to OpenRCT2.org" -ForegroundColor Cyan -Push-Build -file ".\artifacts\openrct2-install.exe" ` - -name "$pushFileName.exe" ` - -version $version ` - -flavourId 2 + # Push installer + if ($installer) + { + Write-Host "Sending installer to OpenRCT2.org" -ForegroundColor Cyan + Push-Build -file ".\artifacts\openrct2-install.exe" ` + -name "$pushFileName.exe" ` + -version $version ` + -flavourId 2 + } +} diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index bd70effaf9..a0e2a3532c 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -6,15 +6,33 @@ ######################################################### param ( [Parameter(Position = 1)] - [string]$Task = "all", + [string]$Task = "all", - [string]$Server = "", - [string]$BuildNumber = "", - [string]$GitBranch = "", - [switch]$Installer = $false, - [switch]$CodeSign = $false + [string]$Server = "", + [string]$GitTag = "", + [string]$GitBranch = "", + [string]$GitSha1 = "", + [string]$GitSha1Short = "", + [bool] $CodeSign = $false, + [switch]$Installer = $false ) +if ($GitTag -eq "") +{ + if ($GitBranch -eq $null) + { + $GitBranch = (git rev-parse --abbrev-ref HEAD) + } + if ($GitCommitSha1 -eq $null) + { + $GitCommitSha1 = (git rev-parse HEAD) + } + if ($GitCommitSha1Short -eq $null) + { + $GitCommitSha1Short = (git rev-parse --short HEAD) + } +} + # Setup $ErrorActionPreference = "Stop" $scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path @@ -27,19 +45,18 @@ $rootPath = Get-RootPath function Do-PrepareSource() { Write-Host "Setting build #defines..." -ForegroundColor Cyan - if ($GitBranch -eq "") - { - $GitBranch = (git rev-parse --abbrev-ref HEAD) - } - $GitCommitSha1 = (git rev-parse HEAD) - $GitCommitSha1Short = (git rev-parse --short HEAD) - $defines = @{ } - $defines["OPENRCT2_BUILD_NUMBER"] = $BuildNumber; - $defines["OPENRCT2_BUILD_SERVER"] = $Server; - $defines["OPENRCT2_BRANCH"] = $GitBranch; - $defines["OPENRCT2_COMMIT_SHA1"] = $GitCommitSha1; - $defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $GitCommitSha1Short; + $defines["OPENRCT2_BUILD_SERVER"] = $Server; + if ($GitTag -ne "") + { + $defines["OPENRCT2_BRANCH"] = $GitTag; + } + else + { + $defines["OPENRCT2_BRANCH"] = $GitBranch; + $defines["OPENRCT2_COMMIT_SHA1"] = $GitCommitSha1; + $defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $GitCommitSha1Short; + } $defineString = "" foreach ($key in $defines.Keys) { @@ -52,6 +69,7 @@ function Do-PrepareSource() # Set the environment variable which the msbuild project will use $env:OPENRCT2_DEFINES = $defineString; + return 0 } @@ -115,7 +133,7 @@ function Do-Package() return 1 } } - & $7zcmd a -tzip -mx9 $outZip "$tempDir\*" | Write-Host + & $7zcmd a -tzip -mx9 $outZip "$tempDir\*" > $null if ($LASTEXITCODE -ne 0) { Write-Host "Failed to create zip." -ForegroundColor Red @@ -137,9 +155,18 @@ function Do-Installer() # Create artifacts directory New-Item -Force -ItemType Directory $artifactsDir > $null + # Resolve version extension + $VersionExtra = "" + if ($GitTag -ne "") + { + $VersionExtra = "$GitTag" + } + else + { + $VersionExtra = "$GitBranch-$GitCommitSha1Short" + } + # Create installer - $GitCommitSha1Short = (git rev-parse --short HEAD) - $VersionExtra = "$GitBranch-$GitCommitSha1Short" & "$installerDir\build.ps1" -VersionExtra $VersionExtra if ($LASTEXITCODE -ne 0) { From 95b5140fb1bcb949bac178c0fa8ca52d9d2062f2 Mon Sep 17 00:00:00 2001 From: Jarno Veuger Date: Wed, 27 Jan 2016 01:30:01 +0100 Subject: [PATCH 4/5] Skip upgrade/downgrade process in installer for now --- distribution/windows/install.nsi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi index 8b8917aef3..4be5f34ee5 100644 --- a/distribution/windows/install.nsi +++ b/distribution/windows/install.nsi @@ -461,7 +461,9 @@ Function .onInit ; Starts Setup - let's look for an older version of OpenRCT2 ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Version" - IfErrors ShowWelcomeMessage ShowUpgradeMessage + ; Skip upgrade checking for now + ;IfErrors ShowWelcomeMessage ShowUpgradeMessage + Goto ShowWelcomeMessage ShowWelcomeMessage: ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Version" IfErrors FinishCallback @@ -488,6 +490,8 @@ DoUninstall: ; You have the same version as this installer. This allows you to Quit InstallerIsOlder: + ; A newer version was found. Let's let the user know there's an downgrade that will take place. + ReadRegStr $OLDVERSION HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayVersion" ;MessageBox MB_OK|MB_ICONSTOP \ ; "You have a newer version of ${APPNAME}.$\nSetup will now exit." ;Quit From c9a532a180b06d01630f04160ca5e8adf65e8953 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 13 Feb 2016 18:50:00 +0000 Subject: [PATCH 5/5] don't decrypt sign key for PRs --- appveyor.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ae5bb97bfc..2a883cc798 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,9 +8,10 @@ environment: OPENRCT2.ORG_TOKEN: secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw== install: -- nuget install secure-file -ExcludeVersion -- secure-file\tools\secure-file -decrypt distribution\windows\code-sign-key-openrct2.org.pfx.enc -secret %ENCKEY% -- cinst nsis.portable -pre > nul +- cmd: >- + IF DEFINED ENCKEY ( nuget install secure-file -ExcludeVersion && secure-file\tools\secure-file -decrypt distribution\windows\code-sign-key-openrct2.org.pfx.enc -secret %ENCKEY% ) + + cinst nsis.portable -pre > nul - ps: >- curl "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip" -OutFile nsisxtra.zip