Skip to content

Commit 50f983a

Browse files
committed
HBX-3011 Switch to Maven Central publishing
1 parent cf4d9d4 commit 50f983a

File tree

2 files changed

+57
-25
lines changed

2 files changed

+57
-25
lines changed

ci/release/Jenkinsfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
22
* Hibernate Tools, Tooling for your Hibernate Projects
3-
*
3+
*
44
* Copyright 2016-2024 Red Hat, Inc.
55
*
6-
* Licensed under the GNU Lesser General Public License (LGPL),
6+
* Licensed under the GNU Lesser General Public License (LGPL),
77
* version 2.1 or later (the "License").
88
* You may not use this file except in compliance with the License.
9-
* You may read the licence in the 'lgpl.txt' file in the root folder of
9+
* You may read the licence in the 'lgpl.txt' file in the root folder of
1010
* project or obtain a copy at
1111
*
1212
* http://www.gnu.org/licenses/lgpl-2.1.html
@@ -51,6 +51,11 @@ pipeline {
5151
defaultValue: false,
5252
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
5353
)
54+
booleanParam(
55+
name: 'RELEASE_PUBLISH_AUTOMATICALLY',
56+
defaultValue: true,
57+
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.'
58+
)
5459
}
5560
stages {
5661
stage('Release') {
@@ -75,6 +80,9 @@ pipeline {
7580
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
7681
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
7782
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
83+
if (!params.RELEASE_PUBLISH_AUTOMATICALLY) {
84+
env.JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_STAGE='UPLOAD'
85+
}
7886
echo "Performing full release for version ${releaseVersion.toString()}"
7987

8088
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
@@ -84,11 +92,7 @@ pipeline {
8492
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
8593
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
8694
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
87-
// TODO: Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
88-
// to use the following env variable names to set the user/password:
89-
// JRELEASER_MAVENCENTRAL_USERNAME
90-
// JRELEASER_MAVENCENTRAL_TOKEN
91-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
95+
usernamePassword(credentialsId: 'central.sonatype.com', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
9296
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
9397
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
9498
sh 'cat $HOME/.ssh/config'

pom.xml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
<artifactId>jboss-parent</artifactId>
1010
<version>48</version>
1111
</parent>
12-
12+
1313
<groupId>org.hibernate</groupId>
1414
<artifactId>hibernate-tools-parent</artifactId>
1515
<version>5.3.38-SNAPSHOT</version>
1616

1717
<packaging>pom</packaging>
18-
18+
1919
<name>Hibernate Tools Parent Project</name>
2020

2121
<modules>
@@ -60,16 +60,20 @@
6060
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
6161
<local.staging.releases.repo.name>Local Staging Directory Releases Repository</local.staging.releases.repo.name>
6262
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
63-
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
64-
<ossrh.snapshots.repo.name>Sonatype OSSRH Snapshots</ossrh.snapshots.repo.name>
65-
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
63+
<central.releases.repo.id>central-releases</central.releases.repo.id>
64+
<central.releases.repo.name>Maven Central Releases Repository</central.releases.repo.name>
65+
<central.releases.repo.url>https://central.sonatype.com/api/v1/publisher/</central.releases.repo.url>
66+
<central.snapshots.repo.id>central-snapshots</central.snapshots.repo.id>
67+
<central.snapshots.repo.name>Maven Central Snapshots Repository</central.snapshots.repo.name>
68+
<central.snapshots.repo.url>https://central.sonatype.com/repository/maven-snapshots/</central.snapshots.repo.url>
69+
6670

6771
<maven.compiler.target>1.8</maven.compiler.target>
6872
<maven.compiler.source>1.8</maven.compiler.source>
6973
<maven.min.version>3.9.7</maven.min.version>
7074

7175
</properties>
72-
76+
7377
<dependencyManagement>
7478
<dependencies>
7579
<dependency>
@@ -145,7 +149,7 @@
145149
</dependency>
146150
<dependency>
147151
<groupId>org.hibernate</groupId>
148-
<artifactId>hibernate-tools-tests-common</artifactId>
152+
<artifactId>hibernate-tools-tests-common</artifactId>
149153
<version>${project.version}</version>
150154
</dependency>
151155
<dependency>
@@ -174,16 +178,16 @@
174178
</dependencyManagement>
175179

176180
<distributionManagement>
177-
<repository>
178-
<id>${local.staging.releases.repo.id}</id>
179-
<name>${local.staging.releases.repo.name}</name>
180-
<url>${local.staging.releases.repo.url}</url>
181-
</repository>
182-
<snapshotRepository>
183-
<id>${ossrh.snapshots.repo.id}</id>
184-
<name>${ossrh.snapshots.repo.name}</name>
185-
<url>${ossrh.snapshots.repo.url}</url>
186-
</snapshotRepository>
181+
<repository>
182+
<id>${central.releases.repo.id}</id>
183+
<name>${central.releases.repo.name}</name>
184+
<url>${central.releases.repo.url}</url>
185+
</repository>
186+
<snapshotRepository>
187+
<id>${central.snapshots.repo.id}</id>
188+
<name>${central.snapshots.repo.name}</name>
189+
<url>${central.snapshots.repo.url}</url>
190+
</snapshotRepository>
187191
</distributionManagement>
188192

189193
<build>
@@ -261,4 +265,28 @@
261265
</plugins>
262266
</build>
263267

268+
<profiles>
269+
<profile>
270+
<id>release</id>
271+
<activation>
272+
<property>
273+
<name>performRelease</name>
274+
<value>true</value>
275+
</property>
276+
</activation>
277+
<build>
278+
<pluginManagement>
279+
<plugins>
280+
<plugin>
281+
<groupId>org.apache.maven.plugins</groupId>
282+
<artifactId>maven-deploy-plugin</artifactId>
283+
<configuration>
284+
<altReleaseDeploymentRepository>${local.staging.releases.repo.id}::${local.staging.releases.repo.url}</altReleaseDeploymentRepository>
285+
</configuration>
286+
</plugin>
287+
</plugins>
288+
</pluginManagement>
289+
</build>
290+
</profile>
291+
</profiles>
264292
</project>

0 commit comments

Comments
 (0)