Skip to content

Commit 7b62913

Browse files
committed
HSEARCH-5351 Switch to JReleaser for nexus publishing
1 parent fdd0e7e commit 7b62913

File tree

7 files changed

+115
-165
lines changed

7 files changed

+115
-165
lines changed

.release/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The folder into which we checkout our release scripts into
2+
*
3+
!.gitignore

build/reports/pom.xml

-32
Original file line numberDiff line numberDiff line change
@@ -214,38 +214,6 @@
214214
</dependency>
215215
</dependencies>
216216
</plugin>
217-
<!--
218-
Hack to deploy in the "reports" module without deploying the "reports" module itself.
219-
The default lifecycle bindings of the plugin is to "stage locally" every artifact throughout
220-
the maven execution, and only actually deploy the "locally staged" artifacts
221-
in the very last executed module, which happens to be this "reports" module.
222-
However, this "reports" module does not generate any artifact we want to deploy.
223-
Thus, we'd like to prevent even its POM from being deployed: just deploy the "locally staged" artifacts,
224-
without adding the POM from the "reports" module to these artifacts.
225-
The default lifecycle bindings of the plugin does not offer a configuration option to do that,
226-
so we have to explicitly bind it
227-
-->
228-
<plugin>
229-
<groupId>org.sonatype.plugins</groupId>
230-
<artifactId>nexus-staging-maven-plugin</artifactId>
231-
<extensions>false</extensions>
232-
<!-- The <configuration> element is inherited from the parent module. -->
233-
<executions>
234-
<!-- Skip the default deployment, as explained above we don't want it. -->
235-
<execution>
236-
<id>default-deploy</id>
237-
<phase>none</phase>
238-
</execution>
239-
<!-- ... but execute the deferred deployment for the other modules -->
240-
<execution>
241-
<id>deferred-deploy</id>
242-
<phase>deploy</phase>
243-
<goals>
244-
<goal>deploy-staged</goal>
245-
</goals>
246-
</execution>
247-
</executions>
248-
</plugin>
249217
</plugins>
250218
</build>
251219

ci/release/Jenkinsfile

+12-4
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,21 @@ pipeline {
6868
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
6969
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
7070
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
71-
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
71+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
72+
// TODO: HSEARCH-5354
73+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
74+
// to use the following env variable names to set the user/password:
75+
// JRELEASER_MAVENCENTRAL_USERNAME
76+
// JRELEASER_MAVENCENTRAL_TOKEN
77+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
78+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
7279
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
7380
sh 'cat $HOME/.ssh/config'
74-
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
75-
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
81+
dir('.release/scripts') {
82+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
83+
}
7684
sh """
77-
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
85+
bash -xe .release/scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
7886
search ${releaseVersion.toString()} ${developmentVersion.toString()}
7987
"""
8088
}

ci/snapshot-publish/Jenkinsfile

