Create tasks to create release bundles
This commit is contained in:
14
pom.xml
14
pom.xml
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<version>4.0.6</version>
|
||||
<relativePath/>
|
||||
<!-- lookup parent from repository -->
|
||||
</parent>
|
||||
@@ -47,6 +47,8 @@
|
||||
<fliptables.version>1.1.0</fliptables.version>
|
||||
<zt.exec.version>1.12</zt.exec.version>
|
||||
<okhttp.version>4.11.0</okhttp.version>
|
||||
<artifactory-client.version>2.17.0</artifactory-client.version>
|
||||
<groovy.version>4.0.6</groovy.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -145,6 +147,16 @@
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>${awaitility.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jfrog.artifactory.client</groupId>
|
||||
<artifactId>artifactory-java-client-services</artifactId>
|
||||
<version>${artifactory-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
<version>${groovy.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -113,3 +113,58 @@ releaser:
|
||||
projects-to-skip:
|
||||
- spring-boot
|
||||
- spring-cloud-stream
|
||||
bundles:
|
||||
repos:
|
||||
spring-cloud-build:
|
||||
- "org/springframework/cloud/spring-cloud-build*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-build*"
|
||||
- "org/springframework/cloud/spring-cloud-dependencies-parent*"
|
||||
spring-cloud-config:
|
||||
- "org/springframework/cloud/spring-cloud-config*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-config*"
|
||||
spring-cloud-function:
|
||||
- "org/springframework/cloud/spring-cloud-function*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-function*"
|
||||
spring-cloud-stream:
|
||||
- "org/springframework/cloud/spring-cloud-stream*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-stream*"
|
||||
spring-cloud-task:
|
||||
- "org/springframework/cloud/spring-cloud-task*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-task*"
|
||||
spring-cloud-bus:
|
||||
- "org/springframework/cloud/spring-cloud-bus*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-bus*"
|
||||
spring-cloud-commons:
|
||||
- "org/springframework/cloud/spring-cloud-commons*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-commons*"
|
||||
spring-cloud-netflix:
|
||||
- "org/springframework/cloud/spring-cloud-netflix*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-netflix*"
|
||||
spring-cloud-openfeign:
|
||||
- "org/springframework/cloud/spring-cloud-openfeign*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-openfeign*"
|
||||
spring-cloud-consul:
|
||||
- "org/springframework/cloud/spring-cloud-consul*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-consul*"
|
||||
spring-cloud-circuitbreaker:
|
||||
- "org/springframework/cloud/spring-cloud-circuitbreaker*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-circuitbreaker*"
|
||||
spring-cloud-gateway:
|
||||
- "org/springframework/cloud/spring-cloud-gateway*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-gateway*"
|
||||
spring-cloud-zookeeper:
|
||||
- "org/springframework/cloud/spring-cloud-zookeeper*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-zookeeper*"
|
||||
spring-cloud-contract:
|
||||
- "org/springframework/cloud/spring-cloud-contract*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-contract*"
|
||||
spring-cloud-kubernetes:
|
||||
- "org/springframework/cloud/spring-cloud-kubernetes*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-kubernetes*"
|
||||
spring-cloud-vault:
|
||||
- "org/springframework/cloud/spring-cloud-vault*"
|
||||
- "org/springframework/cloud/spring-cloud-starter-vault*"
|
||||
# This is Spring Cloud Release, the POM id is spring-cloud-starter-build
|
||||
spring-cloud-starter-build:
|
||||
- "org/springframework/cloud/spring-cloud-starter*"
|
||||
- "org/springframework/cloud/spring-cloud-dependencies*"
|
||||
|
||||
@@ -91,6 +91,14 @@
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
<artifactId>initializr-metadata</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jfrog.artifactory.client</groupId>
|
||||
<artifactId>artifactory-java-client-services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -18,11 +18,13 @@ package releaser.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import releaser.internal.buildsystem.GradleUpdater;
|
||||
import releaser.internal.buildsystem.ProjectPomUpdater;
|
||||
import releaser.internal.commercial.ReleaseBundleCreator;
|
||||
import releaser.internal.docs.DocumentationUpdater;
|
||||
import releaser.internal.git.ProjectGitHandler;
|
||||
import releaser.internal.github.ProjectGitHubHandler;
|
||||
@@ -69,11 +71,13 @@ public class Releaser {
|
||||
|
||||
private ReleaserProperties releaserProperties;
|
||||
|
||||
private ReleaseBundleCreator releaseBundleCreator;
|
||||
|
||||
public Releaser(ReleaserProperties releaserProperties, ProjectPomUpdater projectPomUpdater,
|
||||
ProjectCommandExecutor projectCommandExecutor, ProjectGitHandler projectGitHandler,
|
||||
ProjectGitHubHandler projectGitHubHandler, TemplateGenerator templateGenerator, GradleUpdater gradleUpdater,
|
||||
SaganUpdater saganUpdater, DocumentationUpdater documentationUpdater,
|
||||
PostReleaseActions postReleaseActions) {
|
||||
SaganUpdater saganUpdater, DocumentationUpdater documentationUpdater, PostReleaseActions postReleaseActions,
|
||||
ReleaseBundleCreator releaseBundleCreator) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
this.projectPomUpdater = projectPomUpdater;
|
||||
this.projectCommandExecutor = projectCommandExecutor;
|
||||
@@ -84,6 +88,7 @@ public class Releaser {
|
||||
this.saganUpdater = saganUpdater;
|
||||
this.documentationUpdater = documentationUpdater;
|
||||
this.postReleaseActions = postReleaseActions;
|
||||
this.releaseBundleCreator = releaseBundleCreator;
|
||||
}
|
||||
|
||||
public File clonedProjectFromOrg(String projectName) {
|
||||
@@ -377,4 +382,41 @@ public class Releaser {
|
||||
return ExecutionResult.skipped();
|
||||
}
|
||||
|
||||
public ExecutionResult createReleaseBundle(boolean commercial, ProjectVersion versionFromBom, Boolean dryRun,
|
||||
Map<String, List<String>> commercialRepos, String projectName) {
|
||||
if (dryRun) {
|
||||
log.info("\nWon't create a release bundle for a dry run");
|
||||
return ExecutionResult.skipped();
|
||||
}
|
||||
if (versionFromBom.isSnapshot()) {
|
||||
log.info("\nWon't create a release bundle for a SNAPSHOT version");
|
||||
return ExecutionResult.skipped();
|
||||
}
|
||||
if (!commercial) {
|
||||
log.info("\nWon't create a release bundle for a non commercial project");
|
||||
return ExecutionResult.skipped();
|
||||
}
|
||||
log.info("\nCreating a release bundle");
|
||||
if (!commercialRepos.containsKey(projectName)) {
|
||||
log.warn("No commercial repos configured for project [{}], double check releaser.bundles.repos",
|
||||
projectName);
|
||||
}
|
||||
List<String> repos = commercialRepos.get(projectName);
|
||||
log.info("Creating release bundles for project [{}] in repos [{}]", projectName, repos);
|
||||
try {
|
||||
boolean result = this.releaseBundleCreator.createReleaseBundle(repos, versionFromBom.version,
|
||||
"TNZ-" + projectName + "-commercial");
|
||||
if (!result) {
|
||||
log.warn("Failed to create release bundle");
|
||||
return ExecutionResult.unstable(new BuildUnstableException("Failed to create a release bundle"));
|
||||
}
|
||||
log.info("\nSuccessfully created a release bundle");
|
||||
return ExecutionResult.success();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Failed to create a release bundle", ex);
|
||||
return ExecutionResult.unstable(new BuildUnstableException("Failed to create a release bundle", ex));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ public class ReleaserProperties implements Serializable {
|
||||
|
||||
private boolean commercial = false;
|
||||
|
||||
private Bundles bundles = new Bundles();
|
||||
|
||||
/**
|
||||
* Project name to its version - overrides all versions retrieved from a release train
|
||||
* repository like Spring Cloud Release.
|
||||
@@ -208,6 +210,14 @@ public class ReleaserProperties implements Serializable {
|
||||
this.commercial = commercial;
|
||||
}
|
||||
|
||||
public Bundles getBundles() {
|
||||
return bundles;
|
||||
}
|
||||
|
||||
public void setBundles(Bundles bundles) {
|
||||
this.bundles = bundles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git=" + this.git + ", pom="
|
||||
@@ -1563,4 +1573,68 @@ public class ReleaserProperties implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
public static class Bundles implements Serializable {
|
||||
|
||||
private boolean createProjectReleaseBundle = false;
|
||||
|
||||
private boolean createReleaseTrainReleaseBundle = false;
|
||||
|
||||
private String repoUrl = "https://usw1.packages.broadcom.com";
|
||||
|
||||
private String repoUsername;
|
||||
|
||||
private String repoAccessToken;
|
||||
|
||||
private Map<String, List<String>> repos;
|
||||
|
||||
public boolean isCreateProjectReleaseBundle() {
|
||||
return createProjectReleaseBundle;
|
||||
}
|
||||
|
||||
public void setCreateProjectReleaseBundle(boolean createProjectReleaseBundle) {
|
||||
this.createProjectReleaseBundle = createProjectReleaseBundle;
|
||||
}
|
||||
|
||||
public boolean isCreateReleaseTrainReleaseBundle() {
|
||||
return createReleaseTrainReleaseBundle;
|
||||
}
|
||||
|
||||
public void setCreateReleaseTrainReleaseBundle(boolean createReleaseTrainReleaseBundle) {
|
||||
this.createReleaseTrainReleaseBundle = createReleaseTrainReleaseBundle;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getRepos() {
|
||||
return repos;
|
||||
}
|
||||
|
||||
public void setRepos(Map<String, List<String>> repos) {
|
||||
this.repos = repos;
|
||||
}
|
||||
|
||||
public String getRepoUrl() {
|
||||
return repoUrl;
|
||||
}
|
||||
|
||||
public void setRepoUrl(String repoUrl) {
|
||||
this.repoUrl = repoUrl;
|
||||
}
|
||||
|
||||
public String getRepoUsername() {
|
||||
return repoUsername;
|
||||
}
|
||||
|
||||
public void setRepoUsername(String repoUsername) {
|
||||
this.repoUsername = repoUsername;
|
||||
}
|
||||
|
||||
public String getRepoAccessToken() {
|
||||
return repoAccessToken;
|
||||
}
|
||||
|
||||
public void setRepoAccessToken(String repoAccessToken) {
|
||||
this.repoAccessToken = repoAccessToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package releaser.internal.commercial;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.jfrog.artifactory.client.Artifactory;
|
||||
import org.jfrog.artifactory.client.ArtifactoryClientBuilder;
|
||||
import org.jfrog.artifactory.client.ArtifactoryRequest;
|
||||
import org.jfrog.artifactory.client.ArtifactoryResponse;
|
||||
import org.jfrog.artifactory.client.aql.AqlItem;
|
||||
import org.jfrog.artifactory.client.aql.AqlQueryBuilder;
|
||||
import org.jfrog.artifactory.client.impl.ArtifactoryRequestImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import releaser.internal.ReleaserProperties;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
public class ReleaseBundleCreator {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ReleaseBundleCreator.class);
|
||||
|
||||
private Artifactory artifactory;
|
||||
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
public ReleaseBundleCreator(ReleaserProperties properties) {
|
||||
log.info("Creating Artifactory client with URL [{}]", properties.getBundles().getRepoUrl());
|
||||
log.info("Creating Artifactory client with username [{}]", properties.getBundles().getRepoUsername());
|
||||
log.info("Creating Artifactory client with access token [{}]", properties.getBundles().getRepoAccessToken());
|
||||
this.artifactory = ArtifactoryClientBuilder.create().setUrl(properties.getBundles().getRepoUrl())
|
||||
.setUsername(properties.getBundles().getRepoUsername())
|
||||
.setAccessToken(properties.getBundles().getRepoAccessToken()).build();
|
||||
this.objectMapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
public boolean createReleaseBundle(List<String> repos, String version, String releaseBundleName) throws IOException {
|
||||
Map<String, Object> json = new HashMap<>();
|
||||
json.put("release_bundle_name", releaseBundleName);
|
||||
json.put("release_bundle_version", version);
|
||||
json.put( "source_type", "aql");
|
||||
json.put("source", createAqlMap(repos, version));
|
||||
return createReleaseBundle(objectMapper.writeValueAsString(json));
|
||||
}
|
||||
|
||||
private Map<String, Object> createAqlMap(List<String> repos, String version) {
|
||||
String aql = createAql(repos, version);
|
||||
Map<String, Object> aqlObject = new HashMap<>();
|
||||
aqlObject.put("aql", aql);
|
||||
return aqlObject;
|
||||
}
|
||||
|
||||
private String createAql(List<String> repos, String version) {
|
||||
AqlQueryBuilder builder = new AqlQueryBuilder()
|
||||
.item(AqlItem.aqlItem("repo", AqlItem.aqlItem("$eq", "spring-enterprise-maven-prod-local")));
|
||||
|
||||
AqlItem[] items = new AqlItem[repos.size()];
|
||||
for (String repo : repos) {
|
||||
items[repos.indexOf(repo)] = AqlItem.match("path", repo + "/" + version);
|
||||
}
|
||||
return builder.or(items).asc("path", "name").build();
|
||||
}
|
||||
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
log.info("Creating release bundle with JSON [{}]", json);
|
||||
|
||||
ArtifactoryRequest aqlRequest = new ArtifactoryRequestImpl().method(ArtifactoryRequest.Method.POST)
|
||||
.apiUrl("lifecycle/api/v2/release_bundle").addQueryParam("project", "spring")
|
||||
.addHeader("X-JFrog-Signing-Key-Name", "packagesKey").requestType(ArtifactoryRequest.ContentType.JSON)
|
||||
.responseType(ArtifactoryRequest.ContentType.JSON).requestBody(json);
|
||||
ArtifactoryResponse response = artifactory.restCall(aqlRequest);
|
||||
if (!response.isSuccessResponse()) {
|
||||
log.warn("Failed to create release bundle {}", response.getRawBody());
|
||||
return false;
|
||||
}
|
||||
log.info("Created release bundle {}", response.getRawBody());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package releaser.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.function.Supplier;
|
||||
@@ -31,6 +32,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import releaser.SpringCloudReleaserProperties;
|
||||
import releaser.internal.buildsystem.GradleUpdater;
|
||||
import releaser.internal.buildsystem.ProjectPomUpdater;
|
||||
import releaser.internal.commercial.ReleaseBundleCreator;
|
||||
import releaser.internal.docs.DocumentationUpdater;
|
||||
import releaser.internal.git.ProjectGitHandler;
|
||||
import releaser.internal.github.ProjectGitHubHandler;
|
||||
@@ -92,7 +94,13 @@ public class ReleaserTests {
|
||||
Releaser releaser(Supplier<ProjectVersion> originalVersionSupplier) {
|
||||
return new Releaser(SpringCloudReleaserProperties.get(), this.projectPomUpdater, this.projectCommandExecutor,
|
||||
this.projectGitHandler, this.projectGitHubHandler, this.templateGenerator, this.gradleUpdater,
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions) {
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions,
|
||||
new ReleaseBundleCreator(SpringCloudReleaserProperties.get()) {
|
||||
@Override
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
return true;
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
ProjectVersion originalVersion(File project) {
|
||||
return originalVersionSupplier.get();
|
||||
@@ -103,7 +111,13 @@ public class ReleaserTests {
|
||||
Releaser releaser() {
|
||||
return new Releaser(new ReleaserProperties(), this.projectPomUpdater, this.projectCommandExecutor,
|
||||
this.projectGitHandler, this.projectGitHubHandler, this.templateGenerator, this.gradleUpdater,
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions);
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions,
|
||||
new ReleaseBundleCreator(SpringCloudReleaserProperties.get()) {
|
||||
@Override
|
||||
public boolean createReleaseBundle(String json) throws IOException {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,7 @@ import releaser.internal.ReleaserProperties;
|
||||
import releaser.internal.ReleaserPropertiesUpdater;
|
||||
import releaser.internal.buildsystem.GradleUpdater;
|
||||
import releaser.internal.buildsystem.ProjectPomUpdater;
|
||||
import releaser.internal.commercial.ReleaseBundleCreator;
|
||||
import releaser.internal.docs.CustomProjectDocumentationUpdater;
|
||||
import releaser.internal.docs.DocumentationUpdater;
|
||||
import releaser.internal.git.ProjectGitHandler;
|
||||
@@ -154,10 +155,10 @@ class ReleaserConfiguration {
|
||||
ProjectGitHandler projectGitHandler, ProjectGitHubHandler projectGitHubHandler,
|
||||
TemplateGenerator templateGenerator, GradleUpdater gradleUpdater, SaganUpdater saganUpdater,
|
||||
DocumentationUpdater documentationUpdater, PostReleaseActions postReleaseActions,
|
||||
ReleaserProperties releaserProperties) {
|
||||
ReleaserProperties releaserProperties, ReleaseBundleCreator releaseBundleCreator) {
|
||||
return new Releaser(releaserProperties, projectPomUpdater, projectCommandExecutor, projectGitHandler,
|
||||
projectGitHubHandler, templateGenerator, gradleUpdater, saganUpdater, documentationUpdater,
|
||||
postReleaseActions);
|
||||
postReleaseActions, releaseBundleCreator);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -173,4 +174,10 @@ class ReleaserConfiguration {
|
||||
return new OptionsParser(allTasks, singleProjectReleaserTasks, context);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
ReleaseBundleCreator releaseBundleCreator(ReleaserProperties properties) {
|
||||
return new ReleaseBundleCreator(properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -211,7 +211,9 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
|
||||
@Override
|
||||
public ExecutionResult runReleaseTasks(Options options, ReleaserProperties properties, ProjectsToRun projectsToRun,
|
||||
TasksToRun tasksToRun) {
|
||||
if (properties.isPostReleaseTasksOnly() && options.metaRelease) {
|
||||
// TODO this seems to not be exclusive to meta releases
|
||||
if (properties.isPostReleaseTasksOnly()/** && options.metaRelease */
|
||||
) {
|
||||
log.info("Only post release tasks will be executed for the meta release");
|
||||
return ExecutionResult.skipped();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package releaser.internal.tasks.postrelease;
|
||||
|
||||
import releaser.internal.Releaser;
|
||||
import releaser.internal.project.ProjectVersion;
|
||||
import releaser.internal.spring.Arguments;
|
||||
import releaser.internal.tasks.ProjectPostReleaseReleaserTask;
|
||||
import releaser.internal.tech.BuildUnstableException;
|
||||
import releaser.internal.tech.ExecutionResult;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
public class CreateProjectReleaseBundlePostReleaseTask implements ProjectPostReleaseReleaserTask {
|
||||
|
||||
/**
|
||||
* Order of this task. The higher value, the lower order.
|
||||
*/
|
||||
public static final int ORDER = 60;
|
||||
|
||||
private final Releaser releaser;
|
||||
|
||||
public CreateProjectReleaseBundlePostReleaseTask(Releaser releaser) {
|
||||
this.releaser = releaser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "createReleaseBundle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortName() {
|
||||
return "b";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String header() {
|
||||
return "CREATING RELEASE BUNDLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Creates a release bundle for the project";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
return this.releaser.createReleaseBundle(args.properties.isCommercial(), args.versionFromBom,
|
||||
args.options.dryRun, args.properties.getBundles().getRepos(),
|
||||
new ProjectVersion(args.project).projectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return ORDER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2013-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package releaser.internal.tasks.postrelease;
|
||||
|
||||
import releaser.internal.Releaser;
|
||||
import releaser.internal.project.ProjectVersion;
|
||||
import releaser.internal.spring.Arguments;
|
||||
import releaser.internal.tasks.TrainPostReleaseReleaserTask;
|
||||
import releaser.internal.tech.BuildUnstableException;
|
||||
import releaser.internal.tech.ExecutionResult;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
public class CreateReleaseTrainReleaseBundlePostReleaseTask implements TrainPostReleaseReleaserTask {
|
||||
|
||||
/**
|
||||
* Order of this task. The higher value, the lower order.
|
||||
*/
|
||||
public static final int ORDER = 160;
|
||||
|
||||
private final Releaser releaser;
|
||||
|
||||
public CreateReleaseTrainReleaseBundlePostReleaseTask(Releaser releaser) {
|
||||
this.releaser = releaser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "createReleaseTrainReleaseBundlePostReleaseTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortName() {
|
||||
return "rtb";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String header() {
|
||||
return "CREATE RELEASE TRAIN RELEASE BUNDLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Creates a release train release bundle";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult runTask(Arguments args) throws BuildUnstableException, RuntimeException {
|
||||
return releaser.createReleaseBundle(args.properties.isCommercial(), args.versionFromBom, args.options.dryRun,
|
||||
args.properties.getBundles().getRepos(), new ProjectVersion(args.project).projectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return ORDER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,4 +92,18 @@ class PostReleaseTasksConfiguration {
|
||||
return new UpdateStartSpringIoTrainPostReleaseTask(releaser);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty("releaser.bundles.create-release-train-release-bundle")
|
||||
CreateReleaseTrainReleaseBundlePostReleaseTask createReleaseTrainReleaseBundlePostReleaseTask(Releaser releaser) {
|
||||
return new CreateReleaseTrainReleaseBundlePostReleaseTask(releaser);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty("releaser.bundles.create-project-release-bundle")
|
||||
CreateProjectReleaseBundlePostReleaseTask createProjectReleaseBundlePostReleaseTask(Releaser releaser) {
|
||||
return new CreateProjectReleaseBundlePostReleaseTask(releaser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user