@@ -125,16 +125,14 @@ def publishDocumentationTask = tasks.register( 'publishDocumentation' ) {
125
125
}
126
126
}
127
127
128
- def releasePrepareTask = tasks. register( " releasePrepare" ) {
129
- description " Performs release preparations on local check-out, including updating changelog"
130
- group " Release"
131
- dependsOn commitDocChangesTask
128
+ def createTagTask = tasks. register( ' createTag' ) {
129
+ description " Create local tag"
132
130
133
131
doFirst {
134
132
if ( ! project. hasProperty( ' releaseVersion' ) || ! project. hasProperty( ' developmentVersion' )
135
133
|| ! project. hasProperty( ' gitRemote' ) || ! project. hasProperty( ' gitBranch' ) ) {
136
134
throw new GradleException (
137
- " Task 'releasePrepare ' requires all of the following properties to be set:"
135
+ " Task 'createTag ' requires all of the following properties to be set:"
138
136
+ " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
139
137
)
140
138
}
@@ -147,25 +145,73 @@ def releasePrepareTask = tasks.register( "releasePrepare" ) {
147
145
logger. lifecycle( " Checking that all commits are pushed..." )
148
146
String diffWithUpstream = executeGitCommand( ' diff' , ' @{u}' )
149
147
if ( ! diffWithUpstream. isEmpty() ) {
150
- throw new GradleException (
151
- " Cannot release because there are commits on the branch to release that haven't been pushed yet."
152
- + " \n Push your commits to the branch to release first."
153
- )
148
+ throw new GradleException ( " There are commits on the branch to release that haven't been pushed yet" )
154
149
}
155
150
156
- logger. lifecycle( " Adding commit to update version to '${ project.releaseVersion} '..." )
151
+ logger. lifecycle( " Commit version update to '${ project.releaseVersion} '..." )
157
152
project. projectVersionFile. text = " projectVersion=${ project.releaseVersion} "
158
153
executeGitCommand( ' add' , ' .' )
159
154
executeGitCommand( ' commit' , ' -m' , project. releaseVersion )
155
+
156
+ String tag = project. releaseVersion
157
+ if ( tag. endsWith( " .Final" ) ) {
158
+ tag = tag. replace( " .Final" , " " )
159
+ }
160
+ logger. lifecycle( " Tagging '${ tag} '..." )
161
+ executeGitCommand( ' tag' , ' -a' , ' -m' , " Release ${ project.releaseVersion} " , tag )
160
162
}
161
163
}
162
164
163
- /*
164
- * Release everything
165
- */
166
- def ciReleaseTask = tasks. register( ' ciRelease' ) {
167
- description " Triggers the release on CI: creates commits to change the version (release, then development), creates a tag, pushes everything. Then CI will take over and perform the release."
165
+ def updateVersionsTask = tasks. register( " updateVersions" ) {
166
+ description " Update the release and development version, commit the changes, and create the tag"
168
167
group " Release"
168
+ dependsOn createTagTask
169
+
170
+ doFirst {
171
+ if ( ! project. hasProperty( ' releaseVersion' ) || ! project. hasProperty( ' developmentVersion' )
172
+ || ! project. hasProperty( ' gitRemote' ) || ! project. hasProperty( ' gitBranch' ) ) {
173
+ throw new GradleException (
174
+ " Task 'releasePrepare' requires all of the following properties to be set:"
175
+ + " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
176
+ )
177
+ }
178
+ }
179
+
180
+ doLast {
181
+ logger. lifecycle( " Checking that the working tree is clean..." )
182
+ String uncommittedFiles = executeGitCommand( ' status' , ' --porcelain' )
183
+ if ( ! uncommittedFiles. isEmpty() ) {
184
+ throw new GradleException (
185
+ " Cannot update the version because there are uncommitted changes in the working tree."
186
+ + " \n Uncommitted files:\n " + uncommittedFiles
187
+ )
188
+ }
189
+
190
+ logger. lifecycle( " Adding commit to update version to '${ project.developmentVersion} '..." )
191
+ project. projectVersionFile. text = " projectVersion=${ project.developmentVersion} "
192
+ executeGitCommand( ' add' , ' .' )
193
+ executeGitCommand( ' commit' , ' -m' , project. developmentVersion )
194
+ }
195
+ }
196
+
197
+ def releasePrepareTask = tasks. register( " releasePrepare" ) {
198
+ description " On a local checkout, performs all the changes required for the release"
199
+ group " Release"
200
+ dependsOn updateVersionsTask
201
+
202
+ doFirst {
203
+ if ( ! project. hasProperty( ' releaseVersion' ) || ! project. hasProperty( ' developmentVersion' )
204
+ || ! project. hasProperty( ' gitRemote' ) || ! project. hasProperty( ' gitBranch' ) ) {
205
+ throw new GradleException (
206
+ " Task 'releasePrepare' requires all of the following properties to be set:"
207
+ + " 'releaseVersion', 'developmentVersion', 'gitRemote' and 'gitBranch'."
208
+ )
209
+ }
210
+ }
211
+ }
212
+
213
+ def pushChangesTask = tasks. register( " pushChanges" ) {
214
+ description " Push the changes after preparing the release"
169
215
dependsOn releasePrepareTask
170
216
171
217
doFirst {
@@ -192,24 +238,21 @@ def ciReleaseTask = tasks.register( 'ciRelease' ) {
192
238
if ( tag. endsWith( " .Final" ) ) {
193
239
tag = tag. replace( " .Final" , " " )
194
240
}
195
- logger. lifecycle( " Tagging '${ tag} '..." )
196
- executeGitCommand( ' tag' , ' -a' , ' -m' , " Release ${ project.releaseVersion} " , tag )
197
-
198
- logger. lifecycle( " Adding commit to update version to '${ project.developmentVersion} '..." )
199
- project. projectVersionFile. text = " projectVersion=${ project.developmentVersion} "
200
- executeGitCommand( ' add' , ' .' )
201
- executeGitCommand( ' commit' , ' -m' , project. developmentVersion )
202
-
203
241
logger. lifecycle( " Pushing branch and tag to remote '${ project.gitRemote} '..." )
204
242
executeGitCommand( ' push' , ' --atomic' , project. gitRemote, project. gitBranch, tag )
205
-
206
243
logger. lifecycle( " Done!" )
207
-
208
- // logger
209
- // .lifecycle( "Go to https://github.com/hibernate/hibernate-reactive/actions?query=branch%3A${tag} to check the progress of the automated release." )
210
244
}
211
245
}
212
246
247
+ /*
248
+ * Release everything
249
+ */
250
+ def ciReleaseTask = tasks. register( ' ciRelease' ) {
251
+ description " Triggers the release on CI: creates commits to change the version (release, then development), creates a tag, pushes everything. Then CI will take over and perform the release."
252
+ group " Release"
253
+ dependsOn pushChangesTask
254
+ }
255
+
213
256
static String executeGitCommand (Object ... subcommand ){
214
257
List<Object > command = [' git' ]
215
258
Collections . addAll( command, subcommand )
0 commit comments