Skip to content

Commit 1880062

Browse files
committed
HSEARCH-5351 Switch to JReleaser for nexus publishing
(cherry picked from commit 46f8046)
1 parent 6a7f675 commit 1880062

File tree

6 files changed

+44
-125
lines changed

6 files changed

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

ci/release/Jenkinsfile

Lines changed: 13 additions & 4 deletions
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

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@
189189
<exclude>copyright.txt</exclude>
190190
<exclude>LICENSE.txt</exclude>
191191

192-
<!-- only needed for documentation and helper scripts, no need to include them -->
193-
<exclude>hibernate-noorm-release-scripts/**</exclude>
194-
<exclude>hibernate-release-scripts/**</exclude>
192+
<!-- only needed for documentation and helper scripts, no need to include them -->
193+
<exclude>.release/**</exclude>
195194

196195
<!-- actual files which should be ignored -->
197196
<exclude>.git</exclude>

pom.xml

Lines changed: 16 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@
267267
<version.enforcer.plugin>3.5.0</version.enforcer.plugin>
268268
<version.project-info.plugin>3.6.2</version.project-info.plugin>
269269
<version.japicmp.plugin>0.22.0</version.japicmp.plugin>
270-
<version.nexus-staging.plugin>1.7.0</version.nexus-staging.plugin>
271270
<version.deploy.plugin>3.1.2</version.deploy.plugin>
272-
<version.gpg.plugin>3.2.4</version.gpg.plugin>
273271
<version.flatten-maven-plugin>1.6.0</version.flatten-maven-plugin>
274272
<version.assembly.plugin>3.7.1</version.assembly.plugin>
275273
<version.buildhelper.plugin>3.6.0</version.buildhelper.plugin>
@@ -311,9 +309,11 @@
311309

312310
<!-- Repository Deployment URLs -->
313311

312+
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
313+
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
314+
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
314315
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
315316
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
316-
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
317317
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
318318
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
319319

@@ -322,7 +322,6 @@
322322
Specific modules will override the setting at their own level.
323323
-->
324324
<deploy.skip>true</deploy.skip>
325-
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
326325

327326
<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
328327
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
@@ -554,39 +553,13 @@
554553
</executions>
555554
</plugin>
556555
<!-- We want to deploy the public BOM, so we manage this plugin in the root pom. -->
557-
<plugin>
558-
<groupId>org.sonatype.plugins</groupId>
559-
<artifactId>nexus-staging-maven-plugin</artifactId>
560-
<version>${version.nexus-staging.plugin}</version>
561-
<configuration>
562-
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
563-
</configuration>
564-
</plugin>
565-
<!-- We want to disable this plugin as soon as possible, hence we manage it in the root pom. -->
566556
<plugin>
567557
<groupId>org.apache.maven.plugins</groupId>
568558
<artifactId>maven-deploy-plugin</artifactId>
569559
<version>${version.deploy.plugin}</version>
570-
</plugin>
571-
<!-- Public BOM must be also signed, so we manage this plugin in the root pom. -->
572-
<plugin>
573-
<groupId>org.apache.maven.plugins</groupId>
574-
<artifactId>maven-gpg-plugin</artifactId>
575-
<version>${version.gpg.plugin}</version>
576-
<executions>
577-
<execution>
578-
<id>sign-artifacts</id>
579-
<phase>verify</phase>
580-
<goals>
581-
<goal>sign</goal>
582-
</goals>
583-
<configuration>
584-
<skip>${deploy.skip}</skip>
585-
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
586-
<bestPractices>true</bestPractices>
587-
</configuration>
588-
</execution>
589-
</executions>
560+
<configuration>
561+
<skip>${deploy.skip}</skip>
562+
</configuration>
590563
</plugin>
591564
<!-- Public BOM will be flattened too, so we manage this plugin in the root pom. -->
592565
<plugin>
@@ -1068,44 +1041,6 @@
10681041
</plugins>
10691042
</pluginManagement>
10701043
<plugins>
1071-
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
1072-
<plugin>
1073-
<groupId>org.apache.maven.plugins</groupId>
1074-
<artifactId>maven-deploy-plugin</artifactId>
1075-
<configuration>
1076-
<skip>${maven-deploy-plugin.skip}</skip>
1077-
</configuration>
1078-
</plugin>
1079-
<!--
1080-
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
1081-
in order to work around a problem in the "reports" module (see that module's POM for more info).
1082-
-->
1083-
<plugin>
1084-
<groupId>org.sonatype.plugins</groupId>
1085-
<artifactId>nexus-staging-maven-plugin</artifactId>
1086-
<extensions>false</extensions><!-- This is essential: do not put true here -->
1087-
<configuration>
1088-
<serverId>${ossrh.releases.repo.id}</serverId>
1089-
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
1090-
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
1091-
<!-- oss.sonatype.org has been very slow when closing repositories lately;
1092-
let's raise the timeout until we switch to s01.sonatype.org -->
1093-
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
1094-
</configuration>
1095-
<executions>
1096-
<execution>
1097-
<id>default-deploy</id>
1098-
<phase>deploy</phase>
1099-
<goals>
1100-
<!--
1101-
This will only put artifacts in a staging directory.
1102-
See the "reports" module for actual deployment, at the end of the build.
1103-
-->
1104-
<goal>deploy</goal>
1105-
</goals>
1106-
</execution>
1107-
</executions>
1108-
</plugin>
11091044
<plugin>
11101045
<groupId>org.apache.maven.plugins</groupId>
11111046
<artifactId>maven-compiler-plugin</artifactId>
@@ -1301,12 +1236,16 @@
13011236
<javadoc.generate.jar.phase>prepare-package</javadoc.generate.jar.phase>
13021237
</properties>
13031238
<build>
1304-
<plugins>
1305-
<plugin>
1306-
<groupId>org.apache.maven.plugins</groupId>
1307-
<artifactId>maven-gpg-plugin</artifactId>
1308-
</plugin>
1309-
</plugins>
1239+
<pluginManagement>
1240+
<plugins>
1241+
<plugin>
1242+
<artifactId>maven-deploy-plugin</artifactId>
1243+
<configuration>
1244+
<altReleaseDeploymentRepository>${local.staging.releases.repo.id}::${local.staging.releases.repo.url}</altReleaseDeploymentRepository>
1245+
</configuration>
1246+
</plugin>
1247+
</plugins>
1248+
</pluginManagement>
13101249
</build>
13111250
</profile>
13121251

@@ -1788,10 +1727,8 @@
17881727
-->
17891728
<id>reproducibility-check</id>
17901729
<properties>
1791-
<maven-deploy-plugin.skip>false</maven-deploy-plugin.skip>
17921730
<maven.javadoc.skip>true</maven.javadoc.skip>
17931731
<skipTests>true</skipTests>
1794-
<gpg.skip>true</gpg.skip>
17951732
</properties>
17961733
</profile>
17971734

0 commit comments

Comments
 (0)