| 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 the nightly builds. |
| 19 |
|
| 20 |
def visualStudioPath = '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"' |
| 21 |
def buildOptions = '/p:PlatformToolset=v143 /t:pyrogenesis /t:AtlasUI /t:ActorEditor %JOBS% /nologo -clp:Warningsonly -clp:ErrorsOnly' |
| 22 |
|
| 23 |
def gitHash = '' |
| 24 |
def buildSPIRV = false |
| 25 |
|
| 26 |
pipeline { |
| 27 |
agent { |
| 28 |
node { |
| 29 |
label 'WindowsAgent' |
| 30 |
customWorkspace 'workspace/nightly-build' |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
parameters { |
| 35 |
booleanParam(name: 'NEW_REPO', defaultValue: false, description: 'If a brand new nightly repo is being generated, do not attempt to identify unchanged translations.') |
| 36 |
stashedFile(name: 'spirv_rules', description: 'rules.json file for generation of SPIR-V shaders. Needed for a new repo, else the existing rules files will be used. Uploading a new rules file will force-rebuild the shaders.') |
| 37 |
} |
| 38 |
|
| 39 |
stages { |
| 40 |
stage('Generate build version') { |
| 41 |
steps { |
| 42 |
checkout scmGit(branches: [[name: "${GIT_BRANCH}"]], extensions: [cleanAfterCheckout(), localBranch()]) |
| 43 |
script { gitHash = bat(script:'@git rev-parse --short HEAD', returnStdout: true).trim() } |
| 44 |
bat 'cd build\\build_version && build_version.bat' |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
stage('Pull game assets') { |
| 49 |
steps { |
| 50 |
bat 'git lfs pull' |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
stage('Check for shader changes') { |
| 55 |
when { |
| 56 |
anyOf { |
| 57 |
changeset 'binaries/data/mods/**/shaders/**/*.xml' |
| 58 |
changeset 'source/tools/spirv/compile.py' |
| 59 |
} |
| 60 |
} |
| 61 |
steps { |
| 62 |
script { buildSPIRV = true } |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
stage('Pre-build') { |
| 67 |
steps { |
| 68 |
bat 'cd libraries && get-windows-libs.bat' |
| 69 |
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' |
| 70 |
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' |
| 71 |
bat 'cd build\\workspaces && update-workspaces.bat --without-pch --without-tests' |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
stage('Build') { |
| 76 |
steps { |
| 77 |
bat("cd build\\workspaces\\vs2022 && ${visualStudioPath} pyrogenesis.sln /p:Configuration=Release ${buildOptions}") |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
stage('Generate entity XML schema') { |
| 82 |
steps { |
| 83 |
bat 'cd binaries\\system && pyrogenesis.exe -mod=public -dumpSchema' |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
stage('Mirror to SVN') { |
| 88 |
steps { |
| 89 |
ws('workspace/nightly-svn') { |
| 90 |
bat 'svn co https://svn.wildfiregames.com/nightly-build/trunk .' |
| 91 |
bat 'svn revert -R .' |
| 92 |
script { env.NIGHTLY_PATH = env.WORKSPACE } |
| 93 |
} |
| 94 |
bat ''' |
| 95 |
(robocopy . %NIGHTLY_PATH% ^ |
| 96 |
/XD .git ^ |
| 97 |
/XF .gitattributes ^ |
| 98 |
/XF .gitignore ^ |
| 99 |
/XD %cd%\\binaries\\system ^ |
| 100 |
/XD %cd%\\build\\workspaces\\vs2022 ^ |
| 101 |
/XD %cd%\\libraries\\source\\.svn ^ |
| 102 |
/XD %cd%\\libraries\\win32\\.svn ^ |
| 103 |
/XD %cd%\\libraries\\win32\\wxwidgets\\include ^ |
| 104 |
/XD %cd%\\libraries\\win32\\wxwidgets\\lib ^ |
| 105 |
/XD .svn ^ |
| 106 |
/XD %NIGHTLY_PATH%\\binaries\\data\\mods\\mod\\shaders\\spirv ^ |
| 107 |
/XD %NIGHTLY_PATH%\\binaries\\data\\mods\\public\\shaders\\spirv ^ |
| 108 |
/XF %NIGHTLY_PATH%\\source\\tools\\spirv\\rules.json ^ |
| 109 |
/XF %NIGHTLY_PATH%\\binaries\\data\\mods\\public\\gui\\credits\\texts\\translators.json ^ |
| 110 |
/MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0 |
| 111 |
''' |
| 112 |
bat ''' |
| 113 |
(robocopy binaries\\system ..\\nightly-svn\\binaries\\system ^ |
| 114 |
/XF *.exp ^ |
| 115 |
/XF *.lib ^ |
| 116 |
/MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0 |
| 117 |
''' |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
stage('Check-in SPIR-V rules') { |
| 122 |
when { |
| 123 |
expression { env.spirv_rules_FILENAME } |
| 124 |
} |
| 125 |
steps { |
| 126 |
ws('workspace/nightly-svn') { |
| 127 |
unstash 'spirv_rules' |
| 128 |
bat 'move spirv_rules source\\tools\\spirv\\rules.json' |
| 129 |
} |
| 130 |
script { buildSPIRV = true } |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
stage('Recompile SPIR-V shaders') { |
| 135 |
when { |
| 136 |
expression { buildSPIRV } |
| 137 |
} |
| 138 |
steps { |
| 139 |
ws('workspace/nightly-svn') { |
| 140 |
bat 'del /s /q binaries\\data\\mods\\mod\\shaders\\spirv' |
| 141 |
bat 'del /s /q binaries\\data\\mods\\public\\shaders\\spirv' |
| 142 |
bat 'python source/tools/spirv/compile.py -d binaries/data/mods/mod binaries/data/mods/mod source/tools/spirv/rules.json binaries/data/mods/mod' |
| 143 |
bat 'python source/tools/spirv/compile.py -d binaries/data/mods/mod binaries/data/mods/public source/tools/spirv/rules.json binaries/data/mods/public' |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
stage('Update translations') { |
| 149 |
steps { |
| 150 |
ws('workspace/nightly-svn') { |
| 151 |
bat 'cd source\\tools\\i18n && python update_templates.py' |
| 152 |
withCredentials([string(credentialsId: 'TX_TOKEN', variable: 'TX_TOKEN')]) { |
| 153 |
bat 'cd source\\tools\\i18n && python pull_translations.py' |
| 154 |
} |
| 155 |
bat 'cd source\\tools\\i18n && python generate_debug_translation.py --long' |
| 156 |
bat 'cd source\\tools\\i18n && python clean_translation_files.py' |
| 157 |
script { |
| 158 |
if (!params.NEW_REPO) { |
| 159 |
bat 'python source\\tools\\i18n\\check_diff.py --verbose' |
| 160 |
} |
| 161 |
} |
| 162 |
bat 'cd source\\tools\\i18n && python credit_translators.py' |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
stage('Commit') { |
| 168 |
steps { |
| 169 |
ws('workspace/nightly-svn') { |
| 170 |
bat "(for /F \"tokens=* delims=? \" %%A in ('svn status ^| findstr /R \"^?\"') do (svn add \"%%A\")) || (echo No new files found) ^& exit 0" |
| 171 |
bat "(for /F \"tokens=* delims=! \" %%A in ('svn status ^| findstr /R \"^!\"') do (svn delete \"%%A\")) || (echo No deleted files found) ^& exit 0" |
| 172 |
bat 'for /R %%F in (*.sh) do (svn propset svn:executable ON %%F)' |
| 173 |
withCredentials([usernamePassword(credentialsId: 'nightly-autobuild', passwordVariable: 'SVNPASS', usernameVariable: 'SVNUSER')]) { |
| 174 |
script { |
| 175 |
env.GITHASH = gitHash |
| 176 |
bat 'svn commit --username %SVNUSER% --password %SVNPASS% --no-auth-cache --non-interactive -m "Nightly build for %GITHASH% (%DATE%)"' |
| 177 |
} |
| 178 |
} |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
post { |
| 185 |
always { |
| 186 |
ws('workspace/nightly-svn') { |
| 187 |
bat 'svn cleanup' |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
} |