Skip to content

Commit 9156884

Browse files
committed
HBX-3011 Switch to Maven Central publishing
1 parent 9afec80 commit 9156884

File tree

2 files changed

+51
-18
lines changed

2 files changed

+51
-18
lines changed

ci/release/Jenkinsfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ pipeline {
4747
defaultValue: true,
4848
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
4949
)
50+
booleanParam(
51+
name: 'RELEASE_PUBLISH_AUTOMATICALLY',
52+
defaultValue: true,
53+
description: 'If true, staging repository will get closed and published automatically, otherwise the artifacts will only be uploaded and the publishing (releasing the staging repository) has to be performed manually at Maven Central portal.'
54+
)
5055
}
5156
stages {
5257
stage('Release') {
@@ -71,6 +76,9 @@ pipeline {
7176
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
7277
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
7378
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
79+
if (!params.RELEASE_PUBLISH_AUTOMATICALLY) {
80+
env.JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_STAGE='UPLOAD'
81+
}
7482
echo "Performing full release for version ${releaseVersion.toString()}"
7583

7684
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
@@ -80,11 +88,7 @@ pipeline {
8088
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
8189
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
8290
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
83-
// TODO: Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
84-
// to use the following env variable names to set the user/password:
85-
// JRELEASER_MAVENCENTRAL_USERNAME
86-
// JRELEASER_MAVENCENTRAL_TOKEN
87-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
91+
usernamePassword(credentialsId: 'central.sonatype.com', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
8892
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
8993
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
9094
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {

pom.xml

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@
121121
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
122122
<local.staging.releases.repo.name>Local Staging Directory Releases Repository</local.staging.releases.repo.name>
123123
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
124-
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
125-
<ossrh.snapshots.repo.name>Sonatype OSSRH Snapshots</ossrh.snapshots.repo.name>
126-
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
124+
<central.releases.repo.id>central-releases</central.releases.repo.id>
125+
<central.releases.repo.name>Maven Central Releases Repository</central.releases.repo.name>
126+
<central.releases.repo.url>https://central.sonatype.com/api/v1/publisher/</central.releases.repo.url>
127+
<central.snapshots.repo.id>central-snapshots</central.snapshots.repo.id>
128+
<central.snapshots.repo.name>Maven Central Snapshots Repository</central.snapshots.repo.name>
129+
<central.snapshots.repo.url>https://central.sonatype.com/repository/maven-snapshots/</central.snapshots.repo.url>
130+
127131

128132
<maven.compiler.target>17</maven.compiler.target>
129133
<maven.compiler.source>17</maven.compiler.source>
@@ -263,16 +267,16 @@
263267
</dependencyManagement>
264268

265269
<distributionManagement>
266-
<repository>
267-
<id>${local.staging.releases.repo.id}</id>
268-
<name>${local.staging.releases.repo.name}</name>
269-
<url>${local.staging.releases.repo.url}</url>
270-
</repository>
271-
<snapshotRepository>
272-
<id>${ossrh.snapshots.repo.id}</id>
273-
<name>${ossrh.snapshots.repo.name}</name>
274-
<url>${ossrh.snapshots.repo.url}</url>
275-
</snapshotRepository>
270+
<repository>
271+
<id>${central.releases.repo.id}</id>
272+
<name>${central.releases.repo.name}</name>
273+
<url>${central.releases.repo.url}</url>
274+
</repository>
275+
<snapshotRepository>
276+
<id>${central.snapshots.repo.id}</id>
277+
<name>${central.snapshots.repo.name}</name>
278+
<url>${central.snapshots.repo.url}</url>
279+
</snapshotRepository>
276280
</distributionManagement>
277281

278282
<build>
@@ -349,4 +353,29 @@
349353
</plugin>
350354
</plugins>
351355
</build>
356+
357+
<profiles>
358+
<profile>
359+
<id>release</id>
360+
<activation>
361+
<property>
362+
<name>performRelease</name>
363+
<value>true</value>
364+
</property>
365+
</activation>
366+
<build>
367+
<pluginManagement>
368+
<plugins>
369+
<plugin>
370+
<groupId>org.apache.maven.plugins</groupId>
371+
<artifactId>maven-deploy-plugin</artifactId>
372+
<configuration>
373+
<altReleaseDeploymentRepository>${local.staging.releases.repo.id}::${local.staging.releases.repo.url}</altReleaseDeploymentRepository>
374+
</configuration>
375+
</plugin>
376+
</plugins>
377+
</pluginManagement>
378+
</build>
379+
</profile>
380+
</profiles>
352381
</project>

0 commit comments

Comments
 (0)