Skip to content

Commit

Permalink
HBX-2936 Adjust POMs to use gpg/nexus plugins for the release
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Nov 29, 2024
1 parent 347f246 commit b7e408d
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 17 deletions.
5 changes: 5 additions & 0 deletions ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<description>Hibernate Tools Ant Tasks</description>
<packaging>jar</packaging>

<properties>
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
Expand Down
107 changes: 107 additions & 0 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Hibernate Tools, Tooling for your Hibernate Projects
*
* Copyright 2016-2024 Red Hat, Inc.
*
* Licensed under the GNU Lesser General Public License (LGPL),
* version 2.1 or later (the "License").
* You may not use this file except in compliance with the License.
* You may read the licence in the 'lgpl.txt' file in the root folder of
* project or obtain a copy at
*
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Library('hibernate-jenkins-pipeline-helpers') _

import org.hibernate.jenkins.pipeline.helpers.version.Version

pipeline {
agent {
label 'Worker&&Containers'
}
tools {
maven 'Apache Maven 3.9'
jdk 'OpenJDK 21 Latest'
}
options {
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
disableConcurrentBuilds(abortPrevious: false)
}
parameters {
string(
name: 'RELEASE_VERSION',
defaultValue: '',
description: 'The version to be released, e.g. 7.0.0.Final.',
trim: true
)
string(
name: 'DEVELOPMENT_VERSION',
defaultValue: '',
description: 'The next version to be used after the release, e.g. 7.0.1-SNAPSHOT.',
trim: true
)
booleanParam(
name: 'RELEASE_DRY_RUN',
defaultValue: false,
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
)
}
stages {
stage('Release') {
when {
beforeAgent true
// Releases must be triggered explicitly
// This is just for safety; normally the Jenkins job for this pipeline
// should be configured to "Suppress automatic SCM triggering"
// See https://stackoverflow.com/questions/58259326/prevent-jenkins-multibranch-pipeline-from-triggering-builds-for-new-branches
triggeredBy cause: "UserIdCause"
}
steps {
script {
// Check that all the necessary parameters are set
if (!params.RELEASE_VERSION) {
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
}
if (!params.DEVELOPMENT_VERSION) {
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
}

def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
echo "Performing full release for version ${releaseVersion.toString()}"

withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
sh 'cat $HOME/.ssh/config'
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
sh """
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
tools ${releaseVersion.toString()} ${developmentVersion.toString()}
"""
}
}
}
}
}
}
}
}
post {
always {
notifyBuildResult notifySuccessAfterSuccess: true, maintainers: 'koen@hibernate.org'
}
}
}
9 changes: 7 additions & 2 deletions jbt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
~
~ Copyright 2022-2023 Red Hat, Inc.
~
~ Licensed under the GNU Lesser General Public License (LGPL),
~ Licensed under the GNU Lesser General Public License (LGPL),
~ version 2.1 or later (the "License").
~ You may not use this file except in compliance with the License.
~ You may read the licence in the 'lgpl.txt' file in the root folder of
~ You may read the licence in the 'lgpl.txt' file in the root folder of
~ project or obtain a copy at
~
~ http://www.gnu.org/licenses/lgpl-2.1.html
Expand Down Expand Up @@ -35,6 +35,11 @@
<name>Hibernate Tools ORM - JBoss Tools Adapter</name>
<description>Hibernate Tools ORM - JBoss Tools Adapter</description>

<properties>
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
</properties>

<dependencies>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
3 changes: 2 additions & 1 deletion maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
</prerequisites>

<properties>
<maven.deploy.skip>false</maven.deploy.skip>
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
<maven.install.skip>false</maven.install.skip>

<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>
Expand Down
9 changes: 7 additions & 2 deletions orm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
~
~ Copyright 2018-2021 Red Hat, Inc.
~
~ Licensed under the GNU Lesser General Public License (LGPL),
~ Licensed under the GNU Lesser General Public License (LGPL),
~ version 2.1 or later (the "License").
~ You may not use this file except in compliance with the License.
~ You may read the licence in the 'lgpl.txt' file in the root folder of
~ You may read the licence in the 'lgpl.txt' file in the root folder of
~ project or obtain a copy at
~
~ http://www.gnu.org/licenses/lgpl-2.1.html
Expand Down Expand Up @@ -35,6 +35,11 @@
<name>Hibernate Tools ORM</name>
<description>Hibernate Tools ORM</description>

