mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
[release] finer control on which assets get released. Resolves #321
This commit is contained in:
@@ -40,6 +40,9 @@ import static org.jreleaser.util.StringUtils.isNotBlank;
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAware, TimeoutAware {
|
||||
public static final String KEY_SKIP_RELEASE = "skipRelease";
|
||||
public static final String KEY_SKIP_RELEASE_SIGNATURES = "skipReleaseSignatures";
|
||||
|
||||
public static final String TAG_NAME = "TAG_NAME";
|
||||
public static final String RELEASE_NAME = "RELEASE_NAME";
|
||||
public static final String OVERWRITE = "OVERWRITE";
|
||||
@@ -79,6 +82,10 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
private String apiEndpoint;
|
||||
private int connectTimeout;
|
||||
private int readTimeout;
|
||||
private Boolean artifacts;
|
||||
private Boolean files;
|
||||
private Boolean checksums;
|
||||
private Boolean signatures;
|
||||
|
||||
private String cachedTagName;
|
||||
private String cachedReleaseName;
|
||||
@@ -122,6 +129,10 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
this.apiEndpoint = service.apiEndpoint;
|
||||
this.connectTimeout = service.connectTimeout;
|
||||
this.readTimeout = service.readTimeout;
|
||||
this.artifacts = service.artifacts;
|
||||
this.files = service.files;
|
||||
this.checksums = service.checksums;
|
||||
this.signatures = service.signatures;
|
||||
setCommitAuthor(service.commitAuthor);
|
||||
setChangelog(service.changelog);
|
||||
setMilestone(service.milestone);
|
||||
@@ -571,45 +582,97 @@ public abstract class GitService implements Releaser, CommitAuthorAware, OwnerAw
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
public boolean isArtifactsSet() {
|
||||
return artifacts != null;
|
||||
}
|
||||
|
||||
public Boolean isArtifacts() {
|
||||
return artifacts == null || artifacts;
|
||||
}
|
||||
|
||||
public void setArtifacts(Boolean artifacts) {
|
||||
this.artifacts = artifacts;
|
||||
}
|
||||
|
||||
public Boolean isFiles() {
|
||||
return files == null || files;
|
||||
}
|
||||
|
||||
public boolean isFilesSet() {
|
||||
return files != null;
|
||||
}
|
||||
|
||||
public void setFiles(Boolean files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public boolean isChecksumsSet() {
|
||||
return checksums != null;
|
||||
}
|
||||
|
||||
public Boolean isChecksums() {
|
||||
return checksums == null || checksums;
|
||||
}
|
||||
|
||||
public void setChecksums(Boolean checksums) {
|
||||
this.checksums = checksums;
|
||||
}
|
||||
|
||||
public boolean isSignaturesSet() {
|
||||
return signatures != null;
|
||||
}
|
||||
|
||||
public Boolean isSignatures() {
|
||||
return signatures == null || signatures;
|
||||
}
|
||||
|
||||
public void setSignatures(Boolean signatures) {
|
||||
this.signatures = signatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> asMap(boolean full) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("enabled", isEnabled());
|
||||
map.put("host", host);
|
||||
map.put("owner", owner);
|
||||
map.put("name", name);
|
||||
map.put("username", username);
|
||||
map.put("token", isNotBlank(getResolvedToken()) ? Constants.HIDE : Constants.UNSET);
|
||||
Map<String, Object> props = new LinkedHashMap<>();
|
||||
props.put("enabled", isEnabled());
|
||||
props.put("host", host);
|
||||
props.put("owner", owner);
|
||||
props.put("name", name);
|
||||
props.put("username", username);
|
||||
props.put("token", isNotBlank(getResolvedToken()) ? Constants.HIDE : Constants.UNSET);
|
||||
if (releaseSupported) {
|
||||
map.put("repoUrl", repoUrl);
|
||||
map.put("repoCloneUrl", repoCloneUrl);
|
||||
map.put("commitUrl", commitUrl);
|
||||
map.put("downloadUrl", downloadUrl);
|
||||
map.put("releaseNotesUrl", releaseNotesUrl);
|
||||
map.put("latestReleaseUrl", latestReleaseUrl);
|
||||
map.put("issueTrackerUrl", issueTrackerUrl);
|
||||
props.put("artifacts", isArtifacts());
|
||||
props.put("files", isFiles());
|
||||
props.put("checksums", isChecksums());
|
||||
props.put("signatures", isSignatures());
|
||||
props.put("repoUrl", repoUrl);
|
||||
props.put("repoCloneUrl", repoCloneUrl);
|
||||
props.put("commitUrl", commitUrl);
|
||||
props.put("downloadUrl", downloadUrl);
|
||||
props.put("releaseNotesUrl", releaseNotesUrl);
|
||||
props.put("latestReleaseUrl", latestReleaseUrl);
|
||||
props.put("issueTrackerUrl", issueTrackerUrl);
|
||||
}
|
||||
map.put("tagName", tagName);
|
||||
props.put("tagName", tagName);
|
||||
if (releaseSupported) {
|
||||
map.put("releaseName", releaseName);
|
||||
props.put("releaseName", releaseName);
|
||||
}
|
||||
map.put("branch", branch);
|
||||
map.put("commitAuthor", commitAuthor.asMap(full));
|
||||
map.put("sign", sign);
|
||||
map.put("skipTag", isSkipTag());
|
||||
map.put("overwrite", isOverwrite());
|
||||
props.put("branch", branch);
|
||||
props.put("commitAuthor", commitAuthor.asMap(full));
|
||||
props.put("sign", sign);
|
||||
props.put("skipTag", isSkipTag());
|
||||
props.put("overwrite", isOverwrite());
|
||||
if (releaseSupported) {
|
||||
map.put("update", isUpdate());
|
||||
map.put("updateSections", updateSections);
|
||||
map.put("apiEndpoint", apiEndpoint);
|
||||
map.put("connectTimeout", connectTimeout);
|
||||
map.put("readTimeout", readTimeout);
|
||||
props.put("update", isUpdate());
|
||||
props.put("updateSections", updateSections);
|
||||
props.put("apiEndpoint", apiEndpoint);
|
||||
props.put("connectTimeout", connectTimeout);
|
||||
props.put("readTimeout", readTimeout);
|
||||
}
|
||||
map.put("changelog", changelog.asMap(full));
|
||||
props.put("changelog", changelog.asMap(full));
|
||||
if (releaseSupported) {
|
||||
map.put("milestone", milestone.asMap(full));
|
||||
props.put("milestone", milestone.asMap(full));
|
||||
}
|
||||
return map;
|
||||
return props;
|
||||
}
|
||||
|
||||
public Map<String, Object> props(JReleaserModel model) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jreleaser.model.releaser.spi;
|
||||
|
||||
import org.jreleaser.model.Artifact;
|
||||
import org.jreleaser.model.Distribution;
|
||||
import org.jreleaser.model.GitService;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.util.Artifacts;
|
||||
import org.jreleaser.util.Algorithm;
|
||||
@@ -31,6 +32,8 @@ import java.util.List;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.jreleaser.model.Checksum.INDIVIDUAL_CHECKSUM;
|
||||
import static org.jreleaser.model.GitService.KEY_SKIP_RELEASE;
|
||||
import static org.jreleaser.model.GitService.KEY_SKIP_RELEASE_SIGNATURES;
|
||||
import static org.jreleaser.model.Signing.KEY_SKIP_SIGNING;
|
||||
import static org.jreleaser.util.StringUtils.isTrue;
|
||||
|
||||
@@ -76,48 +79,56 @@ public abstract class AbstractReleaserBuilder<R extends Releaser> implements Rel
|
||||
@Override
|
||||
public ReleaserBuilder<R> configureWith(JReleaserContext context) {
|
||||
this.context = context;
|
||||
GitService service = context.getModel().getRelease().getGitService();
|
||||
|
||||
List<Artifact> artifacts = new ArrayList<>();
|
||||
|
||||
for (Artifact artifact : Artifacts.resolveFiles(context)) {
|
||||
if (!artifact.isActive()) continue;
|
||||
Path path = artifact.getEffectivePath(context);
|
||||
artifacts.add(Artifact.of(path, artifact.getExtraProperties()));
|
||||
if (isIndividual(context, artifact)) {
|
||||
for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
|
||||
artifacts.add(Artifact.of(context.getChecksumsDirectory()
|
||||
.resolve(path.getFileName() + "." + algorithm.formatted())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Distribution distribution : context.getModel().getActiveDistributions()) {
|
||||
for (Artifact artifact : distribution.getArtifacts()) {
|
||||
if (!artifact.isActive()) continue;
|
||||
Path path = artifact.getEffectivePath(context, distribution);
|
||||
if (service.isFiles()) {
|
||||
for (Artifact artifact : Artifacts.resolveFiles(context)) {
|
||||
if (!artifact.isActive() || artifact.extraPropertyIsTrue(KEY_SKIP_RELEASE)) continue;
|
||||
Path path = artifact.getEffectivePath(context);
|
||||
artifacts.add(Artifact.of(path, artifact.getExtraProperties()));
|
||||
if (isIndividual(context, distribution, artifact)) {
|
||||
if (service.isChecksums() && isIndividual(context, artifact)) {
|
||||
for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
|
||||
artifacts.add(Artifact.of(context.getChecksumsDirectory()
|
||||
.resolve(distribution.getName())
|
||||
.resolve(path.getFileName() + "." + algorithm.formatted())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
|
||||
Path checksums = context.getChecksumsDirectory()
|
||||
.resolve(context.getModel().getChecksum().getResolvedName(context, algorithm));
|
||||
if (Files.exists(checksums)) {
|
||||
artifacts.add(Artifact.of(checksums));
|
||||
if (service.isArtifacts()) {
|
||||
for (Distribution distribution : context.getModel().getActiveDistributions()) {
|
||||
if (distribution.extraPropertyIsTrue(KEY_SKIP_RELEASE)) continue;
|
||||
for (Artifact artifact : distribution.getArtifacts()) {
|
||||
if (!artifact.isActive() || artifact.extraPropertyIsTrue(KEY_SKIP_RELEASE)) continue;
|
||||
Path path = artifact.getEffectivePath(context, distribution);
|
||||
artifacts.add(Artifact.of(path, artifact.getExtraProperties()));
|
||||
if (service.isChecksums() && isIndividual(context, distribution, artifact)) {
|
||||
for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
|
||||
artifacts.add(Artifact.of(context.getChecksumsDirectory()
|
||||
.resolve(distribution.getName())
|
||||
.resolve(path.getFileName() + "." + algorithm.formatted())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context.getModel().getSigning().isEnabled()) {
|
||||
if (service.isChecksums()) {
|
||||
for (Algorithm algorithm : context.getModel().getChecksum().getAlgorithms()) {
|
||||
Path checksums = context.getChecksumsDirectory()
|
||||
.resolve(context.getModel().getChecksum().getResolvedName(context, algorithm));
|
||||
if (Files.exists(checksums)) {
|
||||
artifacts.add(Artifact.of(checksums));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context.getModel().getSigning().isEnabled() && service.isSignatures()) {
|
||||
List<Artifact> artifactsCopy = new ArrayList<>(artifacts);
|
||||
for (Artifact artifact : artifactsCopy) {
|
||||
if (artifact.extraPropertyIsTrue(KEY_SKIP_SIGNING)) continue;
|
||||
if (artifact.extraPropertyIsTrue(KEY_SKIP_SIGNING) ||
|
||||
artifact.extraPropertyIsTrue(KEY_SKIP_RELEASE_SIGNATURES)) continue;
|
||||
Path signature = context.getSignaturesDirectory()
|
||||
.resolve(artifact.getResolvedPath().getFileName().toString() + (context.getModel().getSigning().isArmored() ? ".asc" : ".sig"));
|
||||
if (Files.exists(signature)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static org.jreleaser.model.GitService.KEY_SKIP_RELEASE_SIGNATURES;
|
||||
import static org.jreleaser.model.validation.BrewValidator.postValidateBrew;
|
||||
import static org.jreleaser.model.validation.BrewValidator.validateBrew;
|
||||
import static org.jreleaser.model.validation.ChocolateyValidator.validateChocolatey;
|
||||
@@ -127,6 +128,11 @@ public abstract class DistributionsValidator extends Validator {
|
||||
for (Artifact artifact : distribution.getArtifacts()) {
|
||||
if (artifact.isActive()) {
|
||||
validateArtifact(context, distribution, artifact, i++, errors);
|
||||
if (distribution.getExtraProperties().containsKey(KEY_SKIP_RELEASE_SIGNATURES) &&
|
||||
!artifact.getExtraProperties().containsKey(KEY_SKIP_RELEASE_SIGNATURES)) {
|
||||
artifact.getExtraProperties().put(KEY_SKIP_RELEASE_SIGNATURES,
|
||||
distribution.getExtraProperties().get(KEY_SKIP_RELEASE_SIGNATURES));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,14 @@ interface GitService extends Releaser {
|
||||
|
||||
Property<Integer> getReadTimeout()
|
||||
|
||||
Property<Boolean> getArtifacts()
|
||||
|
||||
Property<Boolean> getFiles()
|
||||
|
||||
Property<Boolean> getChecksums()
|
||||
|
||||
Property<Boolean> getSignatures()
|
||||
|
||||
Property<Boolean> getOverwrite()
|
||||
|
||||
Property<Boolean> getUpdate()
|
||||
|
||||
@@ -63,6 +63,10 @@ abstract class AbstractGitService implements GitService {
|
||||
final Property<String> apiEndpoint
|
||||
final Property<Integer> connectTimeout
|
||||
final Property<Integer> readTimeout
|
||||
final Property<Boolean> artifacts
|
||||
final Property<Boolean> files
|
||||
final Property<Boolean> checksums
|
||||
final Property<Boolean> signatures
|
||||
final Property<Boolean> overwrite
|
||||
final Property<Boolean> update
|
||||
final SetProperty<UpdateSection> updateSections
|
||||
@@ -91,6 +95,10 @@ abstract class AbstractGitService implements GitService {
|
||||
apiEndpoint = objects.property(String).convention(Providers.notDefined())
|
||||
connectTimeout = objects.property(Integer).convention(Providers.notDefined())
|
||||
readTimeout = objects.property(Integer).convention(Providers.notDefined())
|
||||
artifacts = objects.property(Boolean).convention(Providers.notDefined())
|
||||
files = objects.property(Boolean).convention(Providers.notDefined())
|
||||
checksums = objects.property(Boolean).convention(Providers.notDefined())
|
||||
signatures = objects.property(Boolean).convention(Providers.notDefined())
|
||||
overwrite = objects.property(Boolean).convention(Providers.notDefined())
|
||||
update = objects.property(Boolean).convention(Providers.notDefined())
|
||||
updateSections = objects.setProperty(UpdateSection).convention(Providers.notDefined())
|
||||
@@ -168,6 +176,10 @@ abstract class AbstractGitService implements GitService {
|
||||
apiEndpoint.present ||
|
||||
connectTimeout.present ||
|
||||
readTimeout.present ||
|
||||
artifacts.present ||
|
||||
files.present ||
|
||||
checksums.present ||
|
||||
signatures.present ||
|
||||
overwrite.present ||
|
||||
update.present ||
|
||||
updateSections.present
|
||||
@@ -230,6 +242,10 @@ abstract class AbstractGitService implements GitService {
|
||||
if (apiEndpoint.present) service.apiEndpoint = apiEndpoint.get()
|
||||
if (connectTimeout.present) service.connectTimeout = connectTimeout.get()
|
||||
if (readTimeout.present) service.readTimeout = readTimeout.get()
|
||||
if (artifacts.present) service.artifacts = artifacts.get()
|
||||
if (files.present) service.files = files.get()
|
||||
if (checksums.present) service.checksums = checksums.get()
|
||||
if (signatures.present) service.signatures = signatures.get()
|
||||
service.sign = sign.getOrElse(false)
|
||||
service.skipTag = skipTag.getOrElse(false)
|
||||
service.overwrite = overwrite.getOrElse(false)
|
||||
|
||||
@@ -54,6 +54,10 @@ public abstract class GitService implements Releaser {
|
||||
private String apiEndpoint;
|
||||
private int connectTimeout;
|
||||
private int readTimeout;
|
||||
private Boolean artifacts;
|
||||
private Boolean files;
|
||||
private Boolean checksums;
|
||||
private Boolean signatures;
|
||||
|
||||
void setAll(GitService service) {
|
||||
this.enabled = service.enabled;
|
||||
@@ -79,6 +83,10 @@ public abstract class GitService implements Releaser {
|
||||
this.apiEndpoint = service.apiEndpoint;
|
||||
this.connectTimeout = service.connectTimeout;
|
||||
this.readTimeout = service.readTimeout;
|
||||
this.artifacts = service.artifacts;
|
||||
this.files = service.files;
|
||||
this.checksums = service.checksums;
|
||||
this.signatures = service.signatures;
|
||||
setCommitAuthor(service.commitAuthor);
|
||||
setChangelog(service.changelog);
|
||||
setMilestone(service.milestone);
|
||||
@@ -408,4 +416,52 @@ public abstract class GitService implements Releaser {
|
||||
public void setReadTimeout(int readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
public boolean isArtifactsSet() {
|
||||
return artifacts != null;
|
||||
}
|
||||
|
||||
public Boolean isArtifacts() {
|
||||
return artifacts == null || artifacts;
|
||||
}
|
||||
|
||||
public void setArtifacts(Boolean artifacts) {
|
||||
this.artifacts = artifacts;
|
||||
}
|
||||
|
||||
public Boolean isFiles() {
|
||||
return files == null || files;
|
||||
}
|
||||
|
||||
public boolean isFilesSet() {
|
||||
return files != null;
|
||||
}
|
||||
|
||||
public void setFiles(Boolean files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public boolean isChecksumsSet() {
|
||||
return checksums != null;
|
||||
}
|
||||
|
||||
public Boolean isChecksums() {
|
||||
return checksums == null || checksums;
|
||||
}
|
||||
|
||||
public void setChecksums(Boolean checksums) {
|
||||
this.checksums = checksums;
|
||||
}
|
||||
|
||||
public boolean isSignaturesSet() {
|
||||
return signatures != null;
|
||||
}
|
||||
|
||||
public Boolean isSignatures() {
|
||||
return signatures == null || signatures;
|
||||
}
|
||||
|
||||
public void setSignatures(Boolean signatures) {
|
||||
this.signatures = signatures;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,6 +251,10 @@ public final class JReleaserModelConverter {
|
||||
s.setMilestone(convertMilestone(service.getMilestone()));
|
||||
s.setConnectTimeout(service.getConnectTimeout());
|
||||
s.setReadTimeout(service.getReadTimeout());
|
||||
if (service.isArtifactsSet()) s.setArtifacts(service.isArtifacts());
|
||||
if (service.isFilesSet()) s.setFiles(service.isFiles());
|
||||
if (service.isChecksumsSet()) s.setChecksums(service.isChecksums());
|
||||
if (service.isSignaturesSet()) s.setSignatures(service.isSignatures());
|
||||
}
|
||||
|
||||
private static Set<org.jreleaser.model.UpdateSection> convertUpdateSections(Set<UpdateSection> updateSections) {
|
||||
|
||||
Reference in New Issue
Block a user