Skip to content
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

Update release process #1991

Merged
merged 3 commits into from
Sep 17, 2024
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
137 changes: 8 additions & 129 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import java.util.regex.Pattern

plugins {
id "local.versions"

id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.asciidoctor.jvm.convert' version '4.0.2' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}

group = "org.hibernate.reactive"
// leverage the ProjectVersion which comes from the `local.versions` plugin
version = project.projectVersion.fullName

ext {
if ( !project.hasProperty( 'sonatypeOssrhUser' ) ) {
sonatypeOssrhUser = null
Expand All @@ -17,57 +21,12 @@ ext {
}
}

ext {
projectGroup = 'org.hibernate.reactive'
projectVersionFile = file( "${rootProject.projectDir}/gradle/version.properties" )
projectVersion = Version.parseProjectVersion( readVersionFromProperties( projectVersionFile ) )

if ( project.hasProperty('releaseVersion') ) {
releaseVersion = Version.parseReleaseVersion( project.releaseVersion )
}
if ( project.hasProperty('developmentVersion') ) {
developmentVersion = Version.parseDevelopmentVersion( project.developmentVersion )
}
}

// nexusPublishing uses group and version
// as defaults
group = projectGroup
version = projectVersion

// Versions which need to be aligned across modules; this also
// allows overriding the build using a parameter, which can be
// useful to monitor compatibility for upcoming versions on CI:
//
// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
ext {
if ( !project.hasProperty('hibernateOrmVersion') ) {
hibernateOrmVersion = '6.6.0.Final'
}
if ( !project.hasProperty( 'hibernateOrmGradlePluginVersion' ) ) {
// Same as ORM as default
hibernateOrmGradlePluginVersion = project.hibernateOrmVersion
}
// For ORM, we need a parsed version (to get the family, ...)

// For ORM, we need a parsed version (to get the family for the documentation during release).
// We use intervals to build with the latest ORM snapshot and this will fail version check.
// Because we don't need to publish or release anything we can disable the check in this case.
// Example:
// ./gradlew build -PhibernateOrmVersion='[5.4,5.5)' -PskipOrmVersionParsing
if ( project.hasProperty( 'skipOrmVersionParsing' ) ) {
// Default to true if the property is null
skipOrmVersionParsing = project.skipOrmVersionParsing ?: true
}
else {
skipOrmVersionParsing = false
}

if ( !Boolean.valueOf( project.skipOrmVersionParsing ) ) {
logger.lifecycle "Parsing ORM version"
hibernateOrmVersion = Version.parseProjectVersion( project.hibernateOrmVersion )
}

// Mainly, to allow CI to test the latest versions of Vert.X
// Example:
// ./gradlew build -PvertxSqlClientVersion=4.0.0-SNAPSHOT
Expand All @@ -77,10 +36,7 @@ ext {

testcontainersVersion = '1.19.8'

logger.lifecycle "Hibernate ORM Version: " + project.hibernateOrmVersion
logger.lifecycle "Hibernate ORM Gradle plugin Version: " + project.hibernateOrmGradlePluginVersion
logger.lifecycle "Vert.x SQL Client Version: " + project.vertxSqlClientVersion
logger.lifecycle "Hibernate Reactive: " + project.version
}

// To release, see task ciRelease in release/build.gradle
Expand All @@ -99,9 +55,8 @@ subprojects {
apply plugin: 'java-library'
apply plugin: 'com.diffplug.spotless'

// FIXME: Also setting the group and version here otherwise not all tasks will find them
group = projectGroup
version = projectVersion
group = rootProject.group
version = rootProject.version

spotless {
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
Expand Down Expand Up @@ -201,79 +156,3 @@ subprojects {
}
}

private static String readVersionFromProperties(File file) {
if ( !file.exists() ) {
throw new GradleException( "Version file $file.canonicalPath does not exists" )
}
Properties versionProperties = new Properties()
file.withInputStream {
stream -> versionProperties.load( stream )
}
return versionProperties.projectVersion
}

class Version {

private static final Pattern RELEASE_VERSION_PATTERN = ~/^(\d+)\.(\d+)\.(\d+)\.((?:Alpha\d+|Beta\d+|CR\d+)|Final)$/

private static final Pattern DEVELOPMENT_VERSION_PATTERN = ~/^(\d+)\.(\d+)\.(\d+)-SNAPSHOT$/

static Version parseReleaseVersion(String versionString) {
def matcher = (versionString =~ RELEASE_VERSION_PATTERN)
if ( !matcher.matches() ) {
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Release version numbers must match /$RELEASE_VERSION_PATTERN/."
)
}
return new Version( matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(4), false )
}

static Version parseDevelopmentVersion(String versionString) {
def matcher = (versionString =~ DEVELOPMENT_VERSION_PATTERN)
if ( !matcher.matches() ) {
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Development version numbers must match /$DEVELOPMENT_VERSION_PATTERN/."
)
}

return new Version( matcher.group(1), matcher.group(2), matcher.group(3), null, true )
}

static Version parseProjectVersion(String versionString) {
if ( (versionString =~ RELEASE_VERSION_PATTERN).matches() ) {
return parseReleaseVersion( versionString )
}
if ( (versionString =~ DEVELOPMENT_VERSION_PATTERN).matches() ) {
return parseDevelopmentVersion( versionString )
}
throw new IllegalArgumentException(
"Invalid version number: '$versionString'." +
" Project version numbers must match either /$RELEASE_VERSION_PATTERN/ or /$DEVELOPMENT_VERSION_PATTERN/."
)
}

final String major
final String minor
final String micro
final String qualifier
final boolean snapshot

Version(String major, String minor, String micro, String qualifier, boolean snapshot) {
this.major = major
this.minor = minor
this.micro = micro
this.qualifier = qualifier
this.snapshot = snapshot
}

@Override
String toString() {
[major, minor, micro, qualifier].findAll({ it != null }).join('.') + (snapshot ? '-SNAPSHOT' : '')
}

String getFamily() {
"$major.$minor"
}
}
33 changes: 33 additions & 0 deletions ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,39 @@ pipeline {
}
}
}
stage('Release prepare') {
steps {
script {
checkoutReleaseScripts()

configFileProvider([
configFile(fileId: 'release.config.ssh', targetLocation: "${env.HOME}/.ssh/config"),
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: "${env.HOME}/.ssh/known_hosts")
]) {
withCredentials([
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USER'),
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'PLUGIN_PORTAL_PASSWORD', usernameVariable: 'PLUGIN_PORTAL_USERNAME'),
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
string(credentialsId: 'release.gpg.passphrase', variable: 'RELEASE_GPG_PASSPHRASE')
]) {
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
// set release version
// update changelog from JIRA
// tags the version
// changes the version to the provided development version
withEnv([
"BRANCH=${env.GIT_BRANCH}",
// Increase the amount of memory for this part since asciidoctor doc rendering consumes a lot of metaspace
"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'"
]) {
sh ".release/scripts/prepare-release.sh ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
}
}
}
}
}
}
}
stage('Publish release') {
steps {
script {
Expand Down
59 changes: 59 additions & 0 deletions ci/snapshot-publish.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* See https://github.com/hibernate/hibernate-jenkins-pipeline-helpers
*/
@Library('hibernate-jenkins-pipeline-helpers@1.13') _

// Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'NOT_BUILT'
return
}

pipeline {
agent {
label 'Fedora'
}
tools {
jdk 'OpenJDK 11 Latest'
}
options {
rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true])
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
disableConcurrentBuilds(abortPrevious: true)
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Publish') {
steps {
withCredentials([
usernamePassword(credentialsId: 'ossrh.sonatype.org', usernameVariable: 'hibernatePublishUsername', passwordVariable: 'hibernatePublishPassword'),
usernamePassword(credentialsId: 'plugins.gradle.org', usernameVariable: 'hibernatePluginPortalUsername', passwordVariable: 'hibernatePluginPortalPassword'),
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_PASS'),
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_KEYRING')
]) {
sh '''./gradlew clean publish \
-PhibernatePublishUsername=$hibernatePublishUsername \
-PhibernatePublishPassword=$hibernatePublishPassword \
-Pgradle.publish.key=$hibernatePluginPortalUsername \
-Pgradle.publish.secret=$hibernatePluginPortalPassword \
--no-scan \
-DsigningPassword=$SIGNING_PASS \
-DsigningKeyFile=$SIGNING_KEYRING \
'''
}
}
}
}
post {
always {
configFileProvider([configFile(fileId: 'job-configuration.yaml', variable: 'JOB_CONFIGURATION_FILE')]) {
notifyBuildResult maintainers: (String) readYaml(file: env.JOB_CONFIGURATION_FILE).notification?.email?.recipients
}
}
}
}
Loading
Loading