| 1 |
/* Copyright (C) 2025 Wildfire Games. |
| 2 |
* This file is part of 0 A.D. |
| 3 |
* |
| 4 |
* 0 A.D. is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* 0 A.D. is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
// This pipeline is used to generate bundles (Windows installer, macOS package, and source tarballs). |
| 19 |
|
| 20 |
// On macOS, binaries are built for both architectures, the native one is used for packaging archives. |
| 21 |
// On Windows, the win32 binary is rebuilt for patch releases, and the win64 one in all cases. |
| 22 |
|
| 23 |
def visualStudioPath = '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"' |
| 24 |
def buildOptions = '/p:PlatformToolset=v143 /t:pyrogenesis /t:AtlasUI %JOBS% /nologo -clp:Warningsonly -clp:ErrorsOnly' |
| 25 |
|
| 26 |
pipeline { |
| 27 |
agent { |
| 28 |
node { |
| 29 |
label 'macOSAgentVentura' |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
// Archive the installer for public download; keep only the latest one. |
| 34 |
options { |
| 35 |
buildDiscarder logRotator(artifactNumToKeepStr: '1') |
| 36 |
skipDefaultCheckout true |
| 37 |
} |
| 38 |
|
| 39 |
parameters { |
| 40 |
string(name: 'BUNDLE_VERSION', defaultValue: '0.28.0dev', description: 'Bundle Version') |
| 41 |
string(name: 'NIGHTLY_REVISION', defaultValue: 'HEAD', description: 'Nightly SVN revision from which to build the bundles') |
| 42 |
booleanParam(name: 'PATCH_BUILD', defaultValue: false, description: 'Apply patch generated from upstream job patch-release onto the nightly build') |
| 43 |
booleanParam(name: 'DO_GZIP', defaultValue: true, description: 'Create .gz unix tarballs as well as .xz') |
| 44 |
} |
| 45 |
|
| 46 |
environment { |
| 47 |
MIN_OSX_VERSION = '10.15' |
| 48 |
} |
| 49 |
|
| 50 |
stages { |
| 51 |
stage('Checkout Nightly Build') { |
| 52 |
steps { |
| 53 |
checkout changelog: false, poll: false, scm: [ |
| 54 |
$class: 'SubversionSCM', |
| 55 |
locations: [[local: '.', remote: "https://svn.wildfiregames.com/nightly-build/trunk@${NIGHTLY_REVISION}"]], |
| 56 |
quietOperation: false, |
| 57 |
workspaceUpdater: [$class: 'UpdateWithCleanUpdater']] |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
stage('Patch Nightly Build') { |
| 62 |
when { |
| 63 |
expression { return params.PATCH_BUILD } |
| 64 |
} |
| 65 |
steps { |
| 66 |
copyArtifacts projectName: '0ad-patch-release', selector: upstream() |
| 67 |
sh "svn patch ${BUNDLE_VERSION}.patch" |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
stage('Compile Native macOS Executable') { |
| 72 |
steps { |
| 73 |
sh "cd libraries/ && MIN_OSX_VERSION=${env.MIN_OSX_VERSION} ./build-macos-libs.sh ${JOBS} --force-rebuild" |
| 74 |
sh "cd build/workspaces/ && ./update-workspaces.sh --macosx-version-min=${env.MIN_OSX_VERSION}" |
| 75 |
sh "cd build/workspaces/gcc/ && make ${JOBS}" |
| 76 |
sh 'svn cleanup --remove-unversioned build' |
| 77 |
sh 'svn cleanup --remove-unversioned libraries' |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
stage('Create Mod Archives') { |
| 82 |
steps { |
| 83 |
sh 'source/tools/dist/build-archives.sh' |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
stage('Create Native macOS Bundle') { |
| 88 |
steps { |
| 89 |
withCredentials([ |
| 90 |
string(credentialsId: 'apple-keychain', variable: 'KEYCHAIN_PW'), |
| 91 |
string(credentialsId: 'apple-signing', variable: 'SIGNKEY_SHA'), |
| 92 |
usernamePassword(credentialsId: 'apple-notarization', passwordVariable: 'NOTARIZATION_PW', usernameVariable: 'NOTARIZATION_USER')]) |
| 93 |
{ |
| 94 |
sh ''' |
| 95 |
security unlock-keychain -p ${KEYCHAIN_PW} login.keychain |
| 96 |
/opt/wfg/venv/bin/python3 source/tools/dist/build-osx-bundle.py \ |
| 97 |
--min_osx=${MIN_OSX_VERSION} \ |
| 98 |
-s ${SIGNKEY_SHA} \ |
| 99 |
--notarytool_user=${NOTARIZATION_USER} \ |
| 100 |
--notarytool_team=P7YF26GARW \ |
| 101 |
--notarytool_password=${NOTARIZATION_PW} \ |
| 102 |
${BUNDLE_VERSION} |
| 103 |
''' |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
stage('Compile Intel macOS Executable') { |
| 109 |
environment { |
| 110 |
ARCH = 'x86_64' |
| 111 |
HOSTTYPE = 'x86_64' |
| 112 |
} |
| 113 |
steps { |
| 114 |
sh "cd libraries/ && MIN_OSX_VERSION=${env.MIN_OSX_VERSION} ./build-macos-libs.sh ${JOBS} --force-rebuild" |
| 115 |
sh "cd build/workspaces/ && ./update-workspaces.sh --macosx-version-min=${env.MIN_OSX_VERSION}" |
| 116 |
sh 'cd build/workspaces/gcc/ && make clean' |
| 117 |
sh "cd build/workspaces/gcc/ && make ${JOBS}" |
| 118 |
sh 'svn cleanup --remove-unversioned build' |
| 119 |
sh 'svn cleanup --remove-unversioned libraries' |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
stage('Create Intel macOS Bundle') { |
| 124 |
steps { |
| 125 |
withCredentials([ |
| 126 |
string(credentialsId: 'apple-keychain', variable: 'KEYCHAIN_PW'), |
| 127 |
string(credentialsId: 'apple-signing', variable: 'SIGNKEY_SHA'), |
| 128 |
usernamePassword(credentialsId: 'apple-notarization', passwordVariable: 'NOTARIZATION_PW', usernameVariable: 'NOTARIZATION_USER')]) |
| 129 |
{ |
| 130 |
sh ''' |
| 131 |
security unlock-keychain -p ${KEYCHAIN_PW} login.keychain |
| 132 |
/opt/wfg/venv/bin/python3 source/tools/dist/build-osx-bundle.py \ |
| 133 |
--architecture=x86_64 \ |
| 134 |
--min_osx=${MIN_OSX_VERSION} \ |
| 135 |
-s ${SIGNKEY_SHA} \ |
| 136 |
--notarytool_user=${NOTARIZATION_USER} \ |
| 137 |
--notarytool_team=P7YF26GARW \ |
| 138 |
--notarytool_password=${NOTARIZATION_PW} \ |
| 139 |
${BUNDLE_VERSION} |
| 140 |
''' |
| 141 |
} |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
stage('Create Unix Tarballs') { |
| 146 |
steps { |
| 147 |
sh "BUNDLE_VERSION=${params.BUNDLE_VERSION} DO_GZIP=${params.DO_GZIP} source/tools/dist/build-unix-tarballs.sh" |
| 148 |
stash(name: 'unix-sources', includes: '*.tar.gz') |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
stage('Create AppImage') { |
| 153 |
stages { |
| 154 |
stage('Docker Setup') { |
| 155 |
agent { |
| 156 |
node { |
| 157 |
label 'LinuxAgent' |
| 158 |
customWorkspace 'workspace/appimage' |
| 159 |
} |
| 160 |
} |
| 161 |
steps { |
| 162 |
checkout scm |
| 163 |
sh 'git clean -dxf' |
| 164 |
sh 'docker build -t debian-12 -f build/jenkins/dockerfiles/debian-12.Dockerfile .' |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
stage('Build AppImage') { |
| 169 |
agent { |
| 170 |
dockerfile { |
| 171 |
label 'LinuxAgent' |
| 172 |
customWorkspace 'workspace/appimage' |
| 173 |
dir 'build/jenkins/dockerfiles' |
| 174 |
filename 'debian-12-appimage.Dockerfile' |
| 175 |
// Prevent Jenkins from running commands with the UID of the host's jenkins user |
| 176 |
// https://stackoverflow.com/a/42822143 |
| 177 |
args '-u root' |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
steps { |
| 182 |
unstash('unix-sources') |
| 183 |
untar(dir: 'appimage-build', file: "0ad-${params.BUNDLE_VERSION}-unix-build.tar.gz", keepPermissions: true) |
| 184 |
untar(dir: 'appimage-build', file: "0ad-${params.BUNDLE_VERSION}-unix-data.tar.gz", keepPermissions: true) |
| 185 |
|
| 186 |
sh "source/tools/dist/build-appimage.sh --version ${params.BUNDLE_VERSION} --root appimage-build/0ad-${params.BUNDLE_VERSION}" |
| 187 |
stash(name: 'appimage', includes: '*AppImage') |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
stage('Create Windows Installers') { |
| 194 |
stages { |
| 195 |
stage('32-bit rebuild') { |
| 196 |
when { |
| 197 |
expression { return params.PATCH_BUILD } |
| 198 |
} |
| 199 |
agent { |
| 200 |
node { |
| 201 |
label 'WindowsAgent' |
| 202 |
customWorkspace 'workspace/win32-bundle-build' |
| 203 |
} |
| 204 |
} |
| 205 |
steps { |
| 206 |
bat "svn co https://svn.wildfiregames.com/nightly-build/trunk@${NIGHTLY_REVISION} ." |
| 207 |
bat 'svn revert -R .' |
| 208 |
bat 'svn cleanup --remove-unversioned' |
| 209 |
|
| 210 |
copyArtifacts projectName: '0ad-patch-release', selector: upstream() |
| 211 |
bat "svn patch ${params.BUNDLE_VERSION}.patch" |
| 212 |
|
| 213 |
bat 'cd libraries && get-windows-libs.bat' |
| 214 |
bat '(robocopy E:\\wxWidgets-3.2.8\\lib libraries\\win32\\wxwidgets\\lib /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' |
| 215 |
bat '(robocopy E:\\wxWidgets-3.2.8\\include libraries\\win32\\wxwidgets\\include /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' |
| 216 |
bat 'cd build\\workspaces && update-workspaces.bat --without-pch --without-tests' |
| 217 |
bat "cd build\\workspaces\\vs2022 && ${visualStudioPath} pyrogenesis.sln /p:Configuration=Release ${buildOptions}" |
| 218 |
|
| 219 |
script { |
| 220 |
def modifiedFiles = bat(script:'@svn status', returnStdout: true).split('\n').collect { l -> l.drop(8).trim() }.join(', ') |
| 221 |
tar archive: true, compress: true, exclude: '*.orig, binaries/system/*.exp, binaries/system/*.lib, build/workspaces/vs2022, libraries/win32/**, libraries/win64/**', file: 'win32-rebuild.tar.gz', glob: modifiedFiles |
| 222 |
} |
| 223 |
stash name: 'win32-rebuild', includes: 'win32-rebuild.tar.gz' |
| 224 |
} |
| 225 |
post { |
| 226 |
cleanup { |
| 227 |
bat 'svn cleanup' |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
stage('32-bit installer') { |
| 233 |
steps { |
| 234 |
script { |
| 235 |
if (params.PATCH_BUILD) { |
| 236 |
unstash 'win32-rebuild' |
| 237 |
untar file: 'win32-rebuild.tar.gz', keepPermissions: false |
| 238 |
sh 'rm win32-rebuild.tar.gz' |
| 239 |
} |
| 240 |
} |
| 241 |
sh "BUNDLE_VERSION=${params.BUNDLE_VERSION} WINARCH=win32 source/tools/dist/build-win-installer.sh" |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
stage('64-bit build') { |
| 246 |
agent { |
| 247 |
node { |
| 248 |
label 'WindowsAgent' |
| 249 |
customWorkspace 'workspace/win64-bundle-build' |
| 250 |
} |
| 251 |
} |
| 252 |
environment { |
| 253 |
HOSTTYPE = 'amd64' |
| 254 |
} |
| 255 |
steps { |
| 256 |
bat "svn co https://svn.wildfiregames.com/nightly-build/trunk@${NIGHTLY_REVISION} ." |
| 257 |
bat 'svn revert -R .' |
| 258 |
bat 'svn cleanup --remove-unversioned' |
| 259 |
|
| 260 |
script { |
| 261 |
if (params.PATCH_BUILD) { |
| 262 |
copyArtifacts projectName: '0ad-patch-release', selector: upstream() |
| 263 |
bat "svn patch ${params.BUNDLE_VERSION}.patch" |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
bat 'cd libraries && get-windows-libs.bat --amd64' |
| 268 |
bat '(robocopy E:\\wxWidgets-3.2.8\\lib libraries\\win64\\wxwidgets\\lib /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' |
| 269 |
bat '(robocopy E:\\wxWidgets-3.2.8\\include libraries\\win64\\wxwidgets\\include /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' |
| 270 |
bat 'cd build\\workspaces && update-workspaces.bat --without-pch --without-tests' |
| 271 |
bat "cd build\\workspaces\\vs2022 && ${visualStudioPath} pyrogenesis.sln /p:Configuration=Release ${buildOptions}" |
| 272 |
|
| 273 |
script { |
| 274 |
def modifiedFiles = bat(script:'@svn status', returnStdout: true).split('\n').collect { l -> l.drop(8).trim() }.join(', ') |
| 275 |
tar archive: true, compress: true, exclude: '*.orig, binaries/system/*.exp, binaries/system/*.lib, build/workspaces/vs2022, libraries/win32/**, libraries/win64/**', file: 'win64-build.tar.gz', glob: modifiedFiles |
| 276 |
} |
| 277 |
stash name: 'win64-build', includes: 'win64-build.tar.gz' |
| 278 |
} |
| 279 |
post { |
| 280 |
cleanup { |
| 281 |
bat 'svn cleanup' |
| 282 |
} |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
stage('64-bit installer') { |
| 287 |
steps { |
| 288 |
unstash 'win64-build' |
| 289 |
untar file: 'win64-build.tar.gz', keepPermissions: false |
| 290 |
sh 'rm win64-build.tar.gz' |
| 291 |
|
| 292 |
sh "BUNDLE_VERSION=${params.BUNDLE_VERSION} WINARCH=win64 source/tools/dist/build-win-installer.sh" |
| 293 |
} |
| 294 |
} |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
stage('Generate Signatures and Checksums') { |
| 299 |
steps { |
| 300 |
unstash('appimage') |
| 301 |
withCredentials([sshUserPrivateKey(credentialsId: 'minisign-releases-key', keyFileVariable: 'MINISIGN_KEY', passphraseVariable: 'MINISIGN_PASS')]) { |
| 302 |
sh 'echo ${MINISIGN_PASS} | minisign -s ${MINISIGN_KEY} -Sm *.{AppImage,dmg,exe,tar.gz,tar.xz}' |
| 303 |
} |
| 304 |
sh 'for file in *.{AppImage,dmg,exe,tar.gz,tar.xz}; do md5sum "${file}" > "${file}".md5sum; done' |
| 305 |
sh 'for file in *.{AppImage,dmg,exe,tar.gz,tar.xz}; do sha1sum "${file}" > "${file}".sha1sum; done' |
| 306 |
sh 'for file in *.{AppImage,dmg,exe,tar.gz,tar.xz}; do sha256sum "${file}" > "${file}".sha256sum; done' |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
post { |
| 312 |
success { |
| 313 |
archiveArtifacts artifacts: '*AppImage,*.dmg,*.exe,*.tar.gz,*.tar.xz,*.minisig,*.md5sum,*.sha1sum,*.sha256sum', excludes: 'win32-rebuild.tar.gz,win64-build.tar.gz' |
| 314 |
} |
| 315 |
cleanup { |
| 316 |
sh 'svn revert -R .' |
| 317 |
sh 'svn cleanup --remove-unversioned' |
| 318 |
} |
| 319 |
} |
| 320 |
} |