Refine build and release build/build-distribute commands for Git operations.
Release commands now require a tag to operate on. Build commands build the current repository state without resetting the Git state. Closes #15
This commit is contained in:
@@ -26,7 +26,6 @@ import java.util.Optional;
|
|||||||
import org.springframework.data.release.CliComponent;
|
import org.springframework.data.release.CliComponent;
|
||||||
import org.springframework.data.release.TimedCommand;
|
import org.springframework.data.release.TimedCommand;
|
||||||
import org.springframework.data.release.cli.TrainIterationConverter;
|
import org.springframework.data.release.cli.TrainIterationConverter;
|
||||||
import org.springframework.data.release.git.GitOperations;
|
|
||||||
import org.springframework.data.release.io.Workspace;
|
import org.springframework.data.release.io.Workspace;
|
||||||
import org.springframework.data.release.model.Project;
|
import org.springframework.data.release.model.Project;
|
||||||
import org.springframework.data.release.model.Projects;
|
import org.springframework.data.release.model.Projects;
|
||||||
@@ -49,7 +48,6 @@ class BuildCommands extends TimedCommand {
|
|||||||
|
|
||||||
@NonNull BuildOperations build;
|
@NonNull BuildOperations build;
|
||||||
@NonNull Workspace workspace;
|
@NonNull Workspace workspace;
|
||||||
@NonNull GitOperations git;
|
|
||||||
@NonNull Logger logger;
|
@NonNull Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +81,6 @@ class BuildCommands extends TimedCommand {
|
|||||||
project.ifPresent(it -> build.triggerBuild(iteration.getModule(it)));
|
project.ifPresent(it -> build.triggerBuild(iteration.getModule(it)));
|
||||||
|
|
||||||
if (!project.isPresent()) {
|
if (!project.isPresent()) {
|
||||||
git.prepare(iteration);
|
|
||||||
iteration.forEach(build::triggerBuild);
|
iteration.forEach(build::triggerBuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,17 +99,14 @@ class BuildCommands extends TimedCommand {
|
|||||||
TrainIteration.class, null);
|
TrainIteration.class, null);
|
||||||
|
|
||||||
Assert.notNull(trainIteration, "TrainIteration must not be null!");
|
Assert.notNull(trainIteration, "TrainIteration must not be null!");
|
||||||
git.prepare(trainIteration);
|
|
||||||
build.distributeResources(trainIteration);
|
build.distributeResources(trainIteration);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Train train = ReleaseTrains.getTrainByName(trainOrIteration);
|
Train train = ReleaseTrains.getTrainByName(trainOrIteration);
|
||||||
|
|
||||||
Assert.notNull(train, "Train must not be null!");
|
Assert.notNull(train, "Train must not be null!");
|
||||||
|
|
||||||
git.checkout(train);
|
|
||||||
build.distributeResources(train);
|
build.distributeResources(train);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.assertj.core.util.VisibleForTesting;
|
import org.assertj.core.util.VisibleForTesting;
|
||||||
|
|
||||||
import org.springframework.data.release.deployment.DeploymentInformation;
|
import org.springframework.data.release.deployment.DeploymentInformation;
|
||||||
import org.springframework.data.release.deployment.StagingRepository;
|
import org.springframework.data.release.deployment.StagingRepository;
|
||||||
import org.springframework.data.release.model.Module;
|
import org.springframework.data.release.model.Module;
|
||||||
@@ -74,42 +73,77 @@ public class BuildOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the distribution builds for all modules participating in the given {@link TrainIteration}.
|
* Prepares the versions of the given {@link TrainIteration} depending on the given {@link Phase}.
|
||||||
*
|
*
|
||||||
* @param iteration must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
|
* @param phase must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public void distributeResources(TrainIteration iteration) {
|
public void prepareVersions(TrainIteration iteration, Phase phase) {
|
||||||
|
|
||||||
Assert.notNull(iteration, "Train iteration must not be null!");
|
Assert.notNull(iteration, "Train iteration must not be null!");
|
||||||
|
Assert.notNull(phase, "Phase must not be null!");
|
||||||
|
|
||||||
distributeResources(iteration.getTrain());
|
BuildExecutor.Summary<ModuleIteration> summary = executor.doWithBuildSystemOrdered(iteration,
|
||||||
|
(system, module) -> system.prepareVersion(module, phase));
|
||||||
|
|
||||||
|
logger.log(iteration, "Prepare versions: %s", summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the distribution builds for all modules participating in the given {@link Train}.
|
* Prepares the version of the given {@link ModuleIteration} depending on the given {@link Phase}.
|
||||||
*
|
*
|
||||||
* @param train must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
|
* @param phase must not be {@literal null}.
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public void distributeResources(Train train) {
|
@VisibleForTesting
|
||||||
|
public ModuleIteration prepareVersion(ModuleIteration iteration, Phase phase) {
|
||||||
|
|
||||||
Assert.notNull(train, "Train must not be null!");
|
Assert.notNull(iteration, "Module iteration must not be null!");
|
||||||
|
Assert.notNull(phase, "Phase must not be null!");
|
||||||
|
|
||||||
BuildExecutor.Summary<Module> summary = executor.doWithBuildSystemAnyOrder(train,
|
return doWithBuildSystem(iteration, (system, module) -> system.prepareVersion(module, phase));
|
||||||
BuildSystem::triggerDistributionBuild);
|
|
||||||
|
|
||||||
logger.log(train, "Distribution build: %s", summary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the distribution builds for the given module.
|
* Opens a repository to stage artifacts for this {@link ModuleIteration}.
|
||||||
*
|
*
|
||||||
* @param iteration must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public void distributeResources(ModuleIteration iteration) {
|
public void open(ModuleIteration iteration) {
|
||||||
|
|
||||||
Assert.notNull(iteration, "ModuleIteration must not be null!");
|
doWithBuildSystem(iteration, (buildSystem, moduleIteration) -> buildSystem.open());
|
||||||
|
}
|
||||||
|
|
||||||
doWithBuildSystem(iteration, BuildSystem::triggerDistributionBuild);
|
/**
|
||||||
|
* Closes a repository to stage artifacts for this {@link ModuleIteration}.
|
||||||
|
*
|
||||||
|
* @param iteration must not be {@literal null}.
|
||||||
|
* @param stagingRepository must not be {@literal null}.
|
||||||
|
*/
|
||||||
|
public void close(ModuleIteration iteration, StagingRepository stagingRepository) {
|
||||||
|
|
||||||
|
Assert.notNull(stagingRepository, "StagingRepository must not be null");
|
||||||
|
Assert.isTrue(stagingRepository.isPresent(), "StagingRepository must be present");
|
||||||
|
|
||||||
|
doWithBuildSystem(iteration, (buildSystem, moduleIteration) -> {
|
||||||
|
buildSystem.close(stagingRepository);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a local build for all modules in the given {@link TrainIteration}.
|
||||||
|
*
|
||||||
|
* @param iteration must not be {@literal null}.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void build(TrainIteration iteration) {
|
||||||
|
|
||||||
|
executor.doWithBuildSystemOrdered(iteration, BuildSystem::triggerBuild);
|
||||||
|
|
||||||
|
logger.log(iteration, "Build finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,36 +183,42 @@ public class BuildOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the versions of the given {@link TrainIteration} depending on the given {@link Phase}.
|
* Triggers the distribution builds for all modules participating in the given {@link TrainIteration}.
|
||||||
*
|
*
|
||||||
* @param iteration must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
* @param phase must not be {@literal null}.
|
|
||||||
*/
|
*/
|
||||||
public void prepareVersions(TrainIteration iteration, Phase phase) {
|
public void distributeResources(TrainIteration iteration) {
|
||||||
|
|
||||||
Assert.notNull(iteration, "Train iteration must not be null!");
|
Assert.notNull(iteration, "Train iteration must not be null!");
|
||||||
Assert.notNull(phase, "Phase must not be null!");
|
|
||||||
|
|
||||||
BuildExecutor.Summary<ModuleIteration> summary = executor.doWithBuildSystemOrdered(iteration,
|
distributeResources(iteration.getTrain());
|
||||||
(system, module) -> system.prepareVersion(module, phase));
|
|
||||||
|
|
||||||
logger.log(iteration, "Prepare versions: %s", summary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the version of the given {@link ModuleIteration} depending on the given {@link Phase}.
|
* Triggers the distribution builds for all modules participating in the given {@link Train}.
|
||||||
|
*
|
||||||
|
* @param train must not be {@literal null}.
|
||||||
|
*/
|
||||||
|
public void distributeResources(Train train) {
|
||||||
|
|
||||||
|
Assert.notNull(train, "Train must not be null!");
|
||||||
|
|
||||||
|
BuildExecutor.Summary<Module> summary = executor.doWithBuildSystemAnyOrder(train,
|
||||||
|
BuildSystem::triggerDistributionBuild);
|
||||||
|
|
||||||
|
logger.log(train, "Distribution build: %s", summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers the distribution builds for the given module.
|
||||||
*
|
*
|
||||||
* @param iteration must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
* @param phase must not be {@literal null}.
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
public void distributeResources(ModuleIteration iteration) {
|
||||||
public ModuleIteration prepareVersion(ModuleIteration iteration, Phase phase) {
|
|
||||||
|
|
||||||
Assert.notNull(iteration, "Module iteration must not be null!");
|
Assert.notNull(iteration, "ModuleIteration must not be null!");
|
||||||
Assert.notNull(phase, "Phase must not be null!");
|
|
||||||
|
|
||||||
return doWithBuildSystem(iteration, (system, module) -> system.prepareVersion(module, phase));
|
doWithBuildSystem(iteration, BuildSystem::triggerDistributionBuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,33 +230,6 @@ public class BuildOperations {
|
|||||||
return properties.getLocalRepository().toPath();
|
return properties.getLocalRepository().toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a repository to stage artifacts for this {@link ModuleIteration}.
|
|
||||||
*
|
|
||||||
* @param iteration must not be {@literal null}.
|
|
||||||
*/
|
|
||||||
public void open(ModuleIteration iteration) {
|
|
||||||
|
|
||||||
doWithBuildSystem(iteration, (buildSystem, moduleIteration) -> buildSystem.open());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes a repository to stage artifacts for this {@link ModuleIteration}.
|
|
||||||
*
|
|
||||||
* @param iteration must not be {@literal null}.
|
|
||||||
* @param stagingRepository must not be {@literal null}.
|
|
||||||
*/
|
|
||||||
public void close(ModuleIteration iteration, StagingRepository stagingRepository) {
|
|
||||||
|
|
||||||
Assert.notNull(stagingRepository, "StagingRepository must not be null");
|
|
||||||
Assert.isTrue(stagingRepository.isPresent(), "StagingRepository must be present");
|
|
||||||
|
|
||||||
doWithBuildSystem(iteration, (buildSystem, moduleIteration) -> {
|
|
||||||
buildSystem.close(stagingRepository);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the release for the given {@link ModuleIteration} and deploys it to the staging repository.
|
* Builds the release for the given {@link ModuleIteration} and deploys it to the staging repository.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -67,6 +67,26 @@ class ReleaseCommands extends TimedCommand {
|
|||||||
orElse(null);
|
orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composite command to prepare a release.
|
||||||
|
*
|
||||||
|
* @param iteration
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@CliCommand(value = "prepare-it")
|
||||||
|
public void prepareIt(@CliOption(key = "", mandatory = true) TrainIteration iteration) throws Exception {
|
||||||
|
|
||||||
|
tracker.trackerPrepare(iteration);
|
||||||
|
|
||||||
|
prepare(iteration);
|
||||||
|
|
||||||
|
build.build(iteration);
|
||||||
|
|
||||||
|
conclude(iteration);
|
||||||
|
|
||||||
|
gitHub.push(iteration);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composite command to ship a full release.
|
* Composite command to ship a full release.
|
||||||
*
|
*
|
||||||
@@ -80,14 +100,14 @@ class ReleaseCommands extends TimedCommand {
|
|||||||
|
|
||||||
prepare(iteration);
|
prepare(iteration);
|
||||||
|
|
||||||
buildRelease(iteration, null);
|
|
||||||
|
|
||||||
conclude(iteration);
|
conclude(iteration);
|
||||||
|
|
||||||
gitHub.push(iteration);
|
buildRelease(iteration, null);
|
||||||
|
|
||||||
distribute(iteration, null);
|
distribute(iteration, null);
|
||||||
|
|
||||||
|
gitHub.push(iteration);
|
||||||
|
|
||||||
tracker.closeIteration(iteration);
|
tracker.closeIteration(iteration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +153,8 @@ class ReleaseCommands extends TimedCommand {
|
|||||||
public void buildRelease(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
|
public void buildRelease(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
|
||||||
@CliOption(key = "project", mandatory = false) String projectName) {
|
@CliOption(key = "project", mandatory = false) String projectName) {
|
||||||
|
|
||||||
|
git.checkout(iteration);
|
||||||
|
|
||||||
if (!iteration.getIteration().isPublic()) {
|
if (!iteration.getIteration().isPublic()) {
|
||||||
deployment.verifyAuthentication();
|
deployment.verifyAuthentication();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class GitOperations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks out all projects of the given {@link TrainIteration}.
|
* Checks out all projects of the given {@link TrainIteration} using their tags.
|
||||||
*
|
*
|
||||||
* @param iteration must not be {@literal null}.
|
* @param iteration must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user