Skip to content

Commit 06e82ed

Browse files
committed
Fix GitHub Action
1 parent 9f2606c commit 06e82ed

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
distribution: 'temurin'
3030
java-version: '25'
3131
- name: Publish to Maven Central
32-
run: ./gradlew --no-daemon --info publishToSonatype closeAndReleaseSonatypeStagingRepository -Phmcl.channel=$HMCL_UPDATE_CHANNEL
32+
run: ./gradlew --no-daemon --info upload -Phmcl.channel=$HMCL_UPDATE_CHANNEL
3333
env:
3434
SIGNING_KEY_ID: ${{ secrets.signingKeyId }}
3535
SIGNING_PASSWORD: ${{ secrets.signingPassword }}

build.gradle.kts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,19 @@ CheckUpdate.apply(project, hmclChannel)
2626
val hmclVersion: String = ext.get(CheckUpdate.HMCL_VERSION).toString()
2727
val hmclDownloadBaseUri: String = ext.get(CheckUpdate.HMCL_DOWNLOAD_BASE_URI).toString()
2828

29+
val existing = CheckExisting.checkExisting(hmclChannel, hmclDownloadBaseUri)
30+
2931
version = hmclVersion
3032

3133
val downloadDir = layout.buildDirectory.dir("downloads")
3234

33-
val checkExisting by tasks.registering(CheckExisting::class) {
34-
version.set(hmclVersion)
35-
channel.set(hmclChannel)
36-
}
37-
38-
39-
tasks.named("publishToSonatype") {
40-
dependsOn(checkExisting)
41-
}
42-
43-
tasks.named("closeAndReleaseSonatypeStagingRepository") {
44-
dependsOn(checkExisting)
35+
val upload by tasks.registering {
36+
if (!existing) {
37+
dependsOn("publishToSonatype", "closeAndReleaseSonatypeStagingRepository")
38+
}
4539
}
4640

4741
val downloadArtifacts by tasks.registering(Download::class) {
48-
dependsOn(checkExisting)
49-
5042
src("$hmclDownloadBaseUri/HMCL-$hmclVersion.jar")
5143
src("$hmclDownloadBaseUri/HMCL-$hmclVersion.jar.sha256")
5244

buildSrc/src/main/java/org/glavo/hmcl/update/CheckExisting.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.gradle.api.logging.Logging;
2323
import org.gradle.api.provider.Property;
2424
import org.gradle.api.tasks.Input;
25-
import org.gradle.api.tasks.StopExecutionException;
2625
import org.gradle.api.tasks.TaskAction;
2726
import org.jetbrains.annotations.NotNull;
2827
import org.w3c.dom.Document;
@@ -36,21 +35,11 @@
3635
import java.net.http.HttpResponse;
3736
import java.util.regex.Pattern;
3837

39-
public abstract class CheckExisting extends DefaultTask {
38+
public final class CheckExisting {
4039
private static final Logger LOGGER = Logging.getLogger(CheckExisting.class);
4140
private static final Pattern PATTERN = Pattern.compile("^[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$");
4241

43-
@Input
44-
public abstract Property<@NotNull UpdateChannel> getChannel();
45-
46-
@Input
47-
public abstract Property<@NotNull String> getVersion();
48-
49-
@TaskAction
50-
public void run() throws Exception {
51-
UpdateChannel channel = getChannel().get();
52-
53-
String version = getVersion().get();
42+
public static boolean checkExisting(UpdateChannel channel, String version) throws Exception {
5443
if (!PATTERN.matcher(version).matches()) {
5544
throw new IllegalArgumentException("Bad HMCL version: " + version);
5645
}
@@ -71,9 +60,11 @@ public void run() throws Exception {
7160
Node item = versionList.item(i);
7261
if (version.equals(item.getFirstChild().getNodeValue())) {
7362
LOGGER.quiet("{} already exists, no update required", version);
74-
throw new StopExecutionException();
63+
return true;
7564
}
7665
}
66+
67+
return false;
7768
}
7869

7970
}

0 commit comments

Comments
 (0)