Skip to content

Commit 7813a71

Browse files
marko-bekhtayrodiere
authored andcommitted
HHH-19341 Backport JReleaser config to 6.4
1 parent 7711bd5 commit 7813a71

File tree

7 files changed

+67
-109
lines changed

7 files changed

+67
-109
lines changed

build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ plugins {
2828
id 'org.checkerframework' version '0.6.34'
2929
id 'org.hibernate.orm.build.jdks'
3030

31-
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
32-
3331
id 'idea'
3432
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0'
3533
id 'eclipse'
@@ -61,13 +59,6 @@ tasks.register('publish') {
6159
"themselves if they have any publish-related activities to perform"
6260
}
6361

64-
nexusPublishing {
65-
repositories {
66-
sonatype()
67-
}
68-
}
69-
70-
7162
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7263
// CI Build Task
7364

@@ -98,6 +89,3 @@ idea {
9889
name = "hibernate-orm"
9990
}
10091
}
101-
102-
103-

ci/release/Jenkinsfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ pipeline {
170170
env.RELEASE_VERSION = releaseVersion.toString()
171171
env.DEVELOPMENT_VERSION = developmentVersion.toString()
172172
env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : ""
173+
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
173174

174175
// Determine version id to check if Jira version exists
175176
sh ".release/scripts/determine-jira-version-id.sh ${env.JIRA_KEY} ${releaseVersion.withoutFinalQualifier}"
@@ -191,12 +192,11 @@ pipeline {
191192
// tags the version
192193
// changes the version to the provided development version
193194
withEnv([
194-
"BRANCH=${env.GIT_BRANCH}",
195195
"DISABLE_REMOTE_GRADLE_CACHE=true",
196196
// Increase the amount of memory for this part since asciidoctor doc rendering consumes a lot of metaspace
197197
"GRADLE_OPTS=-Dorg.gradle.jvmargs='-Dlog4j2.disableJmx -Xmx4g -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8'"
198198
]) {
199-
sh ".release/scripts/prepare-release.sh ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
199+
sh ".release/scripts/prepare-release.sh -j -b ${env.GIT_BRANCH} -v ${env.DEVELOPMENT_VERSION} ${env.PROJECT} ${env.RELEASE_VERSION}"
200200
}
201201
}
202202
}
@@ -214,20 +214,28 @@ pipeline {
214214
]) {
215215
withCredentials([
216216
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
217-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'ORG_GRADLE_PROJECT_sonatypePassword', usernameVariable: 'ORG_GRADLE_PROJECT_sonatypeUsername'),
217+
// TODO: HHH-19309:
218+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
219+
// to use the following env variable names to set the user/password:
220+
// - JRELEASER_MAVENCENTRAL_USERNAME
221+
// - JRELEASER_MAVENCENTRAL_TOKEN
222+
// Also use the new `credentialsId` for Maven Central, e.g.:
223+
// usernamePassword(credentialsId: '???????', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
224+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
218225
// https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
219226
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
220-
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_GPG_PRIVATE_KEY_PATH'),
221-
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_GPG_PASSPHRASE'),
222-
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default')
227+
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default'),
228+
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
229+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
230+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')
223231
]) {
224232
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
225233
// performs documentation upload and Sonatype release
226234
// push to github
227235
withEnv([
228236
"DISABLE_REMOTE_GRADLE_CACHE=true"
229237
]) {
230-
sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
238+
sh ".release/scripts/publish.sh -j ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
231239
}
232240
}
233241
}

ci/snapshot-publish.Jenkinsfile

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
1010
return
1111
}
1212

13+
def checkoutReleaseScripts() {
14+
dir('.release/scripts') {
15+
checkout scmGit(branches: [[name: '*/main']], extensions: [],
16+
userRemoteConfigs: [[credentialsId: 'ed25519.Hibernate-CI.github.com',
17+
url: 'https://github.com/hibernate/hibernate-release-scripts.git']])
18+
}
19+
}
20+
1321
pipeline {
1422
agent {
1523
label 'Release'
@@ -30,21 +38,31 @@ pipeline {
3038
}
3139
stage('Publish') {
3240
steps {
33-
withCredentials([
34-
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
35-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'ORG_GRADLE_PROJECT_sonatypePassword', usernameVariable: 'ORG_GRADLE_PROJECT_sonatypeUsername'),
36-
// https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
37-
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
38-
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_GPG_PRIVATE_KEY_PATH'),
39-
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_GPG_PASSPHRASE')
40-
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default')
41-
]) {
42-
withEnv([
43-
"DISABLE_REMOTE_GRADLE_CACHE=true"
44-
]) {
45-
sh './gradlew clean publish -x test --no-scan --no-daemon --no-build-cache --stacktrace'
46-
}
47-
}
41+
script {
42+
withCredentials([
43+
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
44+
// TODO: HHH-19309:
45+
// Once we switch to maven-central publishing (from nexus2) we need to update credentialsId:
46+
// https://docs.gradle.org/current/samples/sample_publishing_credentials.html#:~:text=via%20environment%20variables
47+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'ORG_GRADLE_PROJECT_snapshotsPassword', usernameVariable: 'ORG_GRADLE_PROJECT_snapshotsUsername'),
48+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN'),
49+
// https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
50+
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
51+
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default')
52+
]) {
53+
withEnv([
54+
"DISABLE_REMOTE_GRADLE_CACHE=true"
55+
]) {
56+
checkoutReleaseScripts()
57+
def version = sh(
58+
script: ".release/scripts/determine-current-version.sh orm",
59+
returnStdout: true
60+
).trim()
61+
echo "Current version: '${version}'"
62+
sh "bash -xe .release/scripts/snapshot-deploy.sh orm ${version}"
63+
}
64+
}
65+
}
4866
}
4967
}
5068
}
@@ -55,4 +73,4 @@ pipeline {
5573
}
5674
}
5775
}
58-
}
76+
}

