Skip to content

Commit b7e408d

Browse files
committed
HBX-2936 Adjust POMs to use gpg/nexus plugins for the release
1 parent 347f246 commit b7e408d

File tree

8 files changed

+353
-17
lines changed

8 files changed

+353
-17
lines changed

ant/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
<description>Hibernate Tools Ant Tasks</description>
3131
<packaging>jar</packaging>
3232

33+
<properties>
34+
<!-- This is a publicly distributed module that should be published: -->
35+
<deploy.skip>false</deploy.skip>
36+
</properties>
37+
3338
<dependencies>
3439
<dependency>
3540
<groupId>org.apache.ant</groupId>

ci/release/Jenkinsfile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Hibernate Tools, Tooling for your Hibernate Projects
3+
*
4+
* Copyright 2016-2024 Red Hat, Inc.
5+
*
6+
* Licensed under the GNU Lesser General Public License (LGPL),
7+
* version 2.1 or later (the "License").
8+
* 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
10+
* project or obtain a copy at
11+
*
12+
* http://www.gnu.org/licenses/lgpl-2.1.html
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" basis,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
@Library('hibernate-jenkins-pipeline-helpers') _
21+
22+
import org.hibernate.jenkins.pipeline.helpers.version.Version
23+
24+
pipeline {
25+
agent {
26+
label 'Worker&&Containers'
27+
}
28+
tools {
29+
maven 'Apache Maven 3.9'
30+
jdk 'OpenJDK 21 Latest'
31+
}
32+
options {
33+
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
34+
disableConcurrentBuilds(abortPrevious: false)
35+
}
36+
parameters {
37+
string(
38+
name: 'RELEASE_VERSION',
39+
defaultValue: '',
40+
description: 'The version to be released, e.g. 7.0.0.Final.',
41+
trim: true
42+
)
43+
string(
44+
name: 'DEVELOPMENT_VERSION',
45+
defaultValue: '',
46+
description: 'The next version to be used after the release, e.g. 7.0.1-SNAPSHOT.',
47+
trim: true
48+
)
49+
booleanParam(
50+
name: 'RELEASE_DRY_RUN',
51+
defaultValue: false,
52+
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
53+
)
54+
}
55+
stages {
56+
stage('Release') {
57+
when {
58+
beforeAgent true
59+
// Releases must be triggered explicitly
60+
// This is just for safety; normally the Jenkins job for this pipeline
61+
// should be configured to "Suppress automatic SCM triggering"
62+
// See https://stackoverflow.com/questions/58259326/prevent-jenkins-multibranch-pipeline-from-triggering-builds-for-new-branches
63+
triggeredBy cause: "UserIdCause"
64+
}
65+
steps {
66+
script {
67+
// Check that all the necessary parameters are set
68+
if (!params.RELEASE_VERSION) {
69+
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
70+
}
71+
if (!params.DEVELOPMENT_VERSION) {
72+
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
73+
}
74+
75+
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
76+
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
77+
echo "Performing full release for version ${releaseVersion.toString()}"
78+
79+
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
80+
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
81+
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
82+
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
83+
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
84+
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
85+
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
86+
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
87+
sh 'cat $HOME/.ssh/config'
88+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
89+
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
90+
sh """
91+
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
92+
tools ${releaseVersion.toString()} ${developmentVersion.toString()}
93+
"""
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}
100+
}
101+
}
102+
post {
103+
always {
104+
notifyBuildResult notifySuccessAfterSuccess: true, maintainers: '[email protected]'
105+
}
106+
}
107+
}

jbt/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
~
55
~ Copyright 2022-2023 Red Hat, Inc.
66
~
7-
~ Licensed under the GNU Lesser General Public License (LGPL),
7+
~ Licensed under the GNU Lesser General Public License (LGPL),
88
~ version 2.1 or later (the "License").
99
~ You may not use this file except in compliance with the License.
10-
~ You may read the licence in the 'lgpl.txt' file in the root folder of
10+
~ You may read the licence in the 'lgpl.txt' file in the root folder of
1111
~ project or obtain a copy at
1212
~
1313
~ http://www.gnu.org/licenses/lgpl-2.1.html
@@ -35,6 +35,11 @@
3535
<name>Hibernate Tools ORM - JBoss Tools Adapter</name>
3636
<description>Hibernate Tools ORM - JBoss Tools Adapter</description>
3737

38+
<properties>
39+
<!-- This is a publicly distributed module that should be published: -->
40+
<deploy.skip>false</deploy.skip>
41+
</properties>
42+
3843
<dependencies>
3944
<dependency>
4045
<groupId>com.h2database</groupId>

maven/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
</prerequisites>
6969

7070
<properties>
71-
<maven.deploy.skip>false</maven.deploy.skip>
71+
<!-- This is a publicly distributed module that should be published: -->
72+
<deploy.skip>false</deploy.skip>
7273
<maven.install.skip>false</maven.install.skip>
7374

7475
<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>

orm/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
~
55
~ Copyright 2018-2021 Red Hat, Inc.
66
~
7-
~ Licensed under the GNU Lesser General Public License (LGPL),
7+
~ Licensed under the GNU Lesser General Public License (LGPL),
88
~ version 2.1 or later (the "License").
99
~ You may not use this file except in compliance with the License.
10-
~ You may read the licence in the 'lgpl.txt' file in the root folder of
10+
~ You may read the licence in the 'lgpl.txt' file in the root folder of
1111
~ project or obtain a copy at
1212
~
1313
~ http://www.gnu.org/licenses/lgpl-2.1.html
@@ -35,6 +35,11 @@
3535
<name>Hibernate Tools ORM</name>
3636
<description>Hibernate Tools ORM</description>
3737

38+
<properties>
39+
<!-- This is a publicly distributed module that should be published: -->
40+
<deploy.skip>false</deploy.skip>
41+
</properties>
42+
3843
<dependencies>
3944
<dependency>
4045
<groupId>com.google.googlejavaformat</groupId>

pom.xml

Lines changed: 120 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,25 @@
103103
<sqlserver.version>9.2.1.jre8</sqlserver.version>
104104
<jakarta.xml.bind-api.version>4.0.0</jakarta.xml.bind-api.version>
105105

106+
<!-- Plugins not managed by the JBoss parent POM: -->
106107
<maven-wrapper-plugin.version>3.3.2</maven-wrapper-plugin.version>
108+
<nexus-staging.plugin.version>1.7.0</nexus-staging.plugin.version>
109+
110+
<!--
111+
We don't want to publish or sign any modules by default.
112+
Specific modules will override the setting at their own level.
113+
-->
114+
<deploy.skip>true</deploy.skip>
115+
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
116+
117+
<!-- Repository Deployment URLs -->
118+
<ossrh.releases.repo.id>ossrh-releases-repository</ossrh.releases.repo.id>
119+
<ossrh.releases.repo.name>Sonatype OSSRH Releases</ossrh.releases.repo.name>
120+
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
121+
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
122+
<ossrh.snapshots.repo.id>ossrh-snapshots-repository</ossrh.snapshots.repo.id>
123+
<ossrh.snapshots.repo.name>Sonatype OSSRH Snapshots</ossrh.snapshots.repo.name>
124+
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
107125

108126
<maven.compiler.target>17</maven.compiler.target>
109127
<maven.compiler.source>17</maven.compiler.source>
@@ -237,30 +255,30 @@
237255
<snapshots>
238256
<enabled>false</enabled>
239257
</snapshots>
240-
<id>ossrh-releases-repository</id>
241-
<name>Sonatype OSSRH Releases</name>
242-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
258+
<id>${ossrh.releases.repo.id}</id>
259+
<name>${ossrh.releases.repo.name}</name>
260+
<url>${ossrh.releases.repo.url}/</url>
243261
</repository>
244262
<repository>
245263
<snapshots>
246264
<enabled>true</enabled>
247265
</snapshots>
248-
<id>ossrh-snapshots-repository</id>
249-
<name>Sonatype OSSRH Snapshots</name>
250-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
266+
<id>${ossrh.snapshots.repo.id}</id>
267+
<name>${ossrh.snapshots.repo.name}</name>
268+
<url>${ossrh.snapshots.repo.url}</url>
251269
</repository>
252270
</repositories>
253271

254272
<distributionManagement>
255273
<repository>
256-
<id>ossrh-releases-repository</id>
257-
<name>Sonatype OSSRH Releases</name>
258-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
274+
<id>${ossrh.releases.repo.id}</id>
275+
<name>${ossrh.releases.repo.name}</name>
276+
<url>${ossrh.releases.repo.url}/</url>
259277
</repository>
260278
<snapshotRepository>
261-
<id>ossrh-snapshots-repository</id>
262-
<name>Sonatype OSSRH Snapshots</name>
263-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
279+
<id>${ossrh.snapshots.repo.id}</id>
280+
<name>${ossrh.snapshots.repo.name}</name>
281+
<url>${ossrh.snapshots.repo.url}</url>
264282
</snapshotRepository>
265283
</distributionManagement>
266284

@@ -276,8 +294,98 @@
276294
<distributionType>bin</distributionType>
277295
</configuration>
278296
</plugin>
297+
<!-- Published artifacts have to be signed: -->
298+
<plugin>
299+
<groupId>org.apache.maven.plugins</groupId>
300+
<artifactId>maven-gpg-plugin</artifactId>
301+
<executions>
302+
<execution>
303+
<id>sign-artifacts</id>
304+
<phase>verify</phase>
305+
<goals>
306+
<goal>sign</goal>
307+
</goals>
308+
<configuration>
309+
<skip>${deploy.skip}</skip>
310+
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
311+
</configuration>
312+
</execution>
313+
</executions>
314+
</plugin>
315+
<plugin>
316+
<groupId>org.sonatype.plugins</groupId>
317+
<artifactId>nexus-staging-maven-plugin</artifactId>
318+
<version>${nexus-staging.plugin.version}</version>
319+
<extensions>false</extensions><!-- This is essential: do not put true here -->
320+
<configuration>
321+
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
322+
<serverId>${ossrh.releases.repo.id}</serverId>
323+
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
324+
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
325+
<!-- oss.sonatype.org has been very slow when closing repositories lately;
326+
let's raise the timeout until we switch to s01.sonatype.org -->
327+
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
328+
</configuration>
329+
</plugin>
279330
</plugins>
280331
</pluginManagement>
332+
<plugins>
333+
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
334+
<plugin>
335+
<groupId>org.apache.maven.plugins</groupId>
336+
<artifactId>maven-gpg-plugin</artifactId>
337+
</plugin>
338+
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
339+
<plugin>
340+
<groupId>org.apache.maven.plugins</groupId>
341+
<artifactId>maven-deploy-plugin</artifactId>
342+
<configuration>
343+
<skip>${maven-deploy-plugin.skip}</skip>
344+
</configuration>
345+
</plugin>
346+
<!--
347+
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
348+
in order to work around a problem in the "reports" module (see that module's POM for more info).
349+
-->
350+
<plugin>
351+
<groupId>org.sonatype.plugins</groupId>
352+
<artifactId>nexus-staging-maven-plugin</artifactId>
353+
<executions>
354+
<execution>
355+
<id>default-deploy</id>
356+
<phase>deploy</phase>
357+
<goals>
358+
<!--
359+
This will only put artifacts in a staging directory.
360+
See the "reports" module for actual deployment, at the end of the build.
361+
-->
362+
<goal>deploy</goal>
363+
</goals>
364+
</execution>
365+
</executions>
366+
</plugin>
367+
</plugins>
281368
</build>
282369

370+
<profiles>
371+
<!--
372+
WARNING: this MUST be the very last profile,
373+
so that the "report" module is the very last module,
374+
in particular when deploying artifacts to a Nexus repository.
375+
See the "build/reports" module POM for more information.
376+
-->
377+
<profile>
378+
<id>build-reports-as-last-module</id>
379+
<activation>
380+
<property>
381+
<name>!some.property.that.will.never.exist</name>
382+
</property>
383+
</activation>
384+
<modules>
385+
<module>reports</module>
386+
</modules>
387+
</profile>
388+
389+
<!-- DO NOT ADD ANY PROFILE AFTER THIS: see above -->
390+
</profiles>
283391
</project>

0 commit comments

Comments
 (0)