Skip to content

Commit 8433de8

Browse files
ali-incefbiville
authored andcommitted
ci: configure release pipeline with JReleaser
Signed-off-by: Florent Biville <[email protected]>
1 parent 3662fe0 commit 8433de8

File tree

4 files changed

+206
-94
lines changed

4 files changed

+206
-94
lines changed

.teamcity/builds/Release.kt

Lines changed: 129 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,135 @@
11
package builds
22

3-
import jetbrains.buildServer.configs.kotlin.*
4-
import jetbrains.buildServer.configs.kotlin.buildFeatures.dockerSupport
3+
import jetbrains.buildServer.configs.kotlin.AbsoluteId
4+
import jetbrains.buildServer.configs.kotlin.BuildType
5+
import jetbrains.buildServer.configs.kotlin.ParameterDisplay
6+
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
7+
import jetbrains.buildServer.configs.kotlin.buildSteps.script
8+
import jetbrains.buildServer.configs.kotlin.toId
59

610
private const val DRY_RUN = "dry-run"
711

812
class Release(id: String, name: String) :
9-
BuildType({
10-
this.id(id.toId())
11-
this.name = name
12-
13-
templates(AbsoluteId("FetchSigningKey"))
14-
15-
params {
16-
text(
17-
"releaseVersion",
18-
"",
19-
label = "Version to release",
20-
display = ParameterDisplay.PROMPT,
21-
allowEmpty = false)
22-
text(
23-
"nextSnapshotVersion",
24-
"",
25-
label = "Next snapshot version",
26-
description = "Next snapshot version to set after release",
27-
display = ParameterDisplay.PROMPT,
28-
allowEmpty = false)
29-
30-
checkbox(
31-
DRY_RUN,
32-
"true",
33-
"Dry run?",
34-
description = "Whether to perform a dry run where nothing is published and released",
35-
display = ParameterDisplay.PROMPT,
36-
checked = "true",
37-
unchecked = "false")
38-
39-
text("env.JRELEASER_DRY_RUN", "%$DRY_RUN%")
40-
41-
password("env.JRELEASER_GITHUB_TOKEN", "%github-pull-request-token%")
42-
password("env.OSSSONATYPEORG_USERNAME", "%osssonatypeorg-username%")
43-
password("env.OSSSONATYPEORG_PASSWORD", "%osssonatypeorg-password%")
44-
password("env.SIGNING_KEY_PASSPHRASE", "%signing-key-passphrase%")
45-
}
46-
47-
steps {
48-
setVersion("Set release version", "%releaseVersion%")
49-
50-
runMaven(DEFAULT_JAVA_VERSION) {
51-
this.name = "Build versioned packages"
52-
goals = "deploy"
53-
runnerArgs = "$MAVEN_DEFAULT_ARGS -Ppublication -Dmaven.test.skip -Dspotless.skip"
54-
}
55-
56-
commitAndPush(
57-
"Push release version",
58-
"build: release version %releaseVersion%",
59-
dryRunParameter = DRY_RUN)
60-
61-
runMaven(DEFAULT_JAVA_VERSION) {
62-
this.name = "Release to Github"
63-
goals = "jreleaser:auto-config-release"
64-
runnerArgs = "$MAVEN_DEFAULT_ARGS -Prelease"
65-
}
66-
67-
setVersion("Set next snapshot version", "%nextSnapshotVersion%")
68-
69-
commitAndPush(
70-
"Push next snapshot version",
71-
"build: update version to %nextSnapshotVersion%",
72-
dryRunParameter = DRY_RUN)
73-
74-
publishToMavenCentral("Publish to Maven Central", dryRunParameter = DRY_RUN)
75-
}
76-
77-
dependencies {
78-
artifacts(AbsoluteId("Tools_ReleaseTool")) {
79-
buildRule = lastSuccessful()
80-
artifactRules = "rt.jar => lib"
81-
}
82-
}
83-
84-
features { dockerSupport {} }
85-
86-
requirements { runOnLinux(LinuxSize.SMALL) }
87-
})
13+
BuildType(
14+
{
15+
this.id(id.toId())
16+
this.name = name
17+
18+
templates(AbsoluteId("FetchSigningKey"))
19+
20+
params {
21+
text(
22+
"releaseVersion",
23+
"",
24+
label = "Version to release",
25+
display = ParameterDisplay.PROMPT,
26+
allowEmpty = false,
27+
)
28+
text(
29+
"nextSnapshotVersion",
30+
"",
31+
label = "Next snapshot version",
32+
description = "Next snapshot version to set after release",
33+
display = ParameterDisplay.PROMPT,
34+
allowEmpty = false,
35+
)
36+
37+
checkbox(
38+
DRY_RUN,
39+
"true",
40+
"Dry run?",
41+
description =
42+
"Whether to perform a dry run where nothing is published and released",
43+
display = ParameterDisplay.PROMPT,
44+
checked = "true",
45+
unchecked = "false",
46+
)
47+
48+
password("env.JRELEASER_GITHUB_TOKEN", "%github-pull-request-token%")
49+
50+
text("env.JRELEASER_DRY_RUN", "%$DRY_RUN%")
51+
text("env.JRELEASER_PROJECT_VERSION", "%releaseVersion%")
52+
53+
text("env.JRELEASER_ANNOUNCE_SLACK_ACTIVE", "NEVER")
54+
text("env.JRELEASER_ANNOUNCE_SLACK_TOKEN", "%slack-token%")
55+
text("env.JRELEASER_ANNOUNCE_SLACK_WEBHOOK", "%slack-webhook%")
56+
57+
password("env.JRELEASER_GPG_PASSPHRASE", "%signing-key-passphrase%")
58+
59+
text("env.JRELEASER_MAVENCENTRAL_USERNAME", "%publish-username%")
60+
password("env.JRELEASER_MAVENCENTRAL_TOKEN", "%publish-password%")
61+
}
62+
63+
steps {
64+
setVersion("Set release version", "%releaseVersion%")
65+
66+
commitAndPush(
67+
"Push release version",
68+
"build: release version %releaseVersion%",
69+
dryRunParameter = DRY_RUN,
70+
)
71+
72+
script {
73+
scriptContent =
74+
"""
75+
#!/bin/bash
76+
77+
set -eux
78+
79+
apt-get update
80+
apt-get install --yes build-essential curl git unzip zip
81+
82+
# Get the jreleaser downloader
83+
curl -sL https://raw.githubusercontent.com/jreleaser/release-action/refs/tags/2.4.2/get_jreleaser.java > get_jreleaser.java
84+
85+
# Download JReleaser with version = 1.18.0
86+
java get_jreleaser.java 1.18.0
87+
88+
if [ "%dry-run%" = "true" ]; then
89+
echo "we are on a dry run, only performing upload to maven central"
90+
export JRELEASER_MAVENCENTRAL_STAGE=UPLOAD
91+
export JRELEASER_ANNOUNCE_SLACK_ACTIVE=NEVER
92+
else
93+
echo "we will do a full deploy to maven central"
94+
export JRELEASER_MAVENCENTRAL_STAGE=FULL
95+
export JRELEASER_ANNOUNCE_SLACK_ACTIVE=ALWAYS
96+
fi
97+
98+
# Execute JReleaser
99+
java -jar jreleaser-cli.jar assemble
100+
java -jar jreleaser-cli.jar full-release
101+
"""
102+
.trimIndent()
103+
104+
dockerImagePlatform = ScriptBuildStep.ImagePlatform.Linux
105+
dockerImage = "eclipse-temurin:21-jdk"
106+
dockerRunParameters =
107+
"--volume /var/run/docker.sock:/var/run/docker.sock --volume %teamcity.build.checkoutDir%/signingkeysandbox:/root/.gnupg"
108+
}
109+
110+
setVersion("Set next snapshot version", "%nextSnapshotVersion%")
111+
112+
commitAndPush(
113+
"Push next snapshot version",
114+
"build: update version to %nextSnapshotVersion%",
115+
dryRunParameter = DRY_RUN,
116+
)
117+
}
118+
119+
artifactRules =
120+
"""
121+
+:target/maven-artifacts => artifacts
122+
+:out/jreleaser => jreleaser
123+
"""
124+
.trimIndent()
125+
126+
dependencies {
127+
artifacts(AbsoluteId("Tools_ReleaseTool")) {
128+
buildRule = lastSuccessful()
129+
artifactRules = "rt.jar => lib"
130+
}
131+
}
132+
133+
requirements { runOnLinux(LinuxSize.SMALL) }
134+
},
135+
)