gradle/published-java-module.gradle

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ apply from: rootProject.file( 'gradle/releasable.gradle' )
99
apply from: rootProject.file( 'gradle/java-module.gradle' )
1010
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
1111

12-
apply plugin: 'signing'
13-
1412
// Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
1513
tasks.getByPath( ':release:publishReleaseArtifacts' ).dependsOn tasks.release
1614

@@ -122,81 +120,20 @@ tasks.withType(PublishToMavenRepository).configureEach {
122120
}
123121
}
124122

125-
126-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127-
// Signing
128-
129-
def signingKey = resolveSigningKey()
130-
def signingPassphrase = resolveSigningPassphrase()
131-
132-
var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension
133-
signingExtension.sign publishing.publications.publishedArtifacts
134-
signingExtension.useInMemoryPgpKeys(signingKey, signingPassphrase)
135-
136-
137-
gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
138-
// are we publishing to OSSRH?
139-
boolean wasPublishingRequested = false
140-
141-
graph.allTasks.each {task ->
142-
if ( task instanceof PublishToMavenRepository ) {
143-
if ( "sonatype" == task.repository.name ) {
144-
wasPublishingRequested = true
145-
}
146-
}
147-
}
148-
149-
if ( wasPublishingRequested ) {
150-
def ossrhUser = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" )
151-
def ossrhPass = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" )
152-
if ( ossrhUser == null || ossrhPass == null ) {
153-
throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." )
154-
}
155-
logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version
156-
signingExtension.required = true
157-
}
158-
else if ( signingKey == null || signingPassphrase == null ) {
159-
tasks.withType( Sign ).each { t-> t.enabled = false }
160-
}
161-
}
162-
163-
static String resolveSigningKey() {
164-
var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" )
165-
if ( key != null ) {
166-
return key
167-
}
168-
169-
var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" )
170-
if ( keyFile != null ) {
171-
return new File( keyFile ).text
172-
}
173-
174-
return null
175-
}
176-
177-
static String resolveSigningPassphrase() {
178-
return System.getenv().get( "SIGNING_GPG_PASSPHRASE" )
179-
}
180-
181-
182123
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183124
// Release / publishing tasks
184125

185126
tasks.register('ciBuild') {
186-
dependsOn test, tasks.publishToSonatype
127+
dependsOn test
187128
}
188129

189-
tasks.release.dependsOn tasks.test, tasks.publishToSonatype
130+
tasks.release.dependsOn tasks.test
190131

191132
tasks.preVerifyRelease.dependsOn build
192133
tasks.preVerifyRelease.dependsOn generateMetadataFileForPublishedArtifactsPublication
193134
tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication
194135
tasks.preVerifyRelease.dependsOn generatePomFileForRelocationPomPublication
195136

196-
tasks.publishToSonatype.mustRunAfter test
197-
198-
199-
200137
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201138
// Ancillary tasks
202139

gradle/publishing-pom.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,18 @@ publishing {
5959

6060
}
6161
}
62+
repositories {
63+
maven {
64+
name = "staging"
65+
url = rootProject.layout.buildDirectory.dir("staging-deploy${File.separator}maven")
66+
}
67+
maven {
68+
name = 'snapshots'
69+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
70+
// So that Gradle uses the `ORG_GRADLE_PROJECT_snapshotsPassword` / `ORG_GRADLE_PROJECT_snapshotsUsername`
71+
// env variables to read the username/password for the `snapshots` repository publishing:
72+
credentials(PasswordCredentials)
73+
}
74+
}
6275

6376
}

hibernate-platform/hibernate-platform.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,3 @@ publishing {
7575
}
7676
}
7777
}
78-
79-
project( ":release" ).getTasks().named( "publishReleaseArtifacts" ).configure {
80-
dependsOn tasks.release
81-
}
82-
83-
tasks.release.dependsOn tasks.publishToSonatype

tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ gradle.taskGraph.whenReady { tg ->
167167
if ( t.repository == null ) {
168168
logger.info( "Task `{}` had null repository", t.path )
169169
}
170-
else if ( t.repository.name == "sonatype" ) {
171-
logger.debug( "Disabling task `{}` because it publishes to Sonatype", t.path )
170+
else if ( t.repository.name == "staging" || t.repository.name == "snapshots" ) {
171+
logger.debug( "Disabling task `{}` because it publishes to remote Maven repository", t.path )
172172
t.enabled = false
173173
}
174174
}
175-
}
175+
}

0 commit comments

Comments
 (0)