Fix release both game version
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good

This commit is contained in:
Roman Jaroš 2025-03-08 15:58:27 +01:00
parent 84ee045c98
commit 506d03e3c8

58
Jenkinsfile vendored
View file

@ -36,22 +36,19 @@ def writeToCVersion = { String tocFile, String current, String next ->
writeFile(file: tocFile, text: content) writeFile(file: tocFile, text: content)
} }
def generateOutput = { String game -> def createZipFile = { String game ->
def tocFile = tocFiles[game]
// prepare output folder // prepare output folder
sh "mkdir -p $outputFolder" sh "mkdir -p $outputFolder"
// copy toc file // copy toc file
def tocFile = tocFiles[game]
sh "cp $tocFile $outputFolder" sh "cp $tocFile $outputFolder"
// copy files // copy files
sh "find . -name '*.lua' -exec rsync -av {} $outputFolder \\;" sh "find . -name '*.lua' -exec rsync -av {} $outputFolder \\;"
sh "find . -name '*.tga' -exec rsync -av {} $outputFolder \\;" sh "find . -name '*.tga' -exec rsync -av {} $outputFolder \\;"
sh "find . -name '*.ttf' -exec rsync -av {} $outputFolder \\;" sh "find . -name '*.ttf' -exec rsync -av {} $outputFolder \\;"
}
def createReleaseFile = { String game ->
def tocFile = tocFiles[game]
// get version // get version
def currentVersion = readToCVersion(tocFile) def currentVersion = readToCVersion(tocFile)
@ -66,15 +63,24 @@ def createReleaseFile = { String game ->
// save version // save version
writeToCVersion(tocFile, currentVersion, newVersion) writeToCVersion(tocFile, currentVersion, newVersion)
}
// commit new version def pushToGit = { String game ->
def tag = "v$newVersion" def tocFile = tocFiles[game]
def version = readToCVersion(tocFile)
def tag = "v$version"
sh "git checkout ${BRANCH_NAME}" sh "git checkout ${BRANCH_NAME}"
sh "git add $tocFile" sh "git add *.toc"
sh "git commit -m 'Release ${tag}'" sh "git commit -m 'Release $tag'"
sh "git push" sh "git push"
sh "git tag ${tag}" sh "git tag $tag"
sh "git push origin ${tag}" sh "git push origin $tag"
}
def uploadToForgejo = { String game ->
def tocFile = tocFiles[game]
def version = readToCVersion(tocFile)
ForgejoRelease('czech-quests', 'addon', version)
} }
MasterJob [:], { -> MasterJob [:], { ->
@ -88,28 +94,22 @@ MasterJob [:], { ->
stageWhen('build') { stageWhen('build') {
def game = params.GAME def game = params.GAME
if (game == "all") { if (game == "all") {
generateOutput("classic_era") createZipFile("classic_era")
generateOutput("retail") createZipFile("retail")
} else { } else {
generateOutput(game) createZipFile(game)
} }
}
stageWhen('make release') {
def game = params.GAME
forgejoGit() forgejoGit()
if (game == "all") { pushToGit(game)
createReleaseFile("classic_era")
createReleaseFile("retail")
} else {
createReleaseFile(game)
}
} }
stageWhen('upload release') { stageWhen('release') {
def game = params.GAME def game = params.GAME
def tocFile = tocFiles[game] if (game == "all") {
def version = readToCVersion(tocFile) uploadToForgejo("classic_era")
ForgejoRelease('czech-quests', 'addon', version) uploadToForgejo("retail")
} else {
uploadToForgejo(game)
}
} }
} }