.teamcity/settings.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import builds.Build
22
import jetbrains.buildServer.configs.kotlin.project
33
import jetbrains.buildServer.configs.kotlin.version
44

5-
version = "2024.03"
5+
version = "2025.03"
66

77
project {
88
params {

jreleaser.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Generated with JReleaser 1.17.0 at 2025-04-28T13:27:24.943485+01:00
2+
project:
3+
name: neo4j-import-spec
4+
description: Uniform Import Specification Library for Neo4j
5+
authors:
6+
- Connectors Team
7+
license: Apache-2.0
8+
copyright: Neo4j, Inc.
9+
links:
10+
homepage: https://github.com/neo4j/import-spec
11+
languages:
12+
java:
13+
groupId: org.neo4j.importer
14+
15+
release:
16+
github:
17+
owner: neo4j
18+
name: import-spec
19+
tagName: "{{projectVersion}}"
20+
update:
21+
enabled: true
22+
sections:
23+
- TITLE
24+
- BODY
25+
- ASSETS
26+
artifacts: false
27+
files: true
28+
changelog:
29+
formatted: ALWAYS
30+
preset: conventional-commits
31+
skipMergeCommits: true
32+
format: "- {{commitShortHash}} {{conventionalCommitDescription}}"
33+
links: true
34+
labelers:
35+
- title: ci
36+
label: ci
37+
excludeLabels:
38+
- ci
39+
hide:
40+
contributors:
41+
- '[bot]'
42+
- GitHub
43+
44+
hooks:
45+
script:
46+
before:
47+
- filter:
48+
includes: [ "assemble" ]
49+
continueOnError: false
50+
verbose: true
51+
shell: BASH
52+
run: |
53+
./mvnw --quiet --batch-mode clean package -DskipTests -DaltDeploymentRepository=default::file://{{basedir}}/target/maven-artifacts
54+
55+
signing:
56+
active: ALWAYS
57+
mode: COMMAND
58+
command:
59+
homeDir: '~/.gnupg'
60+
61+
deploy:
62+
maven:
63+
active: ALWAYS
64+
mavenCentral:
65+
artifacts:
66+
active: ALWAYS
67+
url: https://central.sonatype.com/api/v1/publisher
68+
applyMavenCentralRules: true
69+
namespace: org.neo4j
70+
verifyPom: false
71+
stagingRepositories:
72+
- ./target/maven-artifacts
73+
74+
announce:
75+
slack:
76+
channel: '#release'

pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,5 @@
278278
</plugins>
279279
</build>
280280
</profile>
281-
<profile>
282-
<id>release</id>
283-
<build>
284-
<plugins>
285-
<plugin>
286-
<groupId>org.jreleaser</groupId>
287-
<artifactId>jreleaser-maven-plugin</artifactId>
288-
<version>${jreleaser-maven-plugin.version}</version>
289-
</plugin>
290-
</plugins>
291-
</build>
292-
</profile>
293281
</profiles>
294282
</project>

0 commit comments

Comments
 (0)