Skip to content

Commit

Permalink
Add error message for missing release notes
Browse files Browse the repository at this point in the history
Closes gh-6
  • Loading branch information
sjohnr committed Jan 2, 2024
1 parent 6c73bfe commit e812de6
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-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.
Expand Down Expand Up @@ -43,15 +43,16 @@ public abstract class CreateGitHubReleaseTask extends DefaultTask {
@Input
public abstract Property<String> getVersion();

@Input
public abstract Property<String> getReleaseNotes();

@Input
public abstract Property<String> getBranch();

@Input
public abstract Property<Boolean> getCreateRelease();

@Input
@Optional
public abstract Property<String> getReleaseNotes();

@Input
@Optional
public abstract Property<String> getVersionPrefix();
Expand All @@ -67,12 +68,21 @@ public void createGitHubRelease() {
var version = getVersion().get();
var versionPrefix = getVersionPrefix().getOrElse("");
var branch = getBranch().get();
var body = getReleaseNotes().get();

var createRelease = getCreateRelease().get();
if (createRelease && gitHubAccessToken == null) {
throw new MissingPropertyException("Please provide an access token with -PgitHubAccessToken=...");
}

var body = getReleaseNotes().getOrNull();
if (body == null) {
// @formatter:off
throw new MissingPropertyException(("Nothing was generated by the release-notes-generator, " +
"perhaps because no issues were available in release milestone %s. " +
"Please ensure there is at least one issue in the release.").formatted(version));
// @formatter:on
}

System.out.printf("%sCreating GitHub release for %s/%s@%s%s%n", createRelease ? "" : "[DRY RUN] ",
repository.owner(), repository.name(), versionPrefix, version);
System.out.printf("%nRelease Notes:%n%n----%n%s%n----%n%n", body.trim());
Expand Down

0 comments on commit e812de6

Please sign in to comment.