Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .teamcity/builds/Release.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package builds

import jetbrains.buildServer.configs.kotlin.BuildType
import jetbrains.buildServer.configs.kotlin.ParameterDisplay
import jetbrains.buildServer.configs.kotlin.buildFeatures.dockerSupport
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
import jetbrains.buildServer.configs.kotlin.buildSteps.script
import jetbrains.buildServer.configs.kotlin.toId

Expand All @@ -11,25 +13,41 @@ class Release(id: String, name: String) :
this.name = name

params {
text("version", "", allowEmpty = false)
text("version", "", allowEmpty = false, display = ParameterDisplay.PROMPT, label = "Version to release")

text("env.PACKAGES_USERNAME", "%github-packages-user%")
password("env.PACKAGES_PASSWORD", "%github-packages-token%")
password("env.JRELEASER_GITHUB_TOKEN", "%github-pull-request-token%")
}

steps {
script {
this.name = "Validate version"
scriptContent =
"""
#!/bin/bash -eu

if [ -z "%version%" ]; then
echo "Version is not set. Please run as a custom build and specify 'version' parameter."
exit 1
fi
""".trimIndent()
}

commonMaven {
this.name = "Set version"
goals = "versions:set"
runnerArgs = "$MAVEN_DEFAULT_ARGS -DnewVersion=%version% -DgenerateBackupPoms=false"
}

commonMaven {
this.name = "Build versionalised package"
goals = "package"
runnerArgs = "$MAVEN_DEFAULT_ARGS -DskipTests"
}

script {
this.name = "Push version"
scriptContent =
"""
#!/bin/bash -eu
Expand All @@ -43,13 +61,20 @@ class Release(id: String, name: String) :
git config --global user.name "${'$'}USER_NAME"
git config --global --add safe.directory %teamcity.build.checkoutDir%

git add .
git add **/pom.xml
git commit -m "build: release version %version%"
git push
""".trimIndent()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just thought if we should be specific on what we include in git add such as git add **/pom.xml not to accidentally commit other changes?

formatStderrAsError = true

dockerImagePlatform = ScriptBuildStep.ImagePlatform.Linux
dockerImage = "eclipse-temurin:11-jdk"
dockerRunParameters = "--volume /var/run/docker.sock:/var/run/docker.sock"
}

commonMaven {
this.name = "Release to Github"
goals = "jreleaser:full-release"
runnerArgs = "$MAVEN_DEFAULT_ARGS -Prelease -pl :packaging"
}
Expand Down