Skip to content

Commit

Permalink
Push to github atomically and only if the release succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere authored and dreab8 committed Jun 22, 2020
1 parent 02abce6 commit 1ad029c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions release/release.gradle
Expand Up @@ -302,7 +302,6 @@ task addVersionCommit( dependsOn: [releaseChecks] ) {
logger.lifecycle( "Adding commit to update version to '${project.releaseVersion}'..." )
executeGitCommand( 'add', '.' )
executeGitCommand( 'commit', '-m', project.ormVersion.fullName )
executeGitCommand( 'push', project.gitRemote )
}
}
release.mustRunAfter addVersionCommit
Expand All @@ -311,21 +310,29 @@ task ciRelease( dependsOn: [releaseChecks, addVersionCommit, release] ) {
group = "Release"
description = "Performs a release: the hibernate version is set and the changelog.txt file updated, the changes are pushed to github, then the release is performed, tagged and the hibernate version is set to the development one."
doLast {
String tag = null
if ( !project.hasProperty( 'noTag' ) ) {
String tag = project.ormVersion.fullName
tag = project.ormVersion.fullName
// the release is tagged and the tag is pushed to github
if ( tag.endsWith( ".Final" ) ) {
tag = tag.replace( ".Final", "" )
}
logger.lifecycle( "Tagging '${tag}'..." )
executeGitCommand( 'tag', tag )
executeGitCommand( 'push', project.gitRemote, tag )
}

logger.lifecycle( "Adding commit to update version to '${project.developmentVersion}'..." )
project.ormVersionFile.text = "hibernateVersion=${project.developmentVersion}"
executeGitCommand( 'add', '.')
executeGitCommand( 'commit', '-m', project.developmentVersion )

logger.lifecycle( "Adding commit to update version to '${project.developmentVersion}'..." )
project.ormVersionFile.text = "hibernateVersion=${project.developmentVersion}"
executeGitCommand( 'add', '.')
executeGitCommand( 'commit', '-m', project.developmentVersion )
executeGitCommand( 'push', project.gitRemote )
if ( tag != null ) {
logger.lifecycle("Pushing branch and tag to remote '${project.gitRemote}'...")
executeGitCommand( 'push', '--atomic', project.gitRemote , project.gitBranch, tag )
}
else {
logger.lifecycle("Pushing branch to remote '${project.gitRemote}'...")
executeGitCommand( 'push', project.gitRemote , project.gitBranch )
}
}
}
Expand Down

0 comments on commit 1ad029c

Please sign in to comment.