From 5ffddd0cc47b83cf615a3174dc3320996b5a710d Mon Sep 17 00:00:00 2001 From: Itms Date: Sun, 27 Apr 2025 11:32:59 +0200 Subject: [PATCH] Implement pipeline for generating patch releases The new patch-release pipeline takes a git branch originating from a release tag, applies the changes since the tag onto the nightly build of the release, and rebuilds the Windows binary. All resulting changes are sent to the bundling pipeline which builds for macOS and creates the tarballs and installers. There will be two instances of the bundles pipeline: the main one will keep tracking the main branch and providing biweekly bundles of the next release, while a new patched-bundles pipeline will be manually used to generate patch releases. (cherry picked from commit 51ab9299264cefd88e46498d1ccd04aaa04a1d69) Signed-off-by: Itms --- build/jenkins/pipelines/bundles.Jenkinsfile | 22 ++++- .../pipelines/patch-release.Jenkinsfile | 94 +++++++++++++++++++ 2 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 build/jenkins/pipelines/patch-release.Jenkinsfile diff --git a/build/jenkins/pipelines/bundles.Jenkinsfile b/build/jenkins/pipelines/bundles.Jenkinsfile index a55a4122f4..f58925c82a 100644 --- a/build/jenkins/pipelines/bundles.Jenkinsfile +++ b/build/jenkins/pipelines/bundles.Jenkinsfile @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -32,6 +32,8 @@ pipeline { parameters { string(name: 'BUNDLE_VERSION', defaultValue: '0.27.0dev', description: 'Bundle Version') + string(name: 'NIGHTLY_REVISION', defaultValue: 'HEAD', description: 'Nightly SVN revision from which to build the bundles') + booleanParam(name: 'PATCH_BUILD', defaultValue: false, description: 'Apply patch generated from upstream job patch-release onto the nightly build') booleanParam(name: 'DO_GZIP', defaultValue: true, description: 'Create .gz unix tarballs as well as .xz') } @@ -44,10 +46,20 @@ pipeline { steps { checkout changelog: false, poll: false, scm: [ $class: 'SubversionSCM', - locations: [[local: '.', remote: 'https://svn.wildfiregames.com/nightly-build/trunk']], + locations: [[local: '.', remote: "https://svn.wildfiregames.com/nightly-build/trunk@${NIGHTLY_REVISION}"]], quietOperation: false, workspaceUpdater: [$class: 'UpdateWithCleanUpdater']] - sh "svn cleanup" + } + } + + stage("Patch Nightly Build") { + when { + expression { return params.PATCH_BUILD } + } + steps { + copyArtifacts projectName: '0ad-patch-release', selector: upstream() + sh "svn patch ${BUNDLE_VERSION}.patch" + untar file: "${params.BUNDLE_VERSION}-nightly-patch.tar.gz", keepPermissions: false } } @@ -146,5 +158,9 @@ pipeline { success { archiveArtifacts '*.dmg,*.exe,*.tar.gz,*.tar.xz,*.minisig,*.md5sum,*.sha1sum' } + cleanup { + sh 'svn revert -R .' + sh 'svn cleanup --remove-unversioned' + } } } diff --git a/build/jenkins/pipelines/patch-release.Jenkinsfile b/build/jenkins/pipelines/patch-release.Jenkinsfile new file mode 100644 index 0000000000..337c148548 --- /dev/null +++ b/build/jenkins/pipelines/patch-release.Jenkinsfile @@ -0,0 +1,94 @@ +/* Copyright (C) 2025 Wildfire Games. + * This file is part of 0 A.D. + * + * 0 A.D. is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 0 A.D. is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with 0 A.D. If not, see . + */ + +// This pipeline is used to generate patched releases, suitable to be bundled and distributed. + +def visualStudioPath = '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"' +def buildOptions = '/p:PlatformToolset=v141_xp /p:XPDeprecationWarning=false /t:pyrogenesis /t:AtlasUI %JOBS% /nologo -clp:Warningsonly -clp:ErrorsOnly' + +pipeline { + agent { + node { + label 'WindowsAgent' + } + } + + parameters { + string(name: 'BUNDLE_VERSION', description: 'Bundle Version') + string(name: 'NIGHTLY_REVISION', description: 'Revision of the nightly build corresponding to the release') + string(name: 'RELEASE_TAG', description: 'Git tag from which the point release originates') + } + + stages { + stage('Generate Patch') { + steps { + checkout scmGit(branches: [[name: "${GIT_BRANCH}"]], extensions: [cleanAfterCheckout(), localBranch()]) + bat 'cd build\\build_version && build_version.bat' + stash includes: 'build/build_version/build_version.txt', name: 'build_version' + bat "git diff ${RELEASE_TAG}..HEAD > ${BUNDLE_VERSION}.patch" + stash includes: "${params.BUNDLE_VERSION}.patch", name: 'patch' + archiveArtifacts artifacts: "${params.BUNDLE_VERSION}.patch" + } + } + + stage('Patch Windows Build') { + steps { + ws('workspace/patch-release-svn') { + checkout changelog: false, poll: false, scm: [ + $class: 'SubversionSCM', + locations: [[local: '.', remote: "https://svn.wildfiregames.com/nightly-build/trunk@${NIGHTLY_REVISION}"]], + quietOperation: false, + workspaceUpdater: [$class: 'UpdateWithCleanUpdater']] + unstash 'patch' + bat "svn patch ${params.BUNDLE_VERSION}.patch" + + unstash 'build_version' + bat 'cd libraries && get-windows-libs.bat' + + bat '(robocopy E:\\wxWidgets-3.2.6\\lib libraries\\win32\\wxwidgets\\lib /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' + bat '(robocopy E:\\wxWidgets-3.2.6\\include libraries\\win32\\wxwidgets\\include /MIR /NDL /NJH /NJS /NP /NS /NC) ^& IF %ERRORLEVEL% LEQ 1 exit 0' + bat 'cd build\\workspaces && update-workspaces.bat --without-pch --without-tests' + bat "cd build\\workspaces\\vs2017 && ${visualStudioPath} pyrogenesis.sln /p:Configuration=Release ${buildOptions}" + + script { + def modifiedFiles = bat(script:'@svn status', returnStdout: true).split('\n').collect { l -> l.drop(8).trim() }.join(', ') + tar archive: true, compress: true, exclude: '*.orig, binaries/system/*.exp, binaries/system/*.lib, build/workspaces/vs2017, libraries/win32/wxwidgets/**', file: "${params.BUNDLE_VERSION}-nightly-patch.tar.gz", glob: modifiedFiles + } + } + } + + post { + cleanup { + ws('workspace/patch-release-svn') { + bat 'svn revert -R .' + bat 'svn cleanup --remove-unversioned' + } + } + } + } + + stage('Bundle Patched Release') { + steps { + build job: '0ad-patch-bundles', wait: false, waitForStart: true, parameters: [ + string(name: 'BUNDLE_VERSION', value: "${params.BUNDLE_VERSION}"), + string(name: 'NIGHTLY_REVISION', value: "${params.NIGHTLY_REVISION}"), + booleanParam(name: 'PATCH_BUILD', value: true) + ] + } + } + } +}