Skip to content

Commit 5d5aedb

Browse files
committed
HSEARCH-5351 Switch to JReleaser for nexus publishing
(cherry picked from commit 46f8046)
1 parent adb84d1 commit 5d5aedb

File tree

5 files changed

+27
-122
lines changed

5 files changed

+27
-122
lines changed

.release/.gitignore

Lines changed: 3 additions & 0 deletions
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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -186,38 +186,6 @@
186186
</dependency>
187187
</dependencies>
188188
</plugin>
189-
<!--
190-
Hack to deploy in the "reports" module without deploying the "reports" module itself.
191-
The default lifecycle bindings of the plugin is to "stage locally" every artifact throughout
192-
the maven execution, and only actually deploy the "locally staged" artifacts
193-
in the very last executed module, which happens to be this "reports" module.
194-
However, this "reports" module does not generate any artifact we want to deploy.
195-
Thus, we'd like to prevent even its POM from being deployed: just deploy the "locally staged" artifacts,
196-
without adding the POM from the "reports" module to these artifacts.
197-
The default lifecycle bindings of the plugin does not offer a configuration option to do that,
198-
so we have to explicitly bind it
199-
-->
200-
<plugin>
201-
<groupId>org.sonatype.plugins</groupId>
202-
<artifactId>nexus-staging-maven-plugin</artifactId>
203-
<extensions>false</extensions>
204-
<!-- The <configuration> element is inherited from the parent module. -->
205-
<executions>
206-
<!-- Skip the default deployment, as explained above we don't want it. -->
207-
<execution>
208-
<id>default-deploy</id>
209-
<phase>none</phase>
210-
</execution>
211-
<!-- ... but execute the deferred deployment for the other modules -->
212-
<execution>
213-
<id>deferred-deploy</id>
214-
<phase>deploy</phase>
215-
<goals>
216-
<goal>deploy-staged</goal>
217-
</goals>
218-
</execution>
219-
</executions>
220-
</plugin>
221189
</plugins>
222190
</build>
223191

