From d90715c2ccc23d94eefbf93bcdb5239de84716aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Jaro=C5=A1?= Date: Sat, 8 Mar 2025 16:16:16 +0100 Subject: [PATCH] Fix release zip folder structure --- CzechQuests_Mainline.toc | 2 +- CzechQuests_Vanilla.toc | 2 +- Jenkinsfile | 116 +++++++++++++++++++-------------------- 3 files changed, 57 insertions(+), 63 deletions(-) diff --git a/CzechQuests_Mainline.toc b/CzechQuests_Mainline.toc index 006027b..e4b4ca4 100755 --- a/CzechQuests_Mainline.toc +++ b/CzechQuests_Mainline.toc @@ -2,7 +2,7 @@ ## Title: CzechQuests ## Notes: Addon displays texts of quests in Czech language ## Author: Roman Jaroš -## Version: 0.2.14 +## Version: 1.0.0 ## SavedVariables: CzechQuestsAddon_Store ## Category: Translations ## IconTexture: Interface\AddOns\CzechQuests\Assets\Icons\Logo diff --git a/CzechQuests_Vanilla.toc b/CzechQuests_Vanilla.toc index 8c53300..1448fdb 100755 --- a/CzechQuests_Vanilla.toc +++ b/CzechQuests_Vanilla.toc @@ -2,7 +2,7 @@ ## Title: CzechQuests ## Notes: Addon displays texts of quests in Czech language as tooltip ## Author: Roman Jaroš -## Version: 0.1.13 +## Version: 1.0.0 ## SavedVariables: CzechQuestsAddon_Store CzechQuests.lua diff --git a/Jenkinsfile b/Jenkinsfile index 98cfa9e..dc9d0c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,25 +7,22 @@ def SKIP = "skip" properties([parameters([ choice( name: 'RELEASE', - choices: ['patch', 'minor', 'major'], - description: 'Release new version' + choices: [SKIP, 'patch', 'minor', 'major'], + description: 'Next new version' ), - choice( - name: 'GAME', - choices: [SKIP, 'classic_era', 'retail', 'all'], - description: 'Create build with manual tag', - ) ])]) -def outputFolder = "CzechQuests" +def output = "Output" +def addon = "CzechQuests" + def tocFiles = [ "classic_era": "CzechQuests_Vanilla.toc", "retail" : "CzechQuests_Mainline.toc" ] -def readToCVersion = { String tocFile -> +def readToCVersion = { -> return sh( - script: "grep '## Version:' $tocFile | cut -d ' ' -f 3", + script: "grep '## Version:' ${tocFiles['classic_era']} | cut -d ' ' -f 3", returnStdout: true ).trim() } @@ -36,80 +33,77 @@ def writeToCVersion = { String tocFile, String current, String next -> writeFile(file: tocFile, text: content) } -def generateOutput = { String 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 increaseVersion = { -> + def currentVersion = readToCVersion() + def newVersion = ReleaseUtils.increaseVersion(currentVersion, params.RELEASE) + writeToCVersion(tocFiles['classic_era'], currentVersion, newVersion) + writeToCVersion(tocFiles['retail'], currentVersion, newVersion) } -def createReleaseFile = { String game -> +def createZipFile = { String game -> def tocFile = tocFiles[game] + def version = readToCVersion() - // get version - def currentVersion = readToCVersion(tocFile) - def newVersion = ReleaseUtils.increaseVersion(currentVersion, params.RELEASE) + // prepare output folder + sh "mkdir -p $output/$addon/Addon/Data" + + // copy toc file + sh "cp $tocFile $output/$addon" + + // copy lue files + sh "rsync -av './CzechQuests.lua' ./$output/$addon" + sh "rsync -av './Addon/Data/other.lua' ./$output/$addon/Addon/Data" + sh "find ./Addon/Data/$game/ -name '*.lua' -exec rsync -av {} ./$output/$addon/Addon/Data/ \\;" + sh "find ./Addon/Code/ -name '*.lua' -exec rsync -av {} ./$output/$addon/Addon/Code/ \\;" + + // copy assets + sh "find . -name '*.tga' -exec rsync -avR {} $output/$addon \\;" + sh "find . -name '*.ttf' -exec rsync -avR {} $output/$addon \\;" // create zip - def zipFileName = "czech-quests-$game-v${newVersion}.zip" - zip zipFile: zipFileName, archive: false, dir: outputFolder + def zipFileName = "czech-quests-$game-v${version}.zip" + zip zipFile: zipFileName, archive: false, dir: output // remove build folder - sh "rm -r $outputFolder" + sh "rm -r $output" +} - // save version - writeToCVersion(tocFile, currentVersion, newVersion) - - // commit new version - def tag = "v$newVersion" +def pushToGit = { -> + def version = readToCVersion() sh "git checkout ${BRANCH_NAME}" - sh "git add $tocFile" - sh "git commit -m 'Release ${tag}'" + sh "git add *.toc" + sh "git commit -m 'Release $version'" sh "git push" - sh "git tag ${tag}" - sh "git push origin ${tag}" + sh "git tag $version" + sh "git push origin $version" +} + +def uploadToForgejo = { -> + def version = readToCVersion() + ForgejoRelease('czech-quests', 'addon', version) } MasterJob [:], { -> - if (game == SKIP) { + def version = params.RELEASE + if (version == SKIP) { currentBuild.result = 'SUCCESS' return } checkout scm + stageWhen("version") { + increaseVersion() + } + stageWhen('build') { - def game = params.GAME - if (game == "all") { - generateOutput("classic_era") - generateOutput("retail") - } else { - generateOutput(game) - } - } - - stageWhen('make release') { - def game = params.GAME + createZipFile("classic_era") + createZipFile("retail") forgejoGit() - if (game == "all") { - createReleaseFile("classic_era") - createReleaseFile("retail") - } else { - createReleaseFile(game) - } + pushToGit() } - stageWhen('upload release') { - def game = params.GAME - def tocFile = tocFiles[game] - def version = readToCVersion(tocFile) - ForgejoRelease('czech-quests', 'addon', version) + stageWhen('release') { + uploadToForgejo() } } \ No newline at end of file