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