fancynpcs: add snapshot changelog and implement GitService for commit details

This commit is contained in:
Oliver
2025-03-29 22:30:07 +01:00
parent 3be3f30135
commit b30d28f885
4 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
Commit hash: %COMMIT_HASH%
Commit message: %COMMIT_MESSAGE%
Keep in mind that this is a snapshot version. Snapshot versions are **not** meant to be used in production. They are for **testing purposes only** and may contain bugs or incomplete features. Use at your own risk.

View File

@@ -1,7 +1,7 @@
{
"project_id": "EeyAn23L",
"plugin_jar_path": "../../../../plugins/fancynpcs/build/libs/FancyNpcs-%VERSION%.jar",
"changelog_path": "../../../../plugins/fancynpcs/CHANGELOG.md",
"changelog_path": "../../../../plugins/fancynpcs/CHANGELOG-SNAPSHOT.md",
"version_path": "../../../../plugins/fancynpcs/VERSION",
"supported_versions":[
"1.19.4",

View File

@@ -0,0 +1,37 @@
package de.oliver.deployment.git;
import java.io.IOException;
public class GitService {
public static String getCommitHash() {
ProcessBuilder processBuilder = new ProcessBuilder("git", "rev-parse", "HEAD");
processBuilder.redirectErrorStream(true);
processBuilder.directory(new java.io.File("."));
try {
Process process = processBuilder.start();
return new String(process.getInputStream().readAllBytes()).trim();
} catch (IOException e) {
e.printStackTrace();
}
return "unknown";
}
public static String getCommitMessage() {
ProcessBuilder processBuilder = new ProcessBuilder("git", "log", "-1", "--pretty=%B");
processBuilder.redirectErrorStream(true);
processBuilder.directory(new java.io.File("."));
try {
Process process = processBuilder.start();
return new String(process.getInputStream().readAllBytes()).trim();
} catch (IOException e) {
e.printStackTrace();
}
return "unknown";
}
}

View File

@@ -1,6 +1,7 @@
package de.oliver.deployment.modrinth;
import de.oliver.deployment.Configuration;
import de.oliver.deployment.git.GitService;
import masecla.modrinth4j.client.agent.UserAgent;
import masecla.modrinth4j.endpoints.version.CreateVersion;
import masecla.modrinth4j.main.ModrinthAPI;
@@ -32,6 +33,9 @@ public class ModrinthService {
public void deployPlugin(Configuration config) throws IOException {
String changelog = Files.readString(Path.of(config.changeLogPath()));
changelog = changelog.replaceAll("%COMMIT_HASH%", GitService.getCommitHash());
changelog = changelog.replaceAll("%COMMIT_MESSAGE%", GitService.getCommitMessage());
String version = Files.readString(Path.of(config.versionPath()));
String pluginJarPath = config.pluginJarPath().replace("%VERSION%", version);