Skip to content

Commit 92ac311

Browse files
marko-bekhtadreab8
authored andcommitted
HHH-19341 Backport JReleaser config to 6.6
1 parent b204fa2 commit 92ac311

File tree

6 files changed

+65
-107
lines changed

6 files changed

+65
-107
lines changed

build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ plugins {
2828
id 'org.checkerframework' version '0.6.40'
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,12 +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-
7062
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7163
// CI Build Task
7264

@@ -97,6 +89,3 @@ idea {
9789
name = "hibernate-orm"
9890
}
9991
}
100-
101-
102-

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 & 21 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,26 +38,31 @@ pipeline {
3038
}
3139
stage('Publish') {
3240
steps {
33-
withCredentials([
34-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USER'),
35-
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'PLUGIN_PORTAL_PASSWORD', usernameVariable: 'PLUGIN_PORTAL_USERNAME'),
36-
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
37-
string(credentialsId: 'release.gpg.passphrase', variable: 'RELEASE_GPG_PASSPHRASE'),
38-
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
39-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'ORG_GRADLE_PROJECT_sonatypePassword', usernameVariable: 'ORG_GRADLE_PROJECT_sonatypeUsername'),
40-
// https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
41-
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
42-
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_GPG_PRIVATE_KEY_PATH'),
43-
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_GPG_PASSPHRASE')
44-
]) {
45-
withEnv([
46-
"DISABLE_REMOTE_GRADLE_CACHE=true"
47-
]) {
48-
sh '''./gradlew clean publish -x test \
49-
--no-scan --no-daemon --no-build-cache --stacktrace
50-
'''
51-
}
52-
}
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+
}
5366
}
5467
}
5568
}
@@ -60,4 +73,4 @@ pipeline {
6073
}
6174
}
6275
}
63-
}
76+
}

gradle/published-java-module.gradle

Lines changed: 13 additions & 59 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

@@ -98,84 +96,40 @@ publishing {
9896
}
9997
}
10098
}
101-
}
102-
103-
104-
105-
106-
107-
108-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109-
// Signing
110-
111-
112-
def signingKey = resolveSigningKey()
113-
def signingPassphrase = resolveSigningPassphrase()
114-
115-
var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension
116-
var publishingExtension = project.getExtensions().getByType(PublishingExtension) as PublishingExtension
117-
signingExtension.sign publishingExtension.publications.publishedArtifacts
118-
signingExtension.useInMemoryPgpKeys(signingKey, signingPassphrase)
119-
120-
gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
121-
boolean wasPublishingRequested = false
122-
123-
graph.allTasks.each {task ->
124-
if ( task instanceof PublishToMavenRepository ) {
125-
wasPublishingRequested = true
99+
repositories {
100+
maven {
101+
name = "staging"
102+
url = rootProject.layout.buildDirectory.dir("staging-deploy${File.separator}maven")
126103
}
127-
}
128-
129-
if ( wasPublishingRequested ) {
130-
def ossrhUser = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" )
131-
def ossrhPass = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" )
132-
if ( ossrhUser == null || ossrhPass == null ) {
133-
throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." )
104+
maven {
105+
name = 'snapshots'
106+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
107+
// So that Gradle uses the `ORG_GRADLE_PROJECT_snapshotsPassword` / `ORG_GRADLE_PROJECT_snapshotsUsername`
108+
// env variables to read the username/password for the `snapshots` repository publishing:
109+
credentials(PasswordCredentials)
134110
}
135-
logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version
136-
signingExtension.required = true
137-
}
138-
else if ( signingKey == null || signingPassphrase == null ) {
139-
tasks.withType( Sign ).each { t-> t.enabled = false }
140111
}
141112
}
142113

143-
static String resolveSigningKey() {
144-
var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" )
145-
if ( key != null ) {
146-
return key
147-
}
148114

149-
var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" )
150-
if ( keyFile != null ) {
151-
return new File( keyFile ).text
152-
}
153115

154-
return null
155-
}
156116

157-
static String resolveSigningPassphrase() {
158-
return System.getenv().get( "SIGNING_GPG_PASSPHRASE" )
159-
}
160117

161118

162119
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163120
// Release / publishing tasks
164121

165122
task ciBuild {
166-
dependsOn test, tasks.publishToSonatype
123+
dependsOn test
167124
}
168125

169-
tasks.release.dependsOn tasks.test, tasks.publishToSonatype
126+
tasks.release.dependsOn tasks.test
170127

171128
tasks.preVerifyRelease.dependsOn build
172129
tasks.preVerifyRelease.dependsOn generateMetadataFileForPublishedArtifactsPublication
173130
tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication
174131
tasks.preVerifyRelease.dependsOn generatePomFileForRelocationPomPublication
175132

176-
tasks.publishToSonatype.mustRunAfter test
177-
178-
179133
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
180134
// Ancillary tasks
181135

@@ -188,4 +142,4 @@ task showPublications {
188142
}
189143
}
190144
}
191-
}
145+
}

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
@@ -164,9 +164,9 @@ gradle.taskGraph.whenReady { tg ->
164164
if ( t.repository == null ) {
165165
logger.info( "Task `{}` had null repository", t.path )
166166
}
167-
else if ( t.repository.name == "sonatype" ) {
168-
logger.debug( "Disabling task `{}` because it publishes to Sonatype", t.path )
167+
else if ( t.repository.name == "staging" || t.repository.name == "snapshots" ) {
168+
logger.debug( "Disabling task `{}` because it publishes to remote Maven repository", t.path )
169169
t.enabled = false
170170
}
171171
}
172-
}
172+
}

0 commit comments

Comments
 (0)