Skip to content

Commit 1fdd9f4

Browse files
committed
Add a release Jenkinsfile and JReleaser script updates
1 parent 00f25e7 commit 1fdd9f4

File tree

7 files changed

+112
-162
lines changed

7 files changed

+112
-162
lines changed

build.gradle

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
plugins {
2-
id "io.github.gradle-nexus.publish-plugin"
32
id "release-process"
43
id 'com.diffplug.spotless' version '6.25.0' apply false
54

65
id "com.dorongold.task-tree" version "4.0.0"
76
}
8-
9-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10-
// OSSRH publishing
11-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-
13-
String hibernatePublishUsername = project.hasProperty( 'hibernatePublishUsername' )
14-
? project.property( 'hibernatePublishUsername' )
15-
: null
16-
String hibernatePublishPassword = project.hasProperty( 'hibernatePublishPassword' )
17-
? project.property( 'hibernatePublishPassword' )
18-
: null
19-
20-
nexusPublishing {
21-
repositories {
22-
sonatype {
23-
username = hibernatePublishUsername
24-
password = hibernatePublishPassword
25-
}
26-
}
27-
}

buildSrc/src/main/groovy/published-java-module.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55

66
id "maven-publish"
77
id "publishing-config"
8-
id "signing-config"
98
}
109

1110
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -35,4 +34,4 @@ tasks.named( "javadoc", Javadoc ) {
3534
"implNote:a:Implementation Note:"
3635
)
3736
}
38-
}
37+
}

buildSrc/src/main/groovy/release-process.gradle

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
// - prepareForRelease (this script)
1212
// - publishToSonatype (io.github.gradle-nexus.publish-plugin)
1313
// - closeSonatypeStagingRepository (io.github.gradle-nexus.publish-plugin)
14-
// - completeRelease (this script)
14+
// - releasePerform (this script)
1515
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616

1717
def releaseVersion = project.ext.releaseVersion as String
@@ -30,7 +30,7 @@ def gitBranch = determineGitBranch( project )
3030
// Processes should execute `prepareForRelease`
3131
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3232

33-
def releasePreparationTask = tasks.register( "releasePreparation" ) {
33+
def releasePreparationTask = tasks.register( "releasePrepare" ) {
3434
doFirst {
3535
logger.lifecycle "Release version : {}", releaseVersion
3636
logger.lifecycle "Development version : {}", developmentVersion
@@ -98,13 +98,12 @@ tasks.register( "prepareForRelease" ) {
9898
// - commit the version change
9999
//
100100
//
101-
// Processes should execute `completeRelease`
101+
// Processes should execute `releasePerform`
102102
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103103

104104
def tagReleaseTask = tasks.register( "tagRelease" ) {
105105
onlyIf {
106-
changeToReleaseVersionTask.get().didWork
107-
&& releaseVersion != developmentVersion
106+
releaseVersion != developmentVersion
108107
}
109108

110109
doLast {
@@ -120,8 +119,7 @@ def changeToDevelopmentVersionTask = tasks.register( 'changeToDevelopmentVersion
120119
dependsOn tagReleaseTask
121120

122121
onlyIf {
123-
changeToReleaseVersionTask.get().didWork
124-
&& releaseVersion != developmentVersion
122+
releaseVersion != developmentVersion
125123
}
126124

127125
doFirst {
@@ -140,8 +138,7 @@ def pushToGitTask = tasks.register( 'pushToGit' ) {
140138
dependsOn changeToDevelopmentVersionTask
141139

142140
onlyIf {
143-
changeToReleaseVersionTask.get().didWork
144-
&& releaseVersion != developmentVersion
141+
releaseVersion != developmentVersion
145142
}
146143

147144
doLast {
@@ -154,7 +151,7 @@ def pushToGitTask = tasks.register( 'pushToGit' ) {
154151
}
155152
}
156153

157-
tasks.register( "completeRelease" ) {
154+
tasks.register( "releasePerform" ) {
158155
dependsOn tagReleaseTask
159156
dependsOn changeToDevelopmentVersionTask
160157
dependsOn pushToGitTask
@@ -224,4 +221,4 @@ static String inputStreamToString(InputStream inputStream) {
224221
}
225222
}
226223
}
227-
}
224+
}

buildSrc/src/main/groovy/signing-config.gradle

Lines changed: 0 additions & 127 deletions
This file was deleted.

ci/release/Jenkinsfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
@Library('hibernate-jenkins-pipeline-helpers') _
2+
3+
import org.hibernate.jenkins.pipeline.helpers.version.Version
4+
5+
pipeline {
6+
agent {
7+
label 'Release'
8+
}
9+
tools {
10+
jdk 'OpenJDK 21 Latest'
11+
}
12+
options {
13+
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
14+
disableConcurrentBuilds(abortPrevious: false)
15+
}
16+
parameters {
17+
string(
18+
name: 'RELEASE_VERSION',
19+
defaultValue: '',
20+
description: 'The version to be released, e.g. 1.1.0.',
21+
trim: true
22+
)
23+
string(
24+
name: 'DEVELOPMENT_VERSION',
25+
defaultValue: '',
26+
description: 'The next version to be used after the release, e.g. 1.2.0-SNAPSHOT.',
27+
trim: true
28+
)
29+
booleanParam(
30+
name: 'RELEASE_DRY_RUN',
31+
defaultValue: false,
32+
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
33+
)
34+
}
35+
stages {
36+
stage('Release') {
37+
steps {
38+
script {
39+
// Check that all the necessary parameters are set
40+
if (!params.RELEASE_VERSION) {
41+
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
42+
}
43+
if (!params.DEVELOPMENT_VERSION) {
44+
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
45+
}
46+
47+
def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
48+
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
49+
echo "Performing full release for version ${releaseVersion.toString()}"
50+
51+
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
52+
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
53+
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
54+
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
55+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
56+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
57+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
58+
59+
sshagent(['ed25519.Hibernate-CI.github.com']) {
60+
sh 'cat $HOME/.ssh/config'
61+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
62+
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
63+
sh """
64+
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
65+
models ${releaseVersion.toString()} ${developmentVersion.toString()}
66+
"""
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}

jreleaser.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
project:
2+
languages:
3+
java:
4+
groupId: org.hibernate.models
5+
6+
release:
7+
github:
8+
skipTag: true
9+
skipRelease: true
10+
tagName: '{{projectVersion}}'
11+
12+
# File signing is always active
13+
signing:
14+
mode: COMMAND
15+
active: ALWAYS
16+
armored: true
17+
18+
# Deploy JARs and POMs to Maven Central
19+
deploy:
20+
maven:
21+
nexus2:
22+
maven-central:
23+
active: ALWAYS
24+
url: https://oss.sonatype.org/service/local
25+
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
26+
closeRepository: true
27+
releaseRepository: true
28+
stagingRepositories:
29+
- build/staging-deploy/maven

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pluginManagement {
22
plugins {
33
id "org.checkerframework" version "0.6.34" apply false
4-
id "io.github.gradle-nexus.publish-plugin" version "2.0.0" apply false
54
}
65
repositories {
76
gradlePluginPortal()

0 commit comments

Comments
 (0)