Skip to content

Commit

Permalink
Merge pull request #61 from shestee/tagging-bug
Browse files Browse the repository at this point in the history
Add 'newTagRevision' property to fix tagging problem
  • Loading branch information
mockitoguy authored Dec 21, 2020
2 parents 07b04fa + 64ef115 commit 528a4a1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ tasks.named("githubRelease") {
dependsOn tasks.named("generateChangelog")
repository = "shipkit/shipkit-changelog"
changelog = tasks.named("generateChangelog").get().outputFile
// After publishing new version of the plugin remove comment on 'newTagRevision' below:
// newTagRevision = System.getenv("GITHUB_SHA")
writeToken = System.getenv("GITHUB_TOKEN")
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GitHubReleasePluginIntegTest extends BaseSpecification {
tasks.named("githubRelease") {
repository = "shipkit/shipkit-changelog"
changelog = file("changelog.md")
newTagRevision = "ff2fb22b3bb2fb08164c126c0e2055d57dee441b"
writeToken = "secret"
}
"""
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/shipkit/gh/release/GitHubReleaseTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class GitHubReleaseTask extends DefaultTask {
private String releaseTag = null;
private File changelog = null;
private String writeToken = null;
private String newTagRevision = null;

@Input
public String getGhApiUrl() {
Expand Down Expand Up @@ -80,12 +81,30 @@ public void setWriteToken(String writeToken) {
this.writeToken = writeToken;
}

/**
* See {@link #setNewTagRevision(String)}
*/
@Input
public String getNewTagRevision() {
return newTagRevision;
}

/**
* Property required to specify revision for the new tag.
* The property's value is passed to GitHub API's
* 'target_commitish' parameter in {@link #postRelease()} method.
*/
public void setNewTagRevision(String newTagRevision) {
this.newTagRevision = newTagRevision;
}

@TaskAction public void postRelease() {
String url = ghApiUrl + "/repos/" + repository + "/releases";

JsonObject body = new JsonObject();
body.add("tag_name", releaseTag);
body.add("name", releaseName);
body.add("target_commitish", newTagRevision);
String releaseNotesTxt = IOUtil.readFully(changelog);
body.add("body", releaseNotesTxt);

Expand Down

0 comments on commit 528a4a1

Please sign in to comment.