diff --git a/release-tools/src/main/java/org/springframework/data/release/cli/ReleaseCommands.java b/release-tools/src/main/java/org/springframework/data/release/cli/ReleaseCommands.java index c491813..a8ae7c9 100644 --- a/release-tools/src/main/java/org/springframework/data/release/cli/ReleaseCommands.java +++ b/release-tools/src/main/java/org/springframework/data/release/cli/ReleaseCommands.java @@ -107,9 +107,6 @@ class ReleaseCommands extends TimedCommand { List deploymentInformation = build.performRelease(iteration); deploymentInformation.forEach(deployment::promote); - - build.prepareVersions(iteration, Phase.CLEANUP); - git.commit(iteration, "Prepare next development iteration."); } } @@ -124,22 +121,31 @@ class ReleaseCommands extends TimedCommand { Assert.notNull(iteration, "Train iteration must not be null!"); - // Tag release - git.tagRelease(iteration); + build.prepareVersions(iteration, Phase.CLEANUP); + git.commit(iteration, "Prepare next development iteration."); // Prepare master branch build.updateProjectDescriptors(iteration, Phase.CLEANUP); git.commit(iteration, "After release cleanups."); + // Tag release + git.tagRelease(iteration); + // Prepare maintenance branches if (iteration.getIteration().isGAIteration()) { + // Create bugfix branches git.createMaintenanceBranches(iteration); - build.updateProjectDescriptors(iteration, Phase.MAINTENANCE); + // Set project version to maintenance once build.prepareVersions(iteration, Phase.MAINTENANCE); git.commit(iteration, "Prepare next development iteration."); + // Update inter-project dependencies and repositories + build.updateProjectDescriptors(iteration, Phase.MAINTENANCE); + git.commit(iteration, "After release cleanups."); + + // Back to master branch git.checkout(iteration); } } diff --git a/release-tools/src/main/java/org/springframework/data/release/git/Branch.java b/release-tools/src/main/java/org/springframework/data/release/git/Branch.java index 982018d..0165454 100644 --- a/release-tools/src/main/java/org/springframework/data/release/git/Branch.java +++ b/release-tools/src/main/java/org/springframework/data/release/git/Branch.java @@ -59,7 +59,7 @@ public class Branch implements Comparable { return from(versioned.getVersion()); } - private static Branch from(Version version) { + public static Branch from(Version version) { return from(version.toString().concat(".x")); } diff --git a/release-tools/src/main/java/org/springframework/data/release/git/GitOperations.java b/release-tools/src/main/java/org/springframework/data/release/git/GitOperations.java index 46f8d0c..38f6824 100644 --- a/release-tools/src/main/java/org/springframework/data/release/git/GitOperations.java +++ b/release-tools/src/main/java/org/springframework/data/release/git/GitOperations.java @@ -148,8 +148,6 @@ public class GitOperations { Assert.notNull(iteration, "Train iteration must not be null!"); - update(iteration.getTrain()); - ExecutionUtils.run(iteration, module -> { Project project = module.getProject(); @@ -319,23 +317,23 @@ public class GitOperations { }); } + /** + * Tags the release commits for the given {@link TrainIteration}. + * + * @param iteration + */ public void tagRelease(TrainIteration iteration) { + Assert.notNull(iteration, "Train iteration must not be null!"); + ExecutionUtils.run(iteration, module -> { - Branch branch = Branch.from(module); Project project = module.getProject(); + ObjectId hash = getReleaseHash(module); + Tag tag = getTags(project).createTag(module); doWithGit(project, git -> { - checkout(project, branch); - - logger.log(module, "git pull", branch); - git.pull().call(); - - ObjectId hash = getReleaseHash(module); - Tag tag = getTags(project).createTag(module); - try (RevWalk walk = new RevWalk(git.getRepository())) { RevCommit commit = walk.parseCommit(hash); @@ -423,11 +421,11 @@ public class GitOperations { } /** - * Checks out the given {@link Branch} of the given {@link Project}. + * Checks out the given {@link Branch} of the given {@link Project}. If the given branch doesn't exist yet, a tracking + * branch is created assuming the branch exists in the {@code origin} remote. * * @param project must not be {@literal null}. * @param branch must not be {@literal null}. - * @throws Exception */ public void checkout(Project project, Branch branch) { @@ -462,9 +460,14 @@ public class GitOperations { public void createMaintenanceBranches(TrainIteration iteration) { + if (!iteration.getIteration().isGAIteration()) { + return; + } + checkout(iteration); ExecutionUtils.run(iteration, module -> { + Branch branch = createMaintenanceBranch(module); checkout(module.getProject(), branch); }); @@ -539,11 +542,20 @@ public class GitOperations { }); } + /** + * Creates a version branch for the given {@link ModuleIteration}. + * + * @param module must not be {@literal null}. + * @return + */ private Branch createMaintenanceBranch(ModuleIteration module) { - Branch branch = Branch.from(module); + Assert.notNull(module, "Module iteration must not be null!"); + + Branch branch = Branch.from(module.getVersion()); doWithGit(module.getProject(), git -> { + logger.log(module, "git checkout -b %s", branch); git.branchCreate().setName(branch.toString()).call(); });