+18-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ pipeline {
3333
stage('Publish') {
3434
steps {
3535
script {
36-
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven',
37-
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
38-
sh """mvn \
39-
-Pci-build \
40-
-DskipTests \
41-
clean deploy \
42-
"""
36+
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven', mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
37+
withCredentials([// TODO: HSEARCH-5354
38+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
39+
// to use the following env variable names to set the user/password:
40+
// JRELEASER_MAVENCENTRAL_USERNAME
41+
// JRELEASER_MAVENCENTRAL_TOKEN
42+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
43+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
44+
dir('.release/scripts') {
45+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
46+
}
47+
def version = sh(
48+
script: ".release/scripts/determine-current-version.sh search",
49+
returnStdout: true
50+
).trim()
51+
echo "Current version: '${version}'"
52+
sh "bash -xe .release/scripts/snapshot-deploy.sh search ${version}"
53+
}
4354
}
4455
}
4556
}

distribution/src/main/assembly/dist.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@
201201
<exclude>LICENSE.txt</exclude>
202202

203203
<!-- only needed for documentation and helper scripts, no need to include them -->
204-
<exclude>hibernate-noorm-release-scripts/**</exclude>
205-
<exclude>hibernate-release-scripts/**</exclude>
204+
<exclude>.release/**</exclude>
206205

207206
<!-- actual files which should be ignored -->
208207
<exclude>.git</exclude>

jreleaser.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
project:
2+
languages:
3+
java:
4+
groupId: org.hibernate.search
5+
6+
release:
7+
github:
8+
skipTag: true
9+
skipRelease: true
10+
tagName: '{{projectVersion}}'
11+
12+
# File signing is always active
13+
signing:
14+
mode: COMMAND
15+
active: RELEASE
16+
armored: true
17+
18+
# Deploy JARs and POMs to Maven Central
19+
deploy:
20+
maven:
21+
nexus2:
22+
maven-central:
23+
active: RELEASE
24+
url: https://oss.sonatype.org/service/local
25+
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
26+
closeRepository: true
27+
releaseRepository: false
28+
stagingRepositories:
29+
- target/staging-deploy/maven
30+
mavenCentral:
31+
maven-central:
32+
# TODO: HSEARCH-5354 Change to RELEASE once switching to Maven-Central:
33+
active: NEVER
34+
url: https://central.sonatype.com/api/v1/publisher
35+
snapshotSupported: false
36+
applyMavenCentralRules: true
37+
stagingRepositories:
38+
- target/staging-deploy/maven

pom.xml

+43-120
Original file line numberDiff line numberDiff line change
@@ -156,40 +156,6 @@
156156
</mailingList>
157157
</mailingLists>
158158

159-
<modules>
160-
<module>bom/public</module>
161-
<module>build/parents/relocation</module>
162-
<module>build/parents/build</module>
163-
<module>build/enforcer</module>
164-
<module>build/config</module>
165-
<module>build/parents/internal</module>
166-
<module>util/internal/test/common</module>
167-
<module>util/internal/test/orm</module>
168-
<module>build/parents/public</module>
169-
<module>util/common</module>
170-
<module>engine</module>
171-
<module>backend/lucene</module>
172-
<module>backend/elasticsearch</module>
173-
<module>backend/elasticsearch-aws</module>
174-
<module>mapper/pojo-base</module>
175-
<module>mapper/pojo-standalone</module>
176-
<module>mapper/orm</module>
177-
<module>mapper/orm-outbox-polling</module>
178-
<module>mapper/orm-coordination-outbox-polling</module>
179-
<module>mapper/orm-batch-jsr352/core</module>
180-
<module>mapper/orm-batch-jsr352/jberet</module>
181-
<module>mapper/orm-jakarta-batch/core</module>
182-
<module>mapper/orm-jakarta-batch/jberet</module>
183-
<module>v5migrationhelper/engine</module>
184-
<module>v5migrationhelper/orm</module>
185-
<module>util/internal/integrationtest</module>
186-
<module>build/parents/integrationtest</module>
187-
<module>build/parents/springtest</module>
188-
<module>integrationtest</module>
189-
<module>documentation</module>
190-
<module>lucene-next</module>
191-
</modules>
192-
193159
<properties>
194160
<!--
195161
Version to be used as baseline for API/SPI change reports,
@@ -270,9 +236,7 @@
270236
<version.enforcer.plugin>3.5.0</version.enforcer.plugin>
271237
<version.project-info.plugin>3.9.0</version.project-info.plugin>
272238
<version.japicmp.plugin>0.23.1</version.japicmp.plugin>
273-
<version.nexus-staging.plugin>1.7.0</version.nexus-staging.plugin>
274239
<version.deploy.plugin>3.1.4</version.deploy.plugin>
275-
<version.gpg.plugin>3.2.7</version.gpg.plugin>
276240
<version.flatten-maven-plugin>1.7.0</version.flatten-maven-plugin>
277241
<version.assembly.plugin>3.7.1</version.assembly.plugin>
278242
<version.buildhelper.plugin>3.6.0</version.buildhelper.plugin>
@@ -318,9 +282,9 @@
318282

319283
<!-- Repository Deployment URLs -->
320284

321-
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
322-
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
323-
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
285+
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
286+
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
287+
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
324288
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
325289
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
326290

@@ -329,7 +293,6 @@
329293
Specific modules will override the setting at their own level.
330294
-->
331295
<deploy.skip>true</deploy.skip>
332-
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
333296

334297
<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
335298
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
@@ -496,6 +459,40 @@
496459
</sonar.cpd.exclusions>
497460
</properties>
498461

462+
<modules>
463+
<module>bom/public</module>
464+
<module>build/parents/relocation</module>
465+
<module>build/parents/build</module>
466+
<module>build/enforcer</module>
467+
<module>build/config</module>
468+
<module>build/parents/internal</module>
469+
<module>util/internal/test/common</module>
470+
<module>util/internal/test/orm</module>
471+
<module>build/parents/public</module>
472+
<module>util/common</module>
473+
<module>engine</module>
474+
<module>backend/lucene</module>
475+
<module>backend/elasticsearch</module>
476+
<module>backend/elasticsearch-aws</module>
477+
<module>mapper/pojo-base</module>
478+
<module>mapper/pojo-standalone</module>
479+
<module>mapper/orm</module>
480+
<module>mapper/orm-outbox-polling</module>
481+
<module>mapper/orm-coordination-outbox-polling</module>
482+
<module>mapper/orm-batch-jsr352/core</module>
483+
<module>mapper/orm-batch-jsr352/jberet</module>
484+
<module>mapper/orm-jakarta-batch/core</module>
485+
<module>mapper/orm-jakarta-batch/jberet</module>
486+
<module>v5migrationhelper/engine</module>
487+
<module>v5migrationhelper/orm</module>
488+
<module>util/internal/integrationtest</module>
489+
<module>build/parents/integrationtest</module>
490+
<module>build/parents/springtest</module>
491+
<module>integrationtest</module>
492+
<module>documentation</module>
493+
<module>lucene-next</module>
494+
</modules>
495+
499496
<build>
500497
<defaultGoal>install</defaultGoal>
501498
<pluginManagement>
@@ -555,39 +552,13 @@
555552
</executions>
556553
</plugin>
557554
<!-- We want to deploy the public BOM, so we manage this plugin in the root pom. -->
558-
<plugin>
559-
<groupId>org.sonatype.plugins</groupId>
560-
<artifactId>nexus-staging-maven-plugin</artifactId>
561-
<version>${version.nexus-staging.plugin}</version>
562-
<configuration>
563-
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
564-
</configuration>
565-
</plugin>
566-
<!-- We want to disable this plugin as soon as possible, hence we manage it in the root pom. -->
567555
<plugin>
568556
<groupId>org.apache.maven.plugins</groupId>
569557
<artifactId>maven-deploy-plugin</artifactId>
570558
<version>${version.deploy.plugin}</version>
571-
</plugin>
572-
<!-- Public BOM must be also signed, so we manage this plugin in the root pom. -->
573-
<plugin>
574-
<groupId>org.apache.maven.plugins</groupId>
575-
<artifactId>maven-gpg-plugin</artifactId>
576-
<version>${version.gpg.plugin}</version>
577-
<executions>
578-
<execution>
579-
<id>sign-artifacts</id>
580-
<phase>verify</phase>
581-
<goals>
582-
<goal>sign</goal>
583-
</goals>
584-
<configuration>
585-
<skip>${deploy.skip}</skip>
586-
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
587-
<bestPractices>true</bestPractices>
588-
</configuration>
589-
</execution>
590-
</executions>
559+
<configuration>
560+
<skip>${deploy.skip}</skip>
561+
</configuration>
591562
</plugin>
592563
<!-- Public BOM will be flattened too, so we manage this plugin in the root pom. -->
593564
<plugin>
@@ -1140,44 +1111,6 @@
11401111
</plugins>
11411112
</pluginManagement>
11421113
<plugins>
1143-
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
1144-
<plugin>
1145-
<groupId>org.apache.maven.plugins</groupId>
1146-
<artifactId>maven-deploy-plugin</artifactId>
1147-
<configuration>
1148-
<skip>${maven-deploy-plugin.skip}</skip>
1149-
</configuration>
1150-
</plugin>
1151-
<!--
1152-
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
1153-
in order to work around a problem in the "reports" module (see that module's POM for more info).
1154-
-->
1155-
<plugin>
1156-
<groupId>org.sonatype.plugins</groupId>
1157-
<artifactId>nexus-staging-maven-plugin</artifactId>
1158-
<extensions>false</extensions><!-- This is essential: do not put true here -->
1159-
<configuration>
1160-
<serverId>${ossrh.releases.repo.id}</serverId>
1161-
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
1162-
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
1163-
<!-- oss.sonatype.org has been very slow when closing repositories lately;
1164-
let's raise the timeout until we switch to s01.sonatype.org -->
1165-
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
1166-
</configuration>
1167-
<executions>
1168-
<execution>
1169-
<id>default-deploy</id>
1170-
<phase>deploy</phase>
1171-
<goals>
1172-
<!--
1173-
This will only put artifacts in a staging directory.
1174-
See the "reports" module for actual deployment, at the end of the build.
1175-
-->
1176-
<goal>deploy</goal>
1177-
</goals>
1178-
</execution>
1179-
</executions>
1180-
</plugin>
11811114
<plugin>
11821115
<groupId>org.apache.maven.plugins</groupId>
11831116
<artifactId>maven-compiler-plugin</artifactId>
@@ -1251,9 +1184,9 @@
12511184

12521185
<distributionManagement>
12531186
<repository>
1254-
<id>${ossrh.releases.repo.id}</id>
1255-
<name>OSSRH Releases Repository</name>
1256-
<url>${ossrh.releases.repo.url}</url>
1187+
<id>${local.staging.releases.repo.id}</id>
1188+
<name>Local Staging Directory Releases Repository</name>
1189+
<url>${local.staging.releases.repo.url}</url>
12571190
</repository>
12581191
<snapshotRepository>
12591192
<id>${ossrh.snapshots.repo.id}</id>
@@ -1347,14 +1280,6 @@
13471280
<!-- We want this execution to happen before moditect (which executes at package phase) -->
13481281
<javadoc.generate.jar.phase>prepare-package</javadoc.generate.jar.phase>
13491282
</properties>
1350-
<build>
1351-
<plugins>
1352-
<plugin>
1353-
<groupId>org.apache.maven.plugins</groupId>
1354-
<artifactId>maven-gpg-plugin</artifactId>
1355-
</plugin>
1356-
</plugins>
1357-
</build>
13581283
</profile>
13591284

13601285
<profile>
@@ -1800,10 +1725,8 @@
18001725
-->
18011726
<id>reproducibility-check</id>
18021727
<properties>
1803-
<maven-deploy-plugin.skip>false</maven-deploy-plugin.skip>
18041728
<maven.javadoc.skip>true</maven.javadoc.skip>
18051729
<skipTests>true</skipTests>
1806-
<gpg.skip>true</gpg.skip>
18071730
</properties>
18081731
</profile>
18091732

0 commit comments

Comments
 (0)