ci/release/Jenkinsfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pipeline {
6262

6363
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
6464
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
65+
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
6566
echo "Performing full release for version ${releaseVersion.toString()}"
6667

6768
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
@@ -70,13 +71,21 @@ pipeline {
7071
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
7172
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
7273
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
73-
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
74+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
75+
// TODO: HSEARCH-5354
76+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
77+
// to use the following env variable names to set the user/password:
78+
// JRELEASER_MAVENCENTRAL_USERNAME
79+
// JRELEASER_MAVENCENTRAL_TOKEN
80+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
81+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
7482
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
7583
sh 'cat $HOME/.ssh/config'
76-
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
77-
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
84+
dir('.release/scripts') {
85+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
86+
}
7887
sh """
79-
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
88+
bash -xe .release/scripts/release.sh -j ${params.RELEASE_DRY_RUN ? '-d' : ''} \
8089
search ${releaseVersion.toString()} ${developmentVersion.toString()}
8190
"""
8291
}

distribution/src/main/assembly/dist.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,8 @@
192192
<exclude>copyright.txt</exclude>
193193
<exclude>lgpl.txt</exclude>
194194

195-
<!-- only needed for documentation and helper scripts, no need to include them -->
196-
<exclude>hibernate-noorm-release-scripts/**</exclude>
197-
<exclude>hibernate-release-scripts/**</exclude>
195+
<!-- only needed for documentation and helper scripts, no need to include them -->
196+
<exclude>.release/**</exclude>
198197

199198
<!-- actual files which should be ignored -->
200199
<exclude>.git</exclude>

pom.xml

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@
264264
<version.enforcer.plugin>3.4.0</version.enforcer.plugin>
265265
<version.project-info.plugin>3.5.0</version.project-info.plugin>
266266
<version.japicmp.plugin>0.18.3</version.japicmp.plugin>
267-
<version.nexus-staging.plugin>1.6.13</version.nexus-staging.plugin>
268267
<version.deploy.plugin>3.1.1</version.deploy.plugin>
269-
<version.gpg.plugin>3.1.0</version.gpg.plugin>
270268
<version.flatten-maven-plugin>1.5.0</version.flatten-maven-plugin>
271269
<version.assembly.plugin>3.6.0</version.assembly.plugin>
272270
<version.buildhelper.plugin>3.5.0</version.buildhelper.plugin>
@@ -308,9 +306,9 @@
308306

309307
<!-- Repository Deployment URLs -->
310308

311-
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
312-
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
313-
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
309+
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
310+
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
311+
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
314312
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
315313
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
316314

@@ -539,39 +537,13 @@
539537
</executions>
540538
</plugin>
541539
<!-- We want to deploy the public BOM, so we manage this plugin in the root pom. -->
542-
<plugin>
543-
<groupId>org.sonatype.plugins</groupId>
544-
<artifactId>nexus-staging-maven-plugin</artifactId>
545-
<version>${version.nexus-staging.plugin}</version>
546-
<configuration>
547-
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
548-
</configuration>
549-
</plugin>
550-
<!-- We want to disable this plugin as soon as possible, hence we manage it in the root pom. -->
551540
<plugin>
552541
<groupId>org.apache.maven.plugins</groupId>
553542
<artifactId>maven-deploy-plugin</artifactId>
554543
<version>${version.deploy.plugin}</version>
555-
</plugin>
556-
<!-- Public BOM must be also signed, so we manage this plugin in the root pom. -->
557-
<plugin>
558-
<groupId>org.apache.maven.plugins</groupId>
559-
<artifactId>maven-gpg-plugin</artifactId>
560-
<version>${version.gpg.plugin}</version>
561-
<executions>
562-
<execution>
563-
<id>sign-artifacts</id>
564-
<phase>verify</phase>
565-
<goals>
566-
<goal>sign</goal>
567-
</goals>
568-
<configuration>
569-
<skip>${deploy.skip}</skip>
570-
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
571-
<bestPractices>true</bestPractices>
572-
</configuration>
573-
</execution>
574-
</executions>
544+
<configuration>
545+
<skip>${deploy.skip}</skip>
546+
</configuration>
575547
</plugin>
576548
<!-- Public BOM will be flattened too, so we manage this plugin in the root pom. -->
577549
<plugin>
@@ -1051,44 +1023,6 @@
10511023
</plugins>
10521024
</pluginManagement>
10531025
<plugins>
1054-
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
1055-
<plugin>
1056-
<groupId>org.apache.maven.plugins</groupId>
1057-
<artifactId>maven-deploy-plugin</artifactId>
1058-
<configuration>
1059-
<skip>true</skip>
1060-
</configuration>
1061-
</plugin>
1062-
<!--
1063-
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
1064-
in order to work around a problem in the "reports" module (see that module's POM for more info).
1065-
-->
1066-
<plugin>
1067-
<groupId>org.sonatype.plugins</groupId>
1068-
<artifactId>nexus-staging-maven-plugin</artifactId>
1069-
<extensions>false</extensions><!-- This is essential: do not put true here -->
1070-
<configuration>
1071-
<serverId>${ossrh.releases.repo.id}</serverId>
1072-
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
1073-
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
1074-
<!-- oss.sonatype.org has been very slow when closing repositories lately;
1075-
let's raise the timeout until we switch to s01.sonatype.org -->
1076-
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
1077-
</configuration>
1078-
<executions>
1079-
<execution>
1080-
<id>default-deploy</id>
1081-
<phase>deploy</phase>
1082-
<goals>
1083-
<!--
1084-
This will only put artifacts in a staging directory.
1085-
See the "reports" module for actual deployment, at the end of the build.
1086-
-->
1087-
<goal>deploy</goal>
1088-
</goals>
1089-
</execution>
1090-
</executions>
1091-
</plugin>
10921026
<plugin>
10931027
<artifactId>exec-maven-plugin</artifactId>
10941028
<groupId>org.codehaus.mojo</groupId>
@@ -1283,9 +1217,9 @@
12831217

12841218
<distributionManagement>
12851219
<repository>
1286-
<id>${ossrh.releases.repo.id}</id>
1287-
<name>OSSRH Releases Repository</name>
1288-
<url>${ossrh.releases.repo.url}</url>
1220+
<id>${local.staging.releases.repo.id}</id>
1221+
<name>Local Staging Directory Releases Repository</name>
1222+
<url>${local.staging.releases.repo.url}</url>
12891223
</repository>
12901224
<snapshotRepository>
12911225
<id>${ossrh.snapshots.repo.id}</id>
@@ -1379,14 +1313,6 @@
13791313
<!-- We want this execution to happen before moditect (which executes at package phase) -->
13801314
<javadoc.generate.jar.phase>prepare-package</javadoc.generate.jar.phase>
13811315
</properties>
1382-
<build>
1383-
<plugins>
1384-
<plugin>
1385-
<groupId>org.apache.maven.plugins</groupId>
1386-
<artifactId>maven-gpg-plugin</artifactId>
1387-
</plugin>
1388-
</plugins>
1389-
</build>
13901316
</profile>
13911317

13921318
<profile>

0 commit comments

Comments
 (0)