forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor.yml
226 lines (204 loc) · 11.9 KB
/
appveyor.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
init:
# Only save build cache on master branch
- ps: IF ($env:APPVEYOR_REPO_BRANCH -ne "master") {$env:APPVEYOR_CACHE_SKIP_SAVE = "true"}
environment:
global:
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma -mx=4
matrix:
# 32-bit (x86) builds
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
WZ_JOB_ID: release_x86
wz_deploy_build: true
# NOTE: Additional environment variables are set later to maintain consistent job identifiers
## NOTE: Unfortunately, 64-bit Windows builds are currently broken because of QScript (see: http://developer.wz2100.net/ticket/4763)
## Whenever that ticket is resolved, the following will build 64-bit:
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
# WZ_JOB_ID: release_x64
# Cache
# - Maintains a separate cache for each build matrix entry
#
# To manually clear the project's cache, open the Javascript console when logged-in to AppVeyor, and execute:
# $.ajax({ url: 'https://ci.appveyor.com/api/projects/<username>/<project>/buildcache', type: 'DELETE'})
# For more, see: https://github.com/appveyor/ci/issues/985
cache:
# 1. The vcpkg directory
# - Cache built dependencies to reduce frequent build time by 20+ minutes.
# - The vcpkg cache is invalidated if get-dependencies_win.ps1 changes (and get-dependencies_win.ps1 is what contains the pinned vcpkg commit).
- vcpkg/ -> get-dependencies_win.ps1
platform:
- x64
configuration:
- Release
install:
# Initialize Git submodules
- git submodule update --init --recursive
# Download & install Vulkan SDK
- ps: |
Function Req {
Param(
[Parameter(Mandatory=$True)]
[hashtable]$Params,
[int]$Retries = 1,
[int]$SecondsDelay = 2
)
$method = $Params['Method']
$url = $Params['Uri']
$cmd = { Write-Host "$method $url..." -NoNewline; Invoke-WebRequest @Params }
$retryCount = 0
$completed = $false
$response = $null
while (-not $completed) {
try {
$response = Invoke-Command $cmd -ArgumentList $Params
#if ($response.StatusCode -ne 200) {
# throw "Expecting reponse code 200, was: $($response.StatusCode)"
#}
$completed = $true
} catch {
Write-Host $_.Exception.GetType().FullName
Write-Host $_.Exception.Message
if ($retrycount -ge $Retries) {
Write-Warning "Request to $url failed the maximum number of $retryCount times."
throw
} else {
Write-Warning "Request to $url failed. Retrying in $SecondsDelay seconds."
Start-Sleep $SecondsDelay
$retrycount++
}
}
}
Write-Host "OK ($($response.StatusCode))"
return $response
}
$VULKAN_DL_URL = "https://sdk.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true"
$VULKAN_DL_SHA256 = "92ce6080dc2aebfb0a63dba705b8d50a04cfafa1710acbb3b4fa413b388ff2cd"
$req = Req -Params @{ 'Method'='GET';'Uri'="$VULKAN_DL_URL";'OutFile'='vulkan.exe' } -Retries 3 -SecondsDelay 10
$vulkan_exe_hash = Get-FileHash -Path "vulkan.exe" -Algorithm SHA256
If ($vulkan_exe_hash.Hash -eq $VULKAN_DL_SHA256) {
Write-Output "Successfully downloaded VulkanSDK installer"
} Else {
Write-Error "The downloaded VulkanSDK installer hash '$($vulkan_exe_hash.Hash)' does not match the expected hash: '$VULKAN_DL_SHA256'"
}
- cmd: |
.\vulkan.exe /S
refreshenv
echo %VULKAN_SDK%
# Setup Ruby path (for Asciidoctor gem install)
- set PATH=C:\Ruby26-x64\bin;%PATH%
# Install Asciidoctor (for documentation generation)
# NOTE: Specify an explicit Asciidoctor version to help ensure reproducible builds
- gem install asciidoctor -v 2.0.10 --no-document
before_build:
# Set expanded environment variables for release build jobs
# NOTE: These are set here, instead of in the build matrix above, to maintain consistent job identifiers for release builds
# (as the job is identified based on the environment configuration in the matrix)
- ps: |
Write-Host "env:WZ_JOB_ID='$env:WZ_JOB_ID'"
if ($env:WZ_JOB_ID -eq "release_x86_xp") {
# 32-bit (x86) builds maintain Windows XP compatibility by using Qt 5.6.x and the "*_xp" VC toolchain
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
# TODO: Change VCPKG_DEFAULT_TRIPLET to one that supports XP once https://github.com/Microsoft/vcpkg/pull/1732 is finalized & merged.
$env:VCPKG_DEFAULT_TRIPLET = "x86-windows"
$env:WZ_VC_GENERATOR = "Visual Studio 15 2017"
$env:QT5DIR = "C:\Qt\5.6\msvc2015"
$env:WZ_VC_TOOLCHAIN = "v141_xp"
$env:WZ_VC_TARGET_PLATFORMNAME = "Win32"
$env:WZ_OUTPUT_PLATFORMNAME = "x86"
}
elseif ($env:WZ_JOB_ID -eq "release_x86") {
# 32-bit (x86) builds use more recent Qt and the latest VC toolchain (and support Windows 7+)
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
$env:VCPKG_DEFAULT_TRIPLET = "x86-windows"
$env:WZ_VC_GENERATOR = "Visual Studio 16 2019"
$env:QT5DIR = "C:\Qt\5.9\msvc2015"
$env:WZ_VC_TOOLCHAIN = "v142"
$env:WZ_VC_TARGET_PLATFORMNAME = "Win32"
$env:WZ_OUTPUT_PLATFORMNAME = "x86"
}
elseif ($env:WZ_JOB_ID -eq "release_x64") {
# 64-bit (x64) builds use the latest Qt and VC toolchain (and support Windows 7+)
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
$env:VCPKG_DEFAULT_TRIPLET = "x64-windows"
$env:WZ_VC_GENERATOR = "Visual Studio 16 2019"
$env:QT5DIR = "C:\Qt\5.9\msvc2017_64"
$env:WZ_VC_TOOLCHAIN = "v142"
$env:WZ_VC_TARGET_PLATFORMNAME = "x64"
$env:WZ_OUTPUT_PLATFORMNAME = "x64"
}
# Set distributor (if building from the main repo)
- ps: |
$env:WZ_DISTRIBUTOR = "UNKNOWN"
if ($env:APPVEYOR_ACCOUNT_NAME -eq "Warzone2100") {
$env:WZ_DISTRIBUTOR = "wz2100.net"
}
# Add the QT5 \bin dir to PATH
- set PATH=%PATH%;%QT5DIR%\bin;
# If a future version of vcpkg breaks the "VCPKG_BUILD_TYPE=release" setting for the dependencies we need, use the following line instead:
# - ps: .\get-dependencies_win.ps1
- ps: .\get-dependencies_win.ps1 -VCPKG_BUILD_TYPE "release"
# Remove the vcpkg\buildtrees folder. (Once all dependencies are installed, it isn't needed, and it takes up a lot of space in the cache.)
- ps: if (Test-Path .\vcpkg\buildtrees) { Remove-Item .\vcpkg\buildtrees -Force -Recurse -ErrorAction SilentlyContinue; }
# Clean the build remnants of vcpkg itself. (Since it's rebuilt fresh - even from a cached vcpkg directory - these aren't needed.)
- msbuild .\vcpkg\toolsrc\vcpkg.sln /t:Clean /p:Configuration=Release /p:Platform=x86
# Use CMake to configure with the appropriate Visual Studio (MSBUILD) generator, toolchain, and target platform (portable build)
- cmake -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="%APPVEYOR_BUILD_FOLDER%\vcpkg\scripts\buildsystems\vcpkg.cmake" -DWZ_PORTABLE:BOOL=ON -DCPACK_PACKAGE_FILE_NAME:STRING="warzone2100_portable" -DWZ_DISTRIBUTOR:STRING="%WZ_DISTRIBUTOR%" -G "%WZ_VC_GENERATOR%" -T "%WZ_VC_TOOLCHAIN%" -A "%WZ_VC_TARGET_PLATFORMNAME%"
build_script:
- msbuild build/PACKAGE.vcxproj -m /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /nowarn:MSB8065,MSB8064
after_build:
# Determine the build output description
# Base on the platform name: warzone2100_win_<PLATFORM: x86, x64>_<PORTABLE/INSTALLER>.exe (so it can go right to GitHub releases)
- ps: |
$env:WZ_BUILD_DESC = "win_$($env:WZ_OUTPUT_PLATFORMNAME)"
# Convert special characters
$env:WZ_BUILD_DESC = $env:WZ_BUILD_DESC.replace('/','_')
- ps: Write-Host "env:WZ_BUILD_DESC='$env:WZ_BUILD_DESC'"
# Rename the portable installer
- ps: Move-Item -LiteralPath "$($env:APPVEYOR_BUILD_FOLDER)\build\warzone2100_portable.exe" -Destination "warzone2100_$($env:WZ_BUILD_DESC)_portable.exe"
# Package the portable .pdb and .sym files into a "DEBUGSYMBOLS" .7z archive (do not include metadata / timestamps)
- ps: cmd /c 7z a -t7z -m0=lzma -mx=9 -mtc=off -mtm=off -mta=off "warzone2100_$($env:WZ_BUILD_DESC)_portable.DEBUGSYMBOLS.7z" "$($env:APPVEYOR_BUILD_FOLDER)\build\src\*.pdb" "$($env:APPVEYOR_BUILD_FOLDER)\build\src\*.sym"
# Re-run CMake configure for non-portable (regular) installer
- cmake -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="%APPVEYOR_BUILD_FOLDER%\vcpkg\scripts\buildsystems\vcpkg.cmake" -DWZ_PORTABLE:BOOL=OFF -DCPACK_PACKAGE_FILE_NAME:STRING="warzone2100_installer" -DWZ_DISTRIBUTOR:STRING="%WZ_DISTRIBUTOR%" -G "%WZ_VC_GENERATOR%" -T "%WZ_VC_TOOLCHAIN%" -A "%WZ_VC_TARGET_PLATFORMNAME%"
# Build the regular installer package (this should only rebuild the installer itself)
- msbuild build/PACKAGE.vcxproj -m /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /nowarn:MSB8065,MSB8064
# Rename the regular installer
- ps: Move-Item -LiteralPath "$($env:APPVEYOR_BUILD_FOLDER)\build\warzone2100_installer.exe" -Destination "warzone2100_$($env:WZ_BUILD_DESC)_installer.exe"
# Package the regular installer .pdb and .sym files into a "DEBUGSYMBOLS" .7z archive (do not include metadata / timestamps)
- ps: cmd /c 7z a -t7z -m0=lzma -mx=9 -mtc=off -mtm=off -mta=off "warzone2100_$($env:WZ_BUILD_DESC)_installer.DEBUGSYMBOLS.7z" "$($env:APPVEYOR_BUILD_FOLDER)\build\src\*.pdb" "$($env:APPVEYOR_BUILD_FOLDER)\build\src\*.sym"
# Compare the two DEBUGSYMBOLS.7z files
# If they are equal (as they should be if only the installer was rebuilt), keep only one and remove the "PORTABLE/INSTALLER" suffix
# If they are not equal, we have to keep both (but output a notice, as the CMake build should probably be tweaked to avoid this)
- ps: |
if ((Get-FileHash -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_portable.DEBUGSYMBOLS.7z" -Algorithm SHA512).Hash -eq (Get-FileHash -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_installer.DEBUGSYMBOLS.7z" -Algorithm SHA512).Hash) {
# The two archives' hashes match - delete one, and rename the other
Write-Host "DEBUGSYMBOLS.7z files match"
Remove-Item -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_installer.DEBUGSYMBOLS.7z" -Force -ErrorAction SilentlyContinue
Rename-Item -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_portable.DEBUGSYMBOLS.7z" -NewName "warzone2100_$($env:WZ_BUILD_DESC).DEBUGSYMBOLS.7z"
}
else {
Write-Warning "The DEBUGSYMBOLS.7z files for the portable + regular builds do not match. This may mean that the executable was rebuilt when switching portable / non-portable mode. (Check the CMake scripts to fix.)"
}
# Log hashes of the setup EXEs
- ps: |
Write-Host "SHA512 Hashes:"
Write-Host "`nwarzone2100-$($env:WZ_BUILD_DESC)_portable.exe`n -> SHA512: $((Get-FileHash -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_portable.exe" -Algorithm SHA512).Hash)`n -> Size (bytes): $((Get-Item -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_portable.exe").Length)"
Write-Host "`nwarzone2100-$($env:WZ_BUILD_DESC)_installer.exe`n -> SHA512: $((Get-FileHash -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_installer.exe" -Algorithm SHA512).Hash)`n -> Size (bytes): $((Get-Item -LiteralPath "warzone2100_$($env:WZ_BUILD_DESC)_installer.exe").Length)"
Write-Host ""
artifacts:
- path: warzone2100_*_portable.exe
name: Warzone2100 Portable
- path: warzone2100_*_installer.exe
name: Warzone2100 Installer
- path: warzone2100_*.DEBUGSYMBOLS.7z
name: Debug Symbols (7z)
# deploy:
# # description: ''
# provider: GitHub
# auth_token:
# secure: udWZCPk8pkXCIS0eL88yQ+95q9BkAHaCCQLA/W2zd9XsHYS7wMbLYOATnbuRRD0S
# artifact: /warzone2100_.*\..*/
# draft: true
# prerelease: false
# force_update: true
# on:
# APPVEYOR_REPO_TAG: true # deploy on tag push only
# wz_deploy_build: true