<properties>
<!-- This is a publicly distributed module that should be published: -->
<deploy.skip>false</deploy.skip>
</properties>

<dependencies>
<dependency>
<groupId>com.google.googlejavaformat</groupId>
Expand Down
132 changes: 120 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,25 @@
<sqlserver.version>9.2.1.jre8</sqlserver.version>
<jakarta.xml.bind-api.version>4.0.0</jakarta.xml.bind-api.version>

<!-- Plugins not managed by the JBoss parent POM: -->
<maven-wrapper-plugin.version>3.3.2</maven-wrapper-plugin.version>
<nexus-staging.plugin.version>1.7.0</nexus-staging.plugin.version>

<!--
We don't want to publish or sign any modules by default.
Specific modules will override the setting at their own level.
-->
<deploy.skip>true</deploy.skip>
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>

<!-- Repository Deployment URLs -->
<ossrh.releases.repo.id>ossrh-releases-repository</ossrh.releases.repo.id>
<ossrh.releases.repo.name>Sonatype OSSRH Releases</ossrh.releases.repo.name>
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
<ossrh.snapshots.repo.id>ossrh-snapshots-repository</ossrh.snapshots.repo.id>
<ossrh.snapshots.repo.name>Sonatype OSSRH Snapshots</ossrh.snapshots.repo.name>
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>

<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -237,30 +255,30 @@
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>ossrh-releases-repository</id>
<name>Sonatype OSSRH Releases</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<id>${ossrh.releases.repo.id}</id>
<name>${ossrh.releases.repo.name}</name>
<url>${ossrh.releases.repo.url}/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>ossrh-snapshots-repository</id>
<name>Sonatype OSSRH Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<id>${ossrh.snapshots.repo.id}</id>
<name>${ossrh.snapshots.repo.name}</name>
<url>${ossrh.snapshots.repo.url}</url>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>ossrh-releases-repository</id>
<name>Sonatype OSSRH Releases</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<id>${ossrh.releases.repo.id}</id>
<name>${ossrh.releases.repo.name}</name>
<url>${ossrh.releases.repo.url}/</url>
</repository>
<snapshotRepository>
<id>ossrh-snapshots-repository</id>
<name>Sonatype OSSRH Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<id>${ossrh.snapshots.repo.id}</id>
<name>${ossrh.snapshots.repo.name}</name>
<url>${ossrh.snapshots.repo.url}</url>
</snapshotRepository>
</distributionManagement>

Expand All @@ -276,8 +294,98 @@
<distributionType>bin</distributionType>
</configuration>
</plugin>
<!-- Published artifacts have to be signed: -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<skip>${deploy.skip}</skip>
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging.plugin.version}</version>
<extensions>false</extensions><!-- This is essential: do not put true here -->
<configuration>
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
<serverId>${ossrh.releases.repo.id}</serverId>
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
<!-- oss.sonatype.org has been very slow when closing repositories lately;
let's raise the timeout until we switch to s01.sonatype.org -->
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>${maven-deploy-plugin.skip}</skip>
</configuration>
</plugin>
<!--
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
in order to work around a problem in the "reports" module (see that module's POM for more info).
-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<!--
This will only put artifacts in a staging directory.
See the "reports" module for actual deployment, at the end of the build.
-->
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<!--
WARNING: this MUST be the very last profile,
so that the "report" module is the very last module,
in particular when deploying artifacts to a Nexus repository.
See the "build/reports" module POM for more information.
-->
<profile>
<id>build-reports-as-last-module</id>
<activation>
<property>
<name>!some.property.that.will.never.exist</name>
</property>
</activation>
<modules>
<module>reports</module>
</modules>
</profile>

<!-- DO NOT ADD ANY PROFILE AFTER THIS: see above -->
</profiles>
</project>
Loading

0 comments on commit b7e408d

Please sign in to comment.