@@ -27,6 +27,7 @@ import net.kautler.util.release
2727import net.kautler.util.runBuildTasks
2828import net.kautler.util.updateVersion
2929import net.researchgate.release.ReleasePlugin
30+ import org.ajoberstar.grgit.operation.BranchListOp.Mode.ALL
3031import org.gradle.tooling.GradleConnector
3132import org.kohsuke.github.GHIssueState.OPEN
3233import wooga.gradle.github.base.tasks.Github
@@ -278,8 +279,41 @@ listOf(finishMilestone).forEach {
278279 }
279280}
280281
282+ val createMajorBranch by tasks.registering {
283+ doLast {
284+ val grgit = grgitService
285+ .service
286+ .get()
287+ .grgit
288+
289+ val (maxMajorVersion, maxMajorVersionBranch) = grgit
290+ .branch
291+ .list { mode = ALL }
292+ .filter {
293+ it.name.matches(""" (origin/)?v\d+""" .toRegex())
294+ }
295+ .map { it.name.substringAfter(' /' ).drop(1 ).toInt() to it }
296+ .maxBy { it.first }
297+
298+ if (maxMajorVersion < majorVersion.toInt()) {
299+ grgit.push { refsOrSpecs = listOf (" ${maxMajorVersionBranch.name} :refs/heads/v$majorVersion " ) }
300+ }
301+ }
302+ }
303+
304+ val checkoutMergeToReleaseBranch by tasks.existing {
305+ dependsOn(createMajorBranch)
306+ }
307+
308+ val preprocessVerifyReleaseWorkflow by tasks.existing {
309+ mustRunAfter(createMajorBranch)
310+ }
311+
281312tasks.preTagCommit {
282- dependsOn(tasks.named(" updateReadme" ))
313+ val updateReadme by tasks.existing
314+ dependsOn(updateReadme)
315+ dependsOn(createMajorBranch)
316+ dependsOn(preprocessVerifyReleaseWorkflow)
283317}
284318
285319undraftGithubRelease {
0 commit comments