Skip to content

Commit 46f8046

Browse files
committed
HSEARCH-5351 Switch to JReleaser for nexus publishing
1 parent a13f702 commit 46f8046

File tree

6 files changed

+36
-131
lines changed

6 files changed

+36
-131
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

+13-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pipeline {
6060

6161
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
6262
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
63+
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
6364
echo "Performing full release for version ${releaseVersion.toString()}"
6465

6566
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
@@ -68,13 +69,21 @@ pipeline {
6869
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
6970
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
7071
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
71-
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
72+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
73+
// TODO: HSEARCH-5354
74+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
75+
// to use the following env variable names to set the user/password:
76+
// JRELEASER_MAVENCENTRAL_USERNAME
77+
// JRELEASER_MAVENCENTRAL_TOKEN
78+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
79+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
7280
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
7381
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'
82+
dir('.release/scripts') {
83+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
84+
}
7685
sh """
77-
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
86+
bash -xe .release/scripts/release.sh -j ${params.RELEASE_DRY_RUN ? '-d' : ''} \
7887
search ${releaseVersion.toString()} ${developmentVersion.toString()}
7988
"""
8089
}

ci/snapshot-publish/Jenkinsfile

+10-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ 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+
dir('.release/scripts') {
38+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
39+
}
40+
def version = sh(
41+
script: ".release/scripts/determine-current-version.sh search",
42+
returnStdout: true
43+
).trim()
44+
echo "Current version: '${version}'"
45+
sh "bash -xe .release/scripts/snapshot-deploy.sh search ${version}"
4346
}
4447
}
4548
}

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>

pom.xml

+9-86
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@
270270
<version.enforcer.plugin>3.5.0</version.enforcer.plugin>
271271
<version.project-info.plugin>3.9.0</version.project-info.plugin>
272272
<version.japicmp.plugin>0.23.1</version.japicmp.plugin>
273-
<version.nexus-staging.plugin>1.7.0</version.nexus-staging.plugin>
274273
<version.deploy.plugin>3.1.4</version.deploy.plugin>
275-
<version.gpg.plugin>3.2.7</version.gpg.plugin>
276274
<version.flatten-maven-plugin>1.7.0</version.flatten-maven-plugin>
277275
<version.assembly.plugin>3.7.1</version.assembly.plugin>
278276
<version.buildhelper.plugin>3.6.0</version.buildhelper.plugin>
@@ -318,9 +316,9 @@
318316

319317
<!-- Repository Deployment URLs -->
320318

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>
319+
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
320+
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
321+
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
324322
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
325323
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
326324

@@ -329,7 +327,6 @@
329327
Specific modules will override the setting at their own level.
330328
-->
331329
<deploy.skip>true</deploy.skip>
332-
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
333330

334331
<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
335332
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
@@ -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)