Skip to content

Commit 6a20b01

Browse files
ali-incevenikkin
andauthored
ci: release pipeline (#30)
* build: add jreleaser to packaging module Signed-off-by: Ali Ince <ali.ince@neo4j.com> * build: add tag and release names to release configuration * build: add initial version of release build * build: execute release on packaging submodule * build: replace packages token with pull requests token, add disk space feature * ci: re-package artifacts before full release * ci: add git push step before making full release * ci: change release commit message --------- Signed-off-by: Ali Ince <ali.ince@neo4j.com> Co-authored-by: Eugene Rubanov <eugene.rubanov@neo4j.com>
1 parent 1d97ad6 commit 6a20b01

File tree

6 files changed

+179
-13
lines changed

6 files changed

+179
-13
lines changed

.teamcity/builds/Build.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class Build(name: String, branchFilter: String, forPullRequests: Boolean) :
1313
val packaging =
1414
Maven("${name}-package", "package", "package", "-pl :packaging -am -DskipTests")
1515

16+
val complete = Empty("${name}-complete", "complete")
17+
1618
val bts = sequential {
1719
if (forPullRequests)
1820
buildType(WhiteListCheck("${name}-whitelist-check", "white-list check"))
@@ -33,7 +35,8 @@ class Build(name: String, branchFilter: String, forPullRequests: Boolean) :
3335
}
3436
}
3537
})
36-
dependentBuildType(Empty("${name}-complete", "complete"))
38+
dependentBuildType(complete)
39+
dependentBuildType(Release("${name}-release", "release"))
3740
}
3841

3942
bts.buildTypes().forEach {
@@ -48,5 +51,7 @@ class Build(name: String, branchFilter: String, forPullRequests: Boolean) :
4851
buildType(it)
4952
}
5053

51-
bts.buildTypes().last().triggers { vcs { this.branchFilter = branchFilter } }
54+
complete.triggers { vcs { this.branchFilter = branchFilter } }
5255
})
56+
57+

.teamcity/builds/Common.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package builds
22

33
import jetbrains.buildServer.configs.kotlin.BuildFeatures
4+
import jetbrains.buildServer.configs.kotlin.BuildSteps
45
import jetbrains.buildServer.configs.kotlin.BuildType
56
import jetbrains.buildServer.configs.kotlin.CompoundStage
67
import jetbrains.buildServer.configs.kotlin.FailureAction
@@ -9,6 +10,8 @@ import jetbrains.buildServer.configs.kotlin.buildFeatures.PullRequests
910
import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher
1011
import jetbrains.buildServer.configs.kotlin.buildFeatures.freeDiskSpace
1112
import jetbrains.buildServer.configs.kotlin.buildFeatures.pullRequests
13+
import jetbrains.buildServer.configs.kotlin.buildSteps.MavenBuildStep
14+
import jetbrains.buildServer.configs.kotlin.buildSteps.maven
1215
import jetbrains.buildServer.configs.kotlin.vcs.GitVcsRoot
1316

1417
const val GITHUB_OWNER = "neo4j"
@@ -79,3 +82,18 @@ fun collectArtifacts(buildType: BuildType): BuildType {
7982

8083
return buildType
8184
}
85+
86+
fun BuildSteps.commonMaven(init: MavenBuildStep.() -> Unit): MavenBuildStep {
87+
val maven = this.maven {
88+
// this is the settings name we uploaded to Connectors project
89+
userSettingsSelection = "github"
90+
localRepoScope = MavenBuildStep.RepositoryScope.MAVEN_DEFAULT
91+
92+
dockerImagePlatform = MavenBuildStep.ImagePlatform.Linux
93+
dockerImage = "eclipse-temurin:11-jdk"
94+
dockerRunParameters = "--volume /var/run/docker.sock:/var/run/docker.sock"
95+
}
96+
97+
init(maven)
98+
return maven
99+
}

.teamcity/builds/Maven.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package builds
22

