From baf5b6fe56e1a4fa4797662bfb1d872907e6f56e Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 3 Nov 2024 20:37:20 +0000 Subject: [PATCH 1/2] [FIX] Find draft GitHub releases using tag Draft releases are not found at the `releases/tags/` endpoint, but are still associated with the tag name. If we can't find a release at `releases/tags/`, then we iterate through all releases looking for one with a matching tag name. --- .../modpublisher/tasks/GithubUploadTask.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hypherionmc/modpublisher/tasks/GithubUploadTask.java b/src/main/java/com/hypherionmc/modpublisher/tasks/GithubUploadTask.java index 538b4ee..9ae32d4 100644 --- a/src/main/java/com/hypherionmc/modpublisher/tasks/GithubUploadTask.java +++ b/src/main/java/com/hypherionmc/modpublisher/tasks/GithubUploadTask.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; @@ -95,7 +96,7 @@ public void upload() throws Exception { // Try to find an existing release. // If one is found, the file will be added onto it. - GHRelease ghRelease = ghRepository.getReleaseByTagName(tag); + GHRelease ghRelease = getRelease(ghRepository, tag); UploadPreChecks.checkEmptyJar(extension, uploadFile, extension.getLoaders().get()); @@ -175,6 +176,24 @@ public void upload() throws Exception { ); } + private static GHRelease getRelease(GHRepository repo, String tag) throws IOException { + // First, attempt to get the tag using the releases/tags/ endpoint + GHRelease attempt1 = repo.getReleaseByTagName(tag); + if (attempt1 != null) { + return attempt1; + } + + // For draft releases we need to do some additional work... + // Scan all releases for one with a matching tag name + for (GHRelease release : repo.listReleases()) { + if (Objects.equals(tag, release.getTagName())) { + return release; + } + } + + return null; + } + /** * Lookup whether the {@link GHRepository repo} has the specified {@code ref} or not. * From bfaed03d49d8c9af0ffa2c5375c0fbd2553207a7 Mon Sep 17 00:00:00 2001 From: hypherionmc Date: Mon, 4 Nov 2024 00:56:23 +0200 Subject: [PATCH 2/2] Bump versions and fix changelog --- changelog.md | 9 ++++++++- gradle.properties | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index b77aa69..e5081c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,14 @@ +### Version 2.1.7 + +* [Fix] - Find draft GitHub releases using tag [#26](https://github.com/firstdarkdev/modpublisher/pull/26) + +### Version 2.1.6 + +* [FEAT] Add support for our NightBloom download platform + ### Version 2.1.5 * [FEAT] Add support for "draft" uploads for Modrinth and CurseForge - HypherionSA -* [FEAT] Add support for our NightBloom download platform ### Version 2.1.4 diff --git a/gradle.properties b/gradle.properties index 4048d3f..ceda7c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,8 @@ version_major=2 version_minor=1 -version_patch=5 -release_type=release +version_patch=7 +version_build=0 +release_type=snapshot # Dependencies curse4j=1.0.11