-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathRelease.kt
More file actions
91 lines (71 loc) · 2.79 KB
/
Release.kt
File metadata and controls
91 lines (71 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
class Release(id: String, name: String) :
BuildType({
this.id(id.toId())
this.name = name
params {
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
apt-get update
apt-get install --yes git
USER_NAME=`echo %teamcity.build.triggeredBy.username% | sed 's/@.*//g' | sed 's/\./ /g' | sed 's/\w\+/\L\u&/g'`
git config --global user.email %teamcity.build.triggeredBy.username%
git config --global user.name "${'$'}USER_NAME"
git config --global --add safe.directory %teamcity.build.checkoutDir%
git add **/pom.xml
git commit -m "build: release version %version%"
git push
""".trimIndent()
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"
}
}
features {
dockerSupport {}
requireDiskSpace("5gb")
}
requirements { runOnLinux(LinuxSize.SMALL) }
})