Skip to content

HSEARCH-5351 Switch to JReleaser for nexus publishing #4564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The folder into which we checkout our release scripts into
*
!.gitignore
32 changes: 0 additions & 32 deletions build/reports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,38 +214,6 @@
</dependency>
</dependencies>
</plugin>
<!--
Hack to deploy in the "reports" module without deploying the "reports" module itself.
The default lifecycle bindings of the plugin is to "stage locally" every artifact throughout
the maven execution, and only actually deploy the "locally staged" artifacts
in the very last executed module, which happens to be this "reports" module.
However, this "reports" module does not generate any artifact we want to deploy.
Thus, we'd like to prevent even its POM from being deployed: just deploy the "locally staged" artifacts,
without adding the POM from the "reports" module to these artifacts.
The default lifecycle bindings of the plugin does not offer a configuration option to do that,
so we have to explicitly bind it
-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>false</extensions>
<!-- The <configuration> element is inherited from the parent module. -->
<executions>
<!-- Skip the default deployment, as explained above we don't want it. -->
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
<!-- ... but execute the deferred deployment for the other modules -->
<execution>
<id>deferred-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy-staged</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
16 changes: 12 additions & 4 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ pipeline {
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')]) {
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
// TODO: HSEARCH-5354
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
// to use the following env variable names to set the user/password:
// JRELEASER_MAVENCENTRAL_USERNAME
// JRELEASER_MAVENCENTRAL_TOKEN
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
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'
dir('.release/scripts') {
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
}
sh """
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
bash -xe .release/scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
search ${releaseVersion.toString()} ${developmentVersion.toString()}
"""
}
Expand Down
25 changes: 18 additions & 7 deletions ci/snapshot-publish/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,24 @@ pipeline {
stage('Publish') {
steps {
script {
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven',
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
sh """mvn \
-Pci-build \
-DskipTests \
clean deploy \
"""
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven', mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
withCredentials([// TODO: HSEARCH-5354
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
// to use the following env variable names to set the user/password:
// JRELEASER_MAVENCENTRAL_USERNAME
// JRELEASER_MAVENCENTRAL_TOKEN
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
dir('.release/scripts') {
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git .'
}
def version = sh(
script: ".release/scripts/determine-current-version.sh search",
returnStdout: true
).trim()
echo "Current version: '${version}'"
sh "bash -xe .release/scripts/snapshot-deploy.sh search ${version}"
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions distribution/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@
<exclude>LICENSE.txt</exclude>

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

<!-- actual files which should be ignored -->
<exclude>.git</exclude>
Expand Down
38 changes: 38 additions & 0 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
project:
languages:
java:
groupId: org.hibernate.search

release:
github:
skipTag: true
skipRelease: true
tagName: '{{projectVersion}}'

# File signing is always active
signing:
mode: COMMAND
active: RELEASE
armored: true

# Deploy JARs and POMs to Maven Central
deploy:
maven:
nexus2:
maven-central:
active: RELEASE
url: https://oss.sonatype.org/service/local
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
closeRepository: true
releaseRepository: false
stagingRepositories:
- target/staging-deploy/maven
mavenCentral:
maven-central:
# TODO: HSEARCH-5354 Change to RELEASE once switching to Maven-Central:
active: NEVER
url: https://central.sonatype.com/api/v1/publisher
snapshotSupported: false
applyMavenCentralRules: true
stagingRepositories:
- target/staging-deploy/maven
163 changes: 43 additions & 120 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,40 +156,6 @@
</mailingList>
</mailingLists>

<modules>
<module>bom/public</module>
<module>build/parents/relocation</module>
<module>build/parents/build</module>
<module>build/enforcer</module>
<module>build/config</module>
<module>build/parents/internal</module>
<module>util/internal/test/common</module>
<module>util/internal/test/orm</module>
<module>build/parents/public</module>
<module>util/common</module>
<module>engine</module>
<module>backend/lucene</module>
<module>backend/elasticsearch</module>
<module>backend/elasticsearch-aws</module>
<module>mapper/pojo-base</module>
<module>mapper/pojo-standalone</module>
<module>mapper/orm</module>
<module>mapper/orm-outbox-polling</module>
<module>mapper/orm-coordination-outbox-polling</module>
<module>mapper/orm-batch-jsr352/core</module>
<module>mapper/orm-batch-jsr352/jberet</module>
<module>mapper/orm-jakarta-batch/core</module>
<module>mapper/orm-jakarta-batch/jberet</module>
<module>v5migrationhelper/engine</module>
<module>v5migrationhelper/orm</module>
<module>util/internal/integrationtest</module>
<module>build/parents/integrationtest</module>
<module>build/parents/springtest</module>
<module>integrationtest</module>
<module>documentation</module>
<module>lucene-next</module>
</modules>

<properties>
<!--
Version to be used as baseline for API/SPI change reports,
Expand Down Expand Up @@ -270,9 +236,7 @@
<version.enforcer.plugin>3.5.0</version.enforcer.plugin>
<version.project-info.plugin>3.9.0</version.project-info.plugin>
<version.japicmp.plugin>0.23.1</version.japicmp.plugin>
<version.nexus-staging.plugin>1.7.0</version.nexus-staging.plugin>
<version.deploy.plugin>3.1.4</version.deploy.plugin>
<version.gpg.plugin>3.2.7</version.gpg.plugin>
<version.flatten-maven-plugin>1.7.0</version.flatten-maven-plugin>
<version.assembly.plugin>3.7.1</version.assembly.plugin>
<version.buildhelper.plugin>3.6.0</version.buildhelper.plugin>
Expand Down Expand Up @@ -318,9 +282,9 @@

<!-- Repository Deployment URLs -->

<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
<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>
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
<local.staging.releases.repo.id>staging-deploy</local.staging.releases.repo.id>
<local.staging.releases.repo.url>file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</local.staging.releases.repo.url>
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>

Expand All @@ -329,7 +293,6 @@
Specific modules will override the setting at their own level.
-->
<deploy.skip>true</deploy.skip>
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>

<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
Expand Down Expand Up @@ -496,6 +459,40 @@
</sonar.cpd.exclusions>
</properties>

<modules>
<module>bom/public</module>
<module>build/parents/relocation</module>
<module>build/parents/build</module>
<module>build/enforcer</module>
<module>build/config</module>
<module>build/parents/internal</module>
<module>util/internal/test/common</module>
<module>util/internal/test/orm</module>
<module>build/parents/public</module>
<module>util/common</module>
<module>engine</module>
<module>backend/lucene</module>
<module>backend/elasticsearch</module>
<module>backend/elasticsearch-aws</module>
<module>mapper/pojo-base</module>
<module>mapper/pojo-standalone</module>
<module>mapper/orm</module>
<module>mapper/orm-outbox-polling</module>
<module>mapper/orm-coordination-outbox-polling</module>
<module>mapper/orm-batch-jsr352/core</module>
<module>mapper/orm-batch-jsr352/jberet</module>
<module>mapper/orm-jakarta-batch/core</module>
<module>mapper/orm-jakarta-batch/jberet</module>
<module>v5migrationhelper/engine</module>
<module>v5migrationhelper/orm</module>
<module>util/internal/integrationtest</module>
<module>build/parents/integrationtest</module>
<module>build/parents/springtest</module>
<module>integrationtest</module>
<module>documentation</module>
<module>lucene-next</module>
</modules>

<build>
<defaultGoal>install</defaultGoal>
<pluginManagement>
Expand Down Expand Up @@ -555,39 +552,13 @@
</executions>
</plugin>
<!-- We want to deploy the public BOM, so we manage this plugin in the root pom. -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${version.nexus-staging.plugin}</version>
<configuration>
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
</configuration>
</plugin>
<!-- We want to disable this plugin as soon as possible, hence we manage it in the root pom. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${version.deploy.plugin}</version>
</plugin>
<!-- Public BOM must be also signed, so we manage this plugin in the root pom. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${version.gpg.plugin}</version>
<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>
<bestPractices>true</bestPractices>
</configuration>
</execution>
</executions>
<configuration>
<skip>${deploy.skip}</skip>
</configuration>
</plugin>
<!-- Public BOM will be flattened too, so we manage this plugin in the root pom. -->
<plugin>
Expand Down Expand Up @@ -1140,44 +1111,6 @@
</plugins>
</pluginManagement>
<plugins>
<!-- 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>
<extensions>false</extensions><!-- This is essential: do not put true here -->
<configuration>
<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>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -1251,9 +1184,9 @@

<distributionManagement>
<repository>
<id>${ossrh.releases.repo.id}</id>
<name>OSSRH Releases Repository</name>
<url>${ossrh.releases.repo.url}</url>
<id>${local.staging.releases.repo.id}</id>
<name>Local Staging Directory Releases Repository</name>
<url>${local.staging.releases.repo.url}</url>
</repository>
<snapshotRepository>
<id>${ossrh.snapshots.repo.id}</id>
Expand Down Expand Up @@ -1347,14 +1280,6 @@
<!-- We want this execution to happen before moditect (which executes at package phase) -->
<javadoc.generate.jar.phase>prepare-package</javadoc.generate.jar.phase>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>

<profile>
Expand Down Expand Up @@ -1800,10 +1725,8 @@
-->
<id>reproducibility-check</id>
<properties>
<maven-deploy-plugin.skip>false</maven-deploy-plugin.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<skipTests>true</skipTests>
<gpg.skip>true</gpg.skip>
</properties>
</profile>

Expand Down