Updates for new sagain api, s-c-build 3.1 and boot 2.6 (#243)

Updates releaser to use spring cloud build 3.1.0

Transitively uses boot 2.6

Updates releaser to use new Sagan API

Fixes gh-196
Fixes gh-194
This commit is contained in:
Spencer Gibb
2022-02-18 14:29:17 -05:00
committed by GitHub
parent 2e7d318f13
commit e83cda4fed
195 changed files with 2914 additions and 4881 deletions

View File

@@ -27,8 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ReleaserApplication extends ReleaserCommandLineRunner {
public ReleaserApplication(SpringReleaser releaser,
ExecutionResultHandler executionResultHandler, Parser parser) {
public ReleaserApplication(SpringReleaser releaser, ExecutionResultHandler executionResultHandler, Parser parser) {
super(releaser, executionResultHandler, parser);
}

View File

@@ -24,8 +24,7 @@ final class SpringCloudBomConstants {
// boot
static final String SPRING_BOOT = "spring-boot";
static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter";
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID
+ "-parent";
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + "-parent";
static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies";
// sc-build

View File

@@ -52,17 +52,15 @@ import static releaser.cloud.buildsystem.SpringCloudBomConstants.STREAM_STARTER_
class SpringCloudMavenBomParser implements CustomBomParser {
private static final Logger log = LoggerFactory
.getLogger(SpringCloudMavenBomParser.class);
private static final Logger log = LoggerFactory.getLogger(SpringCloudMavenBomParser.class);
@Override
public VersionsFromBom parseBom(File root, ReleaserProperties properties) {
VersionsFromBom springCloudBuild = springCloudBuild(root, properties);
VersionsFromBom boot = bootVersion(root, properties);
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]",
springCloudBuild, boot);
return new VersionsFromBomBuilder().thisProjectRoot(root)
.releaserProperties(properties).projects(springCloudBuild, boot).merged();
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]", springCloudBuild, boot);
return new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
.projects(springCloudBuild, boot).merged();
}
private VersionsFromBom springCloudBuild(File root, ReleaserProperties properties) {
@@ -70,8 +68,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
if (StringUtils.isEmpty(buildVersion)) {
return VersionsFromBom.EMPTY_VERSION;
}
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root)
.releaserProperties(properties).merged();
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root).releaserProperties(properties)
.merged();
scBuild.add(BUILD_ARTIFACT_ID, buildVersion);
scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion);
return scBuild;
@@ -88,11 +86,9 @@ class SpringCloudMavenBomParser implements CustomBomParser {
}
Model model = PomReader.pom(root, properties.getPom().getThisTrainBom());
String buildArtifact = model.getParent().getArtifactId();
log.debug("[{}] artifact id is equal to [{}]",
CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
log.debug("[{}] artifact id is equal to [{}]", CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
throw new IllegalStateException(
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
throw new IllegalStateException("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
}
buildVersion = model.getParent().getVersion();
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
@@ -104,8 +100,7 @@ class SpringCloudMavenBomParser implements CustomBomParser {
if (StringUtils.hasText(bootVersion)) {
return bootVersion;
}
String pomWithBootStarterParent = properties.getPom()
.getPomWithBootStarterParent();
String pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent();
File pom = new File(root, pomWithBootStarterParent);
if (!pom.exists()) {
return "";
@@ -118,8 +113,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
if (!BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) {
if (log.isDebugEnabled()) {
throw new IllegalStateException("The pom doesn't have a ["
+ BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
throw new IllegalStateException(
"The pom doesn't have a [" + BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
}
return "";
}
@@ -132,8 +127,8 @@ class SpringCloudMavenBomParser implements CustomBomParser {
return VersionsFromBom.EMPTY_VERSION;
}
log.debug("Boot version is equal to [{}]", bootVersion);
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
.thisProjectRoot(root).releaserProperties(properties).merged();
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().thisProjectRoot(root)
.releaserProperties(properties).merged();
versionsFromBom.add(SPRING_BOOT, bootVersion);
versionsFromBom.add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
versionsFromBom.add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
@@ -141,8 +136,7 @@ class SpringCloudMavenBomParser implements CustomBomParser {
}
@Override
public Set<Project> setVersion(Set<Project> projects, String projectName,
String version) {
public Set<Project> setVersion(Set<Project> projects, String projectName, String version) {
Set<Project> newProjects = new LinkedHashSet<>(projects);
switch (projectName) {
case SPRING_BOOT:

View File

@@ -35,18 +35,15 @@ import org.springframework.util.StringUtils;
/**
* @author Marcin Grzejszczak
*/
class SpringCloudCustomProjectDocumentationUpdater
implements CustomProjectDocumentationUpdater {
class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocumentationUpdater {
private static final Logger log = LoggerFactory
.getLogger(SpringCloudCustomProjectDocumentationUpdater.class);
private static final Logger log = LoggerFactory.getLogger(SpringCloudCustomProjectDocumentationUpdater.class);
private final ProjectGitHandler gitHandler;
private final ReleaserProperties releaserProperties;
SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler,
ReleaserProperties releaserProperties) {
SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler, ReleaserProperties releaserProperties) {
this.gitHandler = gitHandler;
this.releaserProperties = releaserProperties;
}
@@ -60,11 +57,10 @@ class SpringCloudCustomProjectDocumentationUpdater
* used
*/
@Override
public File updateDocsRepoForReleaseTrain(File clonedDocumentationProject,
ProjectVersion currentProject, Projects projects, String bomBranch) {
public File updateDocsRepoForReleaseTrain(File clonedDocumentationProject, ProjectVersion currentProject,
Projects projects, String bomBranch) {
if (!currentProject.projectName.startsWith("spring-cloud")) {
log.info(
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
log.info("Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
currentProject.projectName);
return clonedDocumentationProject;
}
@@ -72,12 +68,10 @@ class SpringCloudCustomProjectDocumentationUpdater
ProjectVersion releaseTrainProject = new ProjectVersion(
this.releaserProperties.getMetaRelease().getReleaseTrainProjectName(),
branchToReleaseVersion(bomBranch));
File currentReleaseFolder = new File(clonedDocumentationProject,
currentFolder(releaseTrainProject));
File currentReleaseFolder = new File(clonedDocumentationProject, currentFolder(releaseTrainProject));
// remove the old way
removeAFolderWithRedirection(currentReleaseFolder);
File docsRepo = updateTheDocsRepo(releaseTrainProject, clonedDocumentationProject,
currentReleaseFolder);
File docsRepo = updateTheDocsRepo(releaseTrainProject, clonedDocumentationProject, currentReleaseFolder);
return pushChanges(docsRepo);
}
@@ -89,8 +83,8 @@ class SpringCloudCustomProjectDocumentationUpdater
* used
*/
@Override
public File updateDocsRepoForSingleProject(File clonedDocumentationProject,
ProjectVersion currentProject, Projects projects) {
public File updateDocsRepoForSingleProject(File clonedDocumentationProject, ProjectVersion currentProject,
Projects projects) {
if (!projects.containsProject(currentProject.projectName)) {
log.warn(
"Can't update the documentation repo for project [{}] cause it's not present on the projects list {}",
@@ -98,23 +92,18 @@ class SpringCloudCustomProjectDocumentationUpdater
return clonedDocumentationProject;
}
if (!currentProject.projectName.startsWith("spring-cloud")) {
log.info(
"Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
log.info("Skipping updating docs for project [{}] that does not start with spring-cloud prefix",
currentProject.projectName);
return clonedDocumentationProject;
}
log.info("Updating link to documentation for project [{}]",
currentProject.projectName);
ProjectVersion currentProjectVersion = projects
.forName(currentProject.projectName);
File currentProjectReleaseFolder = new File(clonedDocumentationProject,
currentFolder(currentProjectVersion));
log.info("Updating link to documentation for project [{}]", currentProject.projectName);
ProjectVersion currentProjectVersion = projects.forName(currentProject.projectName);
File currentProjectReleaseFolder = new File(clonedDocumentationProject, currentFolder(currentProjectVersion));
removeAFolderWithRedirection(currentProjectReleaseFolder);
try {
updateTheDocsRepo(currentProjectVersion, clonedDocumentationProject,
currentProjectReleaseFolder);
log.info("Processed [{}] for project with name [{}]",
currentProjectReleaseFolder, currentProjectVersion.projectName);
updateTheDocsRepo(currentProjectVersion, clonedDocumentationProject, currentProjectReleaseFolder);
log.info("Processed [{}] for project with name [{}]", currentProjectReleaseFolder,
currentProjectVersion.projectName);
}
catch (Exception ex) {
log.warn("Exception occurred while trying o update the symlink of a project ["
@@ -140,14 +129,13 @@ class SpringCloudCustomProjectDocumentationUpdater
releaseTrain = currentProjectVersion.isReleaseTrain();
}
catch (IllegalStateException ex) {
log.warn("Exception occurred while trying to resolve if version ["
+ currentProjectVersion + "] is a release train", ex);
log.warn("Exception occurred while trying to resolve if version [" + currentProjectVersion
+ "] is a release train", ex);
releaseTrain = false;
}
// release train -> static/current
// project -> static/spring-cloud-sleuth/current
return releaseTrain ? "current"
: (StringUtils.hasText(projectName) ? projectName : "") + "/current";
return releaseTrain ? "current" : (StringUtils.hasText(projectName) ? projectName : "") + "/current";
}
String linkToVersion(File file) {
@@ -176,33 +164,28 @@ class SpringCloudCustomProjectDocumentationUpdater
return docsRepo;
}
private File updateTheDocsRepo(ProjectVersion projectVersion,
File documentationProject, File currentVersionFolder) {
private File updateTheDocsRepo(ProjectVersion projectVersion, File documentationProject,
File currentVersionFolder) {
try {
String storedVersion = linkToVersion(currentVersionFolder);
String currentVersion = projectVersion.version;
boolean newerVersion = StringUtils.isEmpty(storedVersion)
|| isMoreMature(storedVersion, currentVersion);
boolean newerVersion = StringUtils.isEmpty(storedVersion) || isMoreMature(storedVersion, currentVersion);
if (!newerVersion) {
log.info("Current version [{}] is not newer than the stored one [{}]",
currentVersion, storedVersion);
log.info("Current version [{}] is not newer than the stored one [{}]", currentVersion, storedVersion);
return documentationProject;
}
boolean deleted = Files.deleteIfExists(currentVersionFolder.toPath())
|| FileSystemUtils.deleteRecursively(currentVersionFolder.toPath());
if (deleted) {
log.info("Deleted current version folder link at [{}]",
currentVersionFolder);
log.info("Deleted current version folder link at [{}]", currentVersionFolder);
}
boolean creatingParentDirs = currentVersionFolder.getParentFile().mkdirs();
if (!creatingParentDirs) {
log.warn("Failed to create parent directory of [{}]",
currentVersionFolder);
log.warn("Failed to create parent directory of [{}]", currentVersionFolder);
}
File newTarget = new File(projectVersion.version);
Files.createSymbolicLink(currentVersionFolder.toPath(), newTarget.toPath());
log.info("Updated the link [{}] to point to [{}]",
currentVersionFolder.toPath(),
log.info("Updated the link [{}] to point to [{}]", currentVersionFolder.toPath(),
Files.readSymbolicLink(currentVersionFolder.toPath()));
return commitChanges(currentVersion, documentationProject);
}
@@ -212,8 +195,7 @@ class SpringCloudCustomProjectDocumentationUpdater
}
private boolean isMoreMature(String storedVersion, String currentVersion) {
return new ProjectVersion("project", currentVersion)
.isMoreMature(new ProjectVersion("project", storedVersion));
return new ProjectVersion("project", currentVersion).isMoreMature(new ProjectVersion("project", storedVersion));
}
private String branchToReleaseVersion(String branch) {
@@ -223,8 +205,7 @@ class SpringCloudCustomProjectDocumentationUpdater
return branch;
}
private File commitChanges(String currentVersion, File documentationProject)
throws IOException {
private File commitChanges(String currentVersion, File documentationProject) throws IOException {
log.info("Updated the symbolic links");
this.gitHandler.commit(documentationProject,
"Updating the link to the current version to [" + currentVersion + "]");

View File

@@ -26,10 +26,9 @@ import org.springframework.context.annotation.Configuration;
class SpringCloudDocsConfiguration {
@Bean
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(
ProjectGitHandler handler, ReleaserProperties releaserProperties) {
return new SpringCloudCustomProjectDocumentationUpdater(handler,
releaserProperties);
SpringCloudCustomProjectDocumentationUpdater springCloudCustomProjectDocumentationUpdater(ProjectGitHandler handler,
ReleaserProperties releaserProperties) {
return new SpringCloudCustomProjectDocumentationUpdater(handler, releaserProperties);
}
}

View File

@@ -25,8 +25,7 @@ import org.springframework.context.annotation.Configuration;
class SpringCloudGithubConfiguration {
@Bean
SpringCloudGithubIssues springCloudGithubIssues(
ReleaserProperties releaserProperties) {
SpringCloudGithubIssues springCloudGithubIssues(ReleaserProperties releaserProperties) {
return new SpringCloudGithubIssues(releaserProperties);
}

View File

@@ -47,16 +47,14 @@ class SpringCloudGithubIssues implements CustomGithubIssues {
public void fileIssueInSpringGuides(Projects projects, ProjectVersion version) {
String user = "spring-guides";
String repo = "getting-started-guides";
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(),
guidesIssueText(projects));
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(), guidesIssueText(projects));
}
@Override
public void fileIssueInStartSpringIo(Projects projects, ProjectVersion version) {
String user = "spring-io";
String repo = "start.spring.io";
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(),
startSpringIoIssueText(projects));
this.githubIssueFiler.fileAGitHubIssue(user, repo, version, issueTitle(), startSpringIoIssueText(projects));
}
private String issueTitle() {
@@ -72,21 +70,18 @@ class SpringCloudGithubIssues implements CustomGithubIssues {
}
private String startSpringIoIssueText(Projects projects) {
String springBootVersion = projects.containsProject("spring-boot")
? projects.forName("spring-boot").version : "";
return "Release train ["
+ this.properties.getMetaRelease().getReleaseTrainProjectName()
+ "] in version [" + parsedVersion()
+ "] released with the Spring Boot version [`" + springBootVersion + "`]";
String springBootVersion = projects.containsProject("spring-boot") ? projects.forName("spring-boot").version
: "";
return "Release train [" + this.properties.getMetaRelease().getReleaseTrainProjectName() + "] in version ["
+ parsedVersion() + "] released with the Spring Boot version [`" + springBootVersion + "`]";
}
private String guidesIssueText(Projects projects) {
StringBuilder builder = new StringBuilder().append("Release train [")
.append(this.properties.getMetaRelease().getReleaseTrainProjectName())
.append("] in version [").append(parsedVersion())
.append("] released with the following projects:").append("\n\n");
projects.forEach(project -> builder.append(project.projectName).append(" : ")
.append("`").append(project.version).append("`").append("\n"));
.append(this.properties.getMetaRelease().getReleaseTrainProjectName()).append("] in version [")
.append(parsedVersion()).append("] released with the following projects:").append("\n\n");
projects.forEach(project -> builder.append(project.projectName).append(" : ").append("`")
.append(project.version).append("`").append("\n"));
return builder.toString();
}