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
1 change: 1 addition & 0 deletions distribution/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
<!-- 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
58 changes: 58 additions & 0 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we want to keep logging into the Nexus repository web UI to click the "release" button?

Fine by me, but I wonder: is there an equivalent for the Maven Central publishing API? If not, we'll probably want to make sure we don't rely on this manual step...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea here was not to release the repository while testing the migration, as for the future ... we can flip the flag for maintenance branches, as for the main one... idk... if we aren't adding new artifacts then it's probably fine to release the repo automatically, but if we are .. it'll probably be safer to go check the staged bundle before releasing, no?

as for the new APIs, I think they have some alternative to this:

The MavenCentral Maven deployer allows executing deployments in stages that is, you may set the stage property to UPLOAD, PUBLISH, and/or FULL

https://jreleaser.org/guide/latest/reference/deploy/maven/maven-central.html#_staged_deployments

but ... you know, I haven't tested this yet 😄
and while I was writing the comment, I thought I can (probably) try it on a local nexus, unless it's a Pro feature ...

stagingRepositories:
- target/staging-deploy/maven
maven-central-snapshot:
active: SNAPSHOT
url: https://oss.sonatype.org/service/local
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
closeRepository: true
releaseRepository: true
javadocJar: false
sign: 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
maven-central-snapshot:
# TODO: HSEARCH-5354 Change to SNAPSHOT once switching to Maven-Central:
active: NEVER
url: https://central.sonatype.com/api/v1/publisher
snapshotSupported: true
applyMavenCentralRules: true
javadocJar: false
sign: false
stagingRepositories:
- target/staging-deploy/maven
106 changes: 5 additions & 101 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,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 @@ -316,20 +314,13 @@
<version.spotless-maven-plugin>2.44.4</version.spotless-maven-plugin>
<version.maven-antrun-plugin>3.1.0</version.maven-antrun-plugin>

<!-- 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>
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>

<!--
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>
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
<altDeploymentRepository>local::file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</altDeploymentRepository>

<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
Expand Down Expand Up @@ -555,39 +546,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 +1105,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 @@ -1249,19 +1176,6 @@
</plugins>
</build>

<distributionManagement>
<repository>
<id>${ossrh.releases.repo.id}</id>
<name>OSSRH Releases Repository</name>
<url>${ossrh.releases.repo.url}</url>
</repository>
<snapshotRepository>
<id>${ossrh.snapshots.repo.id}</id>
<name>OSSRH Snapshots Repository</name>
<url>${ossrh.snapshots.repo.url}</url>
</snapshotRepository>
</distributionManagement>

<reporting>
<plugins>
<plugin>
Expand Down Expand Up @@ -1347,14 +1261,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 +1706,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