Skip to content

Add a release Jenkinsfile and JReleaser script updates #115

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

Merged
merged 1 commit into from
Apr 8, 2025
Merged
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
21 changes: 0 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
plugins {
id "io.github.gradle-nexus.publish-plugin"
id "release-process"
id 'com.diffplug.spotless' version '6.25.0' apply false

id "com.dorongold.task-tree" version "4.0.0"
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// OSSRH publishing
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

String hibernatePublishUsername = project.hasProperty( 'hibernatePublishUsername' )
? project.property( 'hibernatePublishUsername' )
: null
String hibernatePublishPassword = project.hasProperty( 'hibernatePublishPassword' )
? project.property( 'hibernatePublishPassword' )
: null

nexusPublishing {
repositories {
sonatype {
username = hibernatePublishUsername
password = hibernatePublishPassword
}
}
}
3 changes: 1 addition & 2 deletions buildSrc/src/main/groovy/published-java-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {

id "maven-publish"
id "publishing-config"
id "signing-config"
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -35,4 +34,4 @@ tasks.named( "javadoc", Javadoc ) {
"implNote:a:Implementation Note:"
)
}
}
}
19 changes: 8 additions & 11 deletions buildSrc/src/main/groovy/release-process.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
// - prepareForRelease (this script)
// - publishToSonatype (io.github.gradle-nexus.publish-plugin)
// - closeSonatypeStagingRepository (io.github.gradle-nexus.publish-plugin)
// - completeRelease (this script)
// - releasePerform (this script)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

def releasePreparationTask = tasks.register( "releasePreparation" ) {
def releasePreparationTask = tasks.register( "releasePrepare" ) {
doFirst {
logger.lifecycle "Release version : {}", releaseVersion
logger.lifecycle "Development version : {}", developmentVersion
Expand Down Expand Up @@ -98,13 +98,12 @@ tasks.register( "prepareForRelease" ) {
// - commit the version change
//
//
// Processes should execute `completeRelease`
// Processes should execute `releasePerform`
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def tagReleaseTask = tasks.register( "tagRelease" ) {
onlyIf {
changeToReleaseVersionTask.get().didWork
&& releaseVersion != developmentVersion
releaseVersion != developmentVersion
}

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

onlyIf {
changeToReleaseVersionTask.get().didWork
&& releaseVersion != developmentVersion
releaseVersion != developmentVersion
}

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

onlyIf {
changeToReleaseVersionTask.get().didWork
&& releaseVersion != developmentVersion
releaseVersion != developmentVersion
}

doLast {
Expand All @@ -154,7 +151,7 @@ def pushToGitTask = tasks.register( 'pushToGit' ) {
}
}

tasks.register( "completeRelease" ) {
tasks.register( "releasePerform" ) {
dependsOn tagReleaseTask
dependsOn changeToDevelopmentVersionTask
dependsOn pushToGitTask
Expand Down Expand Up @@ -224,4 +221,4 @@ static String inputStreamToString(InputStream inputStream) {
}
}
}
}
}
127 changes: 0 additions & 127 deletions buildSrc/src/main/groovy/signing-config.gradle

This file was deleted.

74 changes: 74 additions & 0 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@Library('hibernate-jenkins-pipeline-helpers') _

import org.hibernate.jenkins.pipeline.helpers.version.Version

pipeline {
agent {
label 'Release'
}
tools {
jdk 'OpenJDK 21 Latest'
}
options {
buildDiscarder logRotator(daysToKeepStr: '30', numToKeepStr: '10')
disableConcurrentBuilds(abortPrevious: false)
}
parameters {
string(
name: 'RELEASE_VERSION',
defaultValue: '',
description: 'The version to be released, e.g. 1.1.0.',
trim: true
)
string(
name: 'DEVELOPMENT_VERSION',
defaultValue: '',
description: 'The next version to be used after the release, e.g. 1.2.0-SNAPSHOT.',
trim: true
)
booleanParam(
name: 'RELEASE_DRY_RUN',
defaultValue: false,
description: 'If true, just simulate the release, without pushing any commits or tags, and without uploading any artifacts or documentation.'
)
}
stages {
stage('Release') {
steps {
script {
// Check that all the necessary parameters are set
if (!params.RELEASE_VERSION) {
throw new IllegalArgumentException("Missing value for parameter RELEASE_VERSION.")
}
if (!params.DEVELOPMENT_VERSION) {
throw new IllegalArgumentException("Missing value for parameter DEVELOPMENT_VERSION.")
}

def releaseVersion = Version.parseReleaseVersion(params.RELEASE_VERSION)
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
echo "Performing full release for version ${releaseVersion.toString()}"

configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
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: 'JRELEASER_GPG_PASSPHRASE'),
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']) {
sh 'cat $HOME/.ssh/config'
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
env.RELEASE_GPG_HOMEDIR = env.WORKSPACE_TMP + '/.gpg'
sh """
bash -xe hibernate-release-scripts/release.sh ${params.RELEASE_DRY_RUN ? '-d' : ''} \
models ${releaseVersion.toString()} ${developmentVersion.toString()}
"""
}
}
}
}
}
}
}
}
29 changes: 29 additions & 0 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project:
languages:
java:
groupId: org.hibernate.models

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

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

# Deploy JARs and POMs to Maven Central
deploy:
maven:
nexus2:
maven-central:
active: ALWAYS
url: https://oss.sonatype.org/service/local
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
closeRepository: true
releaseRepository: true
stagingRepositories:
- build/staging-deploy/maven
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pluginManagement {
plugins {
id "org.checkerframework" version "0.6.34" apply false
id "io.github.gradle-nexus.publish-plugin" version "2.0.0" apply false
}
repositories {
gradlePluginPortal()
Expand Down