mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: add snapshot changelog and implement GitService for commit details
This commit is contained in:
5
plugins/fancynpcs/CHANGELOG-SNAPSHOT.md
Normal file
5
plugins/fancynpcs/CHANGELOG-SNAPSHOT.md
Normal 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.
|
||||
@@ -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",
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user