com.exasol.projectkeeper.github.GitHubWorkflowOutput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of project-keeper-core Show documentation
Show all versions of project-keeper-core Show documentation
Project keeper is a tool that verifies and fixes project setups.
The newest version!
package com.exasol.projectkeeper.github;
import static com.exasol.projectkeeper.shared.config.SourceType.GOLANG;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.joining;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Stream;
import com.exasol.projectkeeper.shared.config.ProjectKeeperConfig;
import com.exasol.projectkeeper.shared.config.Source;
import com.exasol.projectkeeper.sources.AnalyzedMavenSource;
import com.exasol.projectkeeper.sources.AnalyzedSource;
import com.exasol.projectkeeper.validators.changesfile.*;
/**
* This class writes output parameters to the file referenced by environment variable {@code GITHUB_OUTPUT} if it is
* defined. If the variable is not defined, this will log the output parameters.
*/
// [impl->dsn~verify-modes.output-parameters~1]
public class GitHubWorkflowOutput {
@SuppressWarnings("unused") // Will be used soon
private final ProjectKeeperConfig config;
private final Path projectDir;
private final String projectVersion;
private final List analyzedSources;
private final OutputPublisherFactory publisherFactory;
private final ChangesFileIO changesFileIO;
GitHubWorkflowOutput(final ProjectKeeperConfig config, final Path projectDir, final String projectVersion,
final List analyzedSources, final OutputPublisherFactory publisherFactory,
final ChangesFileIO changesFileIO) {
this.config = config;
this.projectDir = projectDir;
this.projectVersion = projectVersion;
this.analyzedSources = analyzedSources;
this.publisherFactory = publisherFactory;
this.changesFileIO = changesFileIO;
}
/**
* Create a new publisher.
*
* @param config Project Keeper configuration
* @param projectDir project directory
* @param projectVersion project version
* @param analyzedSources analyzed sources
* @return a new publisher
*/
public static GitHubWorkflowOutput create(final ProjectKeeperConfig config, final Path projectDir,
final String projectVersion, final List analyzedSources) {
return new GitHubWorkflowOutput(config, projectDir, projectVersion, analyzedSources,
new OutputPublisherFactory(System.getenv()), new ChangesFileIO());
}
/**
* Publish all values.
*/
public void provide() {
final Optional changesFile = readChangesFile();
try (WorkflowOutput publisher = this.publisherFactory.create()) {
// [impl->dsn~verify-release-mode.output-parameters.release-tag~1]
publisher.publish("release-tag", getReleaseTag());
// [impl->dsn~release-workflow.create-golang-tags~1]
publisher.publish("additional-release-tags", getAdditionalReleaseTags());
if (changesFile.isPresent()) {
// [impl->dsn~verify-release-mode.output-parameters.release-title~1]
publisher.publish("release-title", this.projectVersion + " " + changesFile.get().getCodeName());
// [impl->dsn~verify-release-mode.output-parameters.release-notes~1]
publisher.publish("release-notes", extractReleaseNotes(changesFile.get()));
}
// [impl->dsn~verify-release-mode.output-parameters.release-artifacts~1]
publisher.publish("release-artifacts", getReleaseArtifacts());
}
}
private String getReleaseTag() {
final String prefix = hasRootGoModule() ? "v" : "";
return prefix + this.projectVersion;
}
private boolean hasRootGoModule() {
return goModules().anyMatch(Source::isRoot);
}
private Stream
© 2015 - 2025 Weber Informatics LLC | Privacy Policy