Introduce command to perform an rc-release on a maven central repository.

See #38
This commit is contained in:
Greg L. Turnquist
2023-03-23 17:03:05 -05:00
committed by Mark Paluch
parent 9ae6e3b9f1
commit 2311977d8d
5 changed files with 55 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
/**
* @author Oliver Gierke
* @author Mark Paluch
* @author Greg Turnquist
*/
@Component
@RequiredArgsConstructor
@@ -162,6 +163,20 @@ public class BuildOperations {
});
}
/**
* Releases a repository of staged artifacts for this {@link ModuleIteration}.
*
* @param iteration
* @param stagingRepository
*/
public void release(ModuleIteration iteration, StagingRepository stagingRepository) {
doWithBuildSystem(iteration, (buildSystem, moduleIteration) -> {
buildSystem.release(stagingRepository);
return null;
});
}
public void buildDocumentation(TrainIteration iteration) {
executor.doWithBuildSystemOrdered(Streamable.of(iteration.getModulesExcept(BOM, COMMONS, BUILD)),
@@ -202,6 +217,10 @@ public class BuildOperations {
logger.log(iteration, "Release: %s", summary);
if (iteration.getIteration().isPublic() && stagingRepository.isPresent()) {
release(module, stagingRepository);
}
return summary.getExecutions().stream().map(BuildExecutor.ExecutionResult::getResult).collect(Collectors.toList());
}

View File

@@ -30,6 +30,7 @@ import org.springframework.plugin.core.Plugin;
*
* @author Oliver Gierke
* @author Mark Paluch
* @author Greg Turnquist
*/
interface BuildSystem extends Plugin<Project> {
@@ -68,6 +69,11 @@ interface BuildSystem extends Plugin<Project> {
*/
void close(StagingRepository stagingRepository);
/**
* Release a remote repository of staged artifacts.
*/
void release(StagingRepository stagingRepository);
<M extends ProjectAware> M triggerBuild(M module);
<M extends ProjectAware> M triggerDocumentationBuild(M module);

View File

@@ -387,6 +387,23 @@ class MavenBuildSystem implements BuildSystem {
logger.log(iteration, "✅ Smoke tests passed. Do not smoke 🚭. It's unhealthy.");
}
/**
* Perform a {@literal nexus-staging:rc-release}.
*/
@Override
public void release(StagingRepository stagingRepository) {
Assert.notNull(stagingRepository, "StagingRepository must not be null");
Assert.isTrue(stagingRepository.isPresent(), "StagingRepository must be present");
CommandLine arguments = CommandLine.of(goal("nexus-staging:rc-release"), //
profile("central"), //
arg("stagingRepositoryId").withValue(stagingRepository.getId()))
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml()));
mvn.execute(BUILD, arguments);
}
@Override
public <M extends ProjectAware> M triggerDocumentationBuild(M module) {

View File

@@ -46,6 +46,7 @@ import org.springframework.util.Assert;
/**
* @author Oliver Gierke
* @author Greg Turnquist
*/
@CliComponent
@RequiredArgsConstructor
@@ -149,6 +150,15 @@ class ReleaseCommands extends TimedCommand {
}
}
@CliCommand(value = "release repository")
public void repositoryRelease(@CliOption(key = "", mandatory = true) TrainIteration iteration,
@CliOption(key = "stagingRepositoryId", mandatory = true) String stagingRepositoryId) {
if (iteration.getIteration().isPublic()) {
build.release(iteration.getModule(Projects.BUILD), StagingRepository.of(stagingRepositoryId));
}
}
@CliCommand(value = "release build")
public void buildRelease(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
@CliOption(key = "project", mandatory = false) String projectName) {