diff --git a/.gitignore b/.gitignore index cf17b31..04726da 100755 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ .DS_Store downloader/.env -downloader/node_modules \ No newline at end of file +downloader/node_modules + +lib \ No newline at end of file diff --git a/Assets/Icons/Logo.webp b/Assets/Icons/Logo.webp new file mode 100644 index 0000000..6805028 Binary files /dev/null and b/Assets/Icons/Logo.webp differ diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..98cfa9e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,115 @@ +@Library('jenkins-lib') + +import dev.romanjaros.jenkins.utils.ReleaseUtils + +def SKIP = "skip" + +properties([parameters([ + choice( + name: 'RELEASE', + choices: ['patch', 'minor', 'major'], + description: 'Release new version' + ), + choice( + name: 'GAME', + choices: [SKIP, 'classic_era', 'retail', 'all'], + description: 'Create build with manual tag', + ) +])]) + +def outputFolder = "CzechQuests" +def tocFiles = [ + "classic_era": "CzechQuests_Vanilla.toc", + "retail" : "CzechQuests_Mainline.toc" +] + +def readToCVersion = { String tocFile -> + return sh( + script: "grep '## Version:' $tocFile | cut -d ' ' -f 3", + returnStdout: true + ).trim() +} + +def writeToCVersion = { String tocFile, String current, String next -> + def content = readFile(file: tocFile) + content = content.replace("## Version: $current", "## Version: $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 createReleaseFile = { String game -> + def tocFile = tocFiles[game] + + // get version + def currentVersion = readToCVersion(tocFile) + def newVersion = ReleaseUtils.increaseVersion(currentVersion, params.RELEASE) + + // create zip + def zipFileName = "czech-quests-$game-v${newVersion}.zip" + zip zipFile: zipFileName, archive: false, dir: outputFolder + + // remove build folder + sh "rm -r $outputFolder" + + // save version + writeToCVersion(tocFile, currentVersion, newVersion) + + // commit new version + def tag = "v$newVersion" + sh "git checkout ${BRANCH_NAME}" + sh "git add $tocFile" + sh "git commit -m 'Release ${tag}'" + sh "git push" + sh "git tag ${tag}" + sh "git push origin ${tag}" +} + +MasterJob [:], { -> + if (game == SKIP) { + currentBuild.result = 'SUCCESS' + return + } + + checkout scm + + stageWhen('build') { + def game = params.GAME + if (game == "all") { + generateOutput("classic_era") + generateOutput("retail") + } else { + generateOutput(game) + } + } + + stageWhen('make release') { + def game = params.GAME + forgejoGit() + if (game == "all") { + createReleaseFile("classic_era") + createReleaseFile("retail") + } else { + createReleaseFile(game) + } + } + + stageWhen('upload release') { + def game = params.GAME + def tocFile = tocFiles[game] + def version = readToCVersion(tocFile) + ForgejoRelease('czech-quests', 'addon', version) + } +} \ No newline at end of file