33
import jetbrains.buildServer.configs.kotlin.BuildType
44
import jetbrains.buildServer.configs.kotlin.buildFeatures.dockerSupport
5-
import jetbrains.buildServer.configs.kotlin.buildSteps.MavenBuildStep
6-
import jetbrains.buildServer.configs.kotlin.buildSteps.maven
75
import jetbrains.buildServer.configs.kotlin.toId
86

97
class Maven(id: String, name: String, goals: String, args: String? = null) :
@@ -35,17 +33,9 @@ class Maven(id: String, name: String, goals: String, args: String? = null) :
3533
}
3634

3735
steps {
38-
maven {
36+
commonMaven {
3937
this.goals = goals
4038
this.runnerArgs = "$MAVEN_DEFAULT_ARGS ${args ?: ""}"
41-
42-
// this is the settings name we uploaded to Connectors project
43-
userSettingsSelection = "github"
44-
localRepoScope = MavenBuildStep.RepositoryScope.MAVEN_DEFAULT
45-
46-
dockerImagePlatform = MavenBuildStep.ImagePlatform.Linux
47-
dockerImage = "eclipse-temurin:11-jdk"
48-
dockerRunParameters = "--volume /var/run/docker.sock:/var/run/docker.sock"
4939
}
5040
}
5141

.teamcity/builds/Release.kt

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package builds
2+
3+
import jetbrains.buildServer.configs.kotlin.BuildType
4+
import jetbrains.buildServer.configs.kotlin.buildFeatures.dockerSupport
5+
import jetbrains.buildServer.configs.kotlin.buildSteps.script
6+
import jetbrains.buildServer.configs.kotlin.toId
7+
8+
class Release(id: String, name: String) :
9+
BuildType({
10+
this.id(id.toId())
11+
this.name = name
12+
13+
params {
14+
text("version", "", allowEmpty = false)
15+
16+
text("env.PACKAGES_USERNAME", "%github-packages-user%")
17+
password("env.PACKAGES_PASSWORD", "%github-packages-token%")
18+
password("env.JRELEASER_GITHUB_TOKEN", "%github-pull-request-token%")
19+
}
20+
21+
steps {
22+
commonMaven {
23+
goals = "versions:set"
24+
runnerArgs = "$MAVEN_DEFAULT_ARGS -DnewVersion=%version% -DgenerateBackupPoms=false"
25+
}
26+
27+
commonMaven {
28+
goals = "package"
29+
runnerArgs = "$MAVEN_DEFAULT_ARGS -DskipTests"
30+
}
31+
32+
script {
33+
scriptContent =
34+
"""
35+
#!/bin/bash -eu
36+
37+
apt-get update
38+
apt-get install --yes git
39+
40+
USER_NAME=`echo %teamcity.build.triggeredBy.username% | sed 's/@.*//g' | sed 's/\./ /g' | sed 's/\w\+/\L\u&/g'`
41+
42+
git config --global user.email %teamcity.build.triggeredBy.username%
43+
git config --global user.name "${'$'}USER_NAME"
44+
git config --global --add safe.directory %teamcity.build.checkoutDir%
45+
46+
git add .
47+
git commit -m "build: release version %version%"
48+
git push
49+
""".trimIndent()
50+
}
51+
52+
commonMaven {
53+
goals = "jreleaser:full-release"
54+
runnerArgs = "$MAVEN_DEFAULT_ARGS -Prelease -pl :packaging"
55+
}
56+
}
57+
58+
features {
59+
dockerSupport {}
60+
requireDiskSpace("5gb")
61+
}
62+
63+
requirements { runOnLinux(LinuxSize.SMALL) }
64+
65+
})
66+

packaging/pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,84 @@
195195
</plugin>
196196
</plugins>
197197
</build>
198+
<profiles>
199+
<profile>
200+
<id>release</id>
201+
<properties>
202+
<packaging.directory>packaging/target</packaging.directory>
203+
</properties>
204+
<build>
205+
<plugins>
206+
<plugin>
207+
<groupId>org.jreleaser</groupId>
208+
<artifactId>jreleaser-maven-plugin</artifactId>
209+
<inherited>false</inherited>
210+
<configuration>
211+
<jreleaser>
212+
<checksum>
213+
<individual>true</individual>
214+
<files>true</files>
215+
</checksum>
216+
<project/>
217+
<release>
218+
<github>
219+
<owner>neo4j</owner>
220+
<name>neo4j-kafka-connector</name>
221+
<overwrite>true</overwrite>
222+
<branch>main</branch>
223+
<changelog>
224+
<enabled>true</enabled>
225+
</changelog>
226+
<files>true</files>
227+
<tagName>{{projectVersion}}</tagName>
228+
<releaseName>{{projectVersion}}</releaseName>
229+
</github>
230+
</release>
231+
<files>
232+
<artifacts>
233+
<artifact>
234+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-legacy-${project.version}.zip</path>
235+
</artifact>
236+
<artifact>
237+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-legacy-${project.version}.jar</path>
238+
</artifact>
239+
<artifact>
240+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-source-${project.version}.zip</path>
241+
</artifact>
242+
<artifact>
243+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-source-${project.version}.jar</path>
244+
</artifact>
245+
<artifact>
246+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-sink-${project.version}.zip</path>
247+
</artifact>
248+
<artifact>
249+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-sink-${project.version}.jar</path>
250+
</artifact>
251+
<artifact>
252+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-legacy-${project.version}-kc-oss.zip</path>
253+
</artifact>
254+
<artifact>
255+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-legacy-${project.version}-kc-oss.jar</path>
256+
</artifact>
257+
<artifact>
258+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-source-${project.version}-kc-oss.zip</path>
259+
</artifact>
260+
<artifact>
261+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-source-${project.version}-kc-oss.jar</path>
262+
</artifact>
263+
<artifact>
264+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-sink-${project.version}-kc-oss.zip</path>
265+
</artifact>
266+
<artifact>
267+
<path>${packaging.directory}/neo4j-kafka-connect-neo4j-sink-${project.version}-kc-oss.jar</path>
268+
</artifact>
269+
</artifacts>
270+
</files>
271+
</jreleaser>
272+
</configuration>
273+
</plugin>
274+
</plugins>
275+
</build>
276+
</profile>
277+
</profiles>
198278
</project>

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<name>parent</name>
1010
<description>Neo4j Connector for Kafka</description>
1111
<url>http://github.com/neo4j/neo4j-kafka-connector</url>
12+
<inceptionYear>2023</inceptionYear>
1213
<organization>
1314
<name>Neo4j, Neo4j Sweden AB</name>
1415
<url>https://neo4j.com</url>
@@ -50,6 +51,7 @@
5051
<hamcrest.version>2.2</hamcrest.version>
5152
<jackson.version>2.15.2</jackson.version>
5253
<java.version>11</java.version>
54+
<jreleaser-maven-plugin.version>1.9.0</jreleaser-maven-plugin.version>
5355
<junit-jupiter.version>5.10.0</junit-jupiter.version>
5456
<!-- keep the next two in sync: https://docs.confluent.io/platform/current/installation/versions-interoperability.html -->
5557
<!-- as well as versions in the docker-compose.yml file -->
@@ -237,6 +239,11 @@
237239
<build>
238240
<pluginManagement>
239241
<plugins>
242+
<plugin>
243+
<groupId>org.jreleaser</groupId>
244+
<artifactId>jreleaser-maven-plugin</artifactId>
245+
<version>${jreleaser-maven-plugin.version}</version>
246+
</plugin>
240247
<plugin>
241248
<groupId>org.neo4j.build.plugins</groupId>
242249
<artifactId>licensing-maven-plugin</artifactId>

0 commit comments

Comments
 (0)