mirror of
https://github.com/jlengrand/jreleaser.git
synced 2026-03-10 08:31:24 +00:00
Allow releases without files or distributions
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
package org.jreleaser.cli;
|
||||
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.tools.Checksums;
|
||||
import picocli.CommandLine;
|
||||
|
||||
/**
|
||||
@@ -34,6 +33,6 @@ public class Checksum extends AbstractModelCommand {
|
||||
}
|
||||
|
||||
static void checksum(JReleaserContext context) {
|
||||
Checksums.collectAndWriteChecksums(context);
|
||||
org.jreleaser.checksum.Checksum.collectAndWriteChecksums(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jreleaser.tools;
|
||||
package org.jreleaser.checksum;
|
||||
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.Hashing;
|
||||
@@ -37,7 +37,7 @@ import static org.jreleaser.util.JReleaserLogger.DEBUG_TAB;
|
||||
* @author Andres Almiray
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class Checksums {
|
||||
public class Checksum {
|
||||
public static void collectAndWriteChecksums(JReleaserContext context) throws JReleaserException {
|
||||
context.getLogger().info("Calculating checksums");
|
||||
|
||||
@@ -56,6 +56,11 @@ public class Checksums {
|
||||
}
|
||||
}
|
||||
|
||||
if (checksums.isEmpty()) {
|
||||
context.getLogger().info("No files configured for checksum. Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
Path checksumsFilePath = context.getChecksumsDirectory().resolve("checksums.txt");
|
||||
try {
|
||||
Files.createDirectories(context.getChecksumsDirectory());
|
||||
@@ -73,13 +73,17 @@ public class Signer {
|
||||
public static void sign(JReleaserContext context) throws SigningException {
|
||||
context.getLogger().info("Signing files");
|
||||
if (!context.getModel().getSigning().isEnabled()) {
|
||||
context.getLogger().info("Signing is not enabled");
|
||||
context.getLogger().info("Signing is not enabled. Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Path> paths = collectArtifactsForSigning(context);
|
||||
if (paths.isEmpty()) {
|
||||
context.getLogger().info("No files configured for signing. Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
InMemoryKeyring keyring = createInMemoryKeyring(context.getModel().getSigning());
|
||||
|
||||
List<Path> paths = collectArtifactsForSigning(context);
|
||||
List<FilePair> files = sign(context, keyring, paths);
|
||||
verify(context, keyring, files);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jreleaser.tools;
|
||||
|
||||
import org.jreleaser.checksum.Checksum;
|
||||
import org.jreleaser.model.Artifact;
|
||||
import org.jreleaser.model.Distribution;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
@@ -72,7 +73,7 @@ public class DistributionProcessor {
|
||||
context.getLogger().debug("Reading checksums for {} distribution", distributionName);
|
||||
for (int i = 0; i < distribution.getArtifacts().size(); i++) {
|
||||
Artifact artifact = distribution.getArtifacts().get(i);
|
||||
Checksums.readHash(context, distributionName, artifact);
|
||||
Checksum.readHash(context, distributionName, artifact);
|
||||
}
|
||||
|
||||
return ToolProcessors.findProcessor(context, tool)
|
||||
|
||||
@@ -32,6 +32,11 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class Distributions {
|
||||
public static void process(JReleaserContext context, boolean failFast, String action, ToolProcessingFunction function) {
|
||||
if (context.getModel().getDistributions().isEmpty()) {
|
||||
context.getLogger().debug("No configured distributions [" + action.toLowerCase() + "]. Skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
context.getLogger().info("{} distributions", action);
|
||||
List<Exception> exceptions = new ArrayList<>();
|
||||
for (Distribution distribution : context.getModel().getDistributions().values()) {
|
||||
|
||||
@@ -411,11 +411,6 @@ public final class JReleaserModelValidator {
|
||||
private static void validateDistributions(JReleaserContext context, List<String> errors) {
|
||||
Map<String, Distribution> distributions = context.getModel().getDistributions();
|
||||
|
||||
if (distributions.isEmpty()) {
|
||||
errors.add("Missing distributions configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
if (distributions.size() == 1) {
|
||||
distributions.values().stream()
|
||||
.findFirst().ifPresent(distribution -> distribution.setName(context.getModel().getProject().getName()));
|
||||
|
||||
@@ -70,9 +70,6 @@ public abstract class AbstractReleaserBuilder<R extends Releaser, B extends Rele
|
||||
|
||||
protected void validate() {
|
||||
requireNonNull(context, "'context' must not be null");
|
||||
if (assets.isEmpty()) {
|
||||
throw new IllegalArgumentException("'assets must not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package org.jreleaser.ant.tasks;
|
||||
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.tools.Checksums;
|
||||
import org.jreleaser.checksum.Checksum;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
@@ -31,6 +31,6 @@ public class JReleaserChecksumTask extends AbstractJReleaserTask {
|
||||
}
|
||||
|
||||
static void checksum(JReleaserContext context) {
|
||||
Checksums.collectAndWriteChecksums(context);
|
||||
Checksum.collectAndWriteChecksums(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import groovy.transform.CompileStatic
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jreleaser.model.JReleaserContext
|
||||
import org.jreleaser.tools.Checksums
|
||||
import org.jreleaser.checksum.Checksum
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -43,6 +43,6 @@ abstract class JReleaserChecksumTask extends AbstractJReleaserTask {
|
||||
}
|
||||
|
||||
static void checksum(JReleaserContext context) {
|
||||
Checksums.collectAndWriteChecksums(context)
|
||||
Checksum.collectAndWriteChecksums(context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.jreleaser.model.JReleaserContext;
|
||||
import org.jreleaser.model.JReleaserException;
|
||||
import org.jreleaser.tools.Checksums;
|
||||
import org.jreleaser.checksum.Checksum;
|
||||
|
||||
/**
|
||||
* @author Andres Almiray
|
||||
@@ -47,7 +47,7 @@ public class JReleaserChecksumMojo extends AbstractJReleaserMojo {
|
||||
|
||||
static void checksum(JReleaserContext context) throws MojoExecutionException {
|
||||
try {
|
||||
Checksums.collectAndWriteChecksums(context);
|
||||
Checksum.collectAndWriteChecksums(context);
|
||||
} catch (JReleaserException e) {
|
||||
throw new MojoExecutionException("Unexpected error writing checksums", e);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.kohsuke.github.GitHub;
|
||||
import org.kohsuke.github.GitHubBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
@@ -108,8 +109,8 @@ class Github {
|
||||
|
||||
void uploadAssets(GHRelease release, List<Path> assets) throws IOException {
|
||||
for (Path asset : assets) {
|
||||
if (0 == asset.toFile().length()) {
|
||||
// do not upload empty files
|
||||
if (0 == asset.toFile().length() || !Files.exists(asset)) {
|
||||
// do not upload empty or non existent files
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.kohsuke.github.GHRelease;
|
||||
import org.kohsuke.github.GHRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -108,8 +109,8 @@ public class GithubReleaser implements Releaser {
|
||||
|
||||
if (context.isDryrun()) {
|
||||
for (Path asset : assets) {
|
||||
if (0 == asset.toFile().length()) {
|
||||
// do not upload empty files
|
||||
if (0 == asset.toFile().length() || !Files.exists(asset)) {
|
||||
// do not upload empty or non existent files
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user