From 506d03e3c895c595adae15e2a17614ab5f6952b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Jaro=C5=A1?= Date: Sat, 8 Mar 2025 15:58:27 +0100 Subject: [PATCH] Fix release both game version --- Jenkinsfile | 58 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 98cfa9e..b0f72f2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,22 +36,19 @@ def writeToCVersion = { String tocFile, String current, String next -> writeFile(file: tocFile, text: content) } -def generateOutput = { String game -> +def createZipFile = { String game -> + def tocFile = tocFiles[game] + // prepare output folder sh "mkdir -p $outputFolder" // copy toc file - def tocFile = tocFiles[game] sh "cp $tocFile $outputFolder" // copy files sh "find . -name '*.lua' -exec rsync -av {} $outputFolder \\;" sh "find . -name '*.tga' -exec rsync -av {} $outputFolder \\;" sh "find . -name '*.ttf' -exec rsync -av {} $outputFolder \\;" -} - -def createReleaseFile = { String game -> - def tocFile = tocFiles[game] // get version def currentVersion = readToCVersion(tocFile) @@ -66,15 +63,24 @@ def createReleaseFile = { String game -> // save version writeToCVersion(tocFile, currentVersion, newVersion) +} - // commit new version - def tag = "v$newVersion" +def pushToGit = { String game -> + def tocFile = tocFiles[game] + def version = readToCVersion(tocFile) + def tag = "v$version" sh "git checkout ${BRANCH_NAME}" - sh "git add $tocFile" - sh "git commit -m 'Release ${tag}'" + sh "git add *.toc" + sh "git commit -m 'Release $tag'" sh "git push" - sh "git tag ${tag}" - sh "git push origin ${tag}" + sh "git tag $tag" + sh "git push origin $tag" +} + +def uploadToForgejo = { String game -> + def tocFile = tocFiles[game] + def version = readToCVersion(tocFile) + ForgejoRelease('czech-quests', 'addon', version) } MasterJob [:], { -> @@ -88,28 +94,22 @@ MasterJob [:], { -> stageWhen('build') { def game = params.GAME if (game == "all") { - generateOutput("classic_era") - generateOutput("retail") + createZipFile("classic_era") + createZipFile("retail") } else { - generateOutput(game) + createZipFile(game) } - } - - stageWhen('make release') { - def game = params.GAME forgejoGit() - if (game == "all") { - createReleaseFile("classic_era") - createReleaseFile("retail") - } else { - createReleaseFile(game) - } + pushToGit(game) } - stageWhen('upload release') { + stageWhen('release') { def game = params.GAME - def tocFile = tocFiles[game] - def version = readToCVersion(tocFile) - ForgejoRelease('czech-quests', 'addon', version) + if (game == "all") { + uploadToForgejo("classic_era") + uploadToForgejo("retail") + } else { + uploadToForgejo(game) + } } } \ No newline at end of file