From 36742d7b0e6de364e75fb9c62caf29c31b8838ef Mon Sep 17 00:00:00 2001 From: PinozenTH Date: Thu, 6 Nov 2025 18:05:14 +0700 Subject: [PATCH 1/4] chore: update singularitylib version to 1.3.3-SNAPSHOT and improve release script --- .github/workflows/release.yml | 18 ++++++++++++------ pom.xml | 2 +- .../singularitylib/plugin/CorePlugin.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d965901..934ffca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -120,19 +120,25 @@ jobs: # Capture a primary jar (non sources/javadoc) for convenience MAIN_JAR=$(ls target/*.jar | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true) if [[ -z "$MAIN_JAR" ]]; then - echo "ERROR: No main artifact jar found." - exit 1 + echo "ERROR: No main artifact jar found." + exit 1 fi - cp "$MAIN_JAR" main-artifact.jar + + # Extract filename and remove 'original-' prefix if present + BASENAME=$(basename "$MAIN_JAR") + BASENAME=${BASENAME#original-} + + cp "$MAIN_JAR" "$BASENAME" echo "Selected main artifact: $MAIN_JAR" + echo "Copied to: $BASENAME" - name: Create & Push Git Tag run: | set -e TAG="${{ steps.version.outputs.version }}" if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then - echo "Tag ${TAG} already exists unexpectedly (race condition?)." - exit 1 + echo "Tag ${TAG} already exists unexpectedly (race condition?)." + exit 1 fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" @@ -148,7 +154,7 @@ jobs: files: | target/*-sources.jar target/*-javadoc.jar - main-artifact.jar + singularitylib-*.jar - name: Summary run: | diff --git a/pom.xml b/pom.xml index 6b1f3ca..c124c83 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.pinont singularitylib - 1.3.2-SNAPSHOT + 1.3.3-SNAPSHOT jar SingularityLib diff --git a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java index 0704907..7b86156 100644 --- a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java +++ b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java @@ -99,7 +99,7 @@ public static void sendConsoleMessage(String message) { * @return the API version string */ public static String getAPIVersion() { - String version = "1.3.0"; + String version = "1.3.3-SNAPSHOT"; return "V-" + version; } From bb4615012efa4d3330e5d4a14853d1598edfef23 Mon Sep 17 00:00:00 2001 From: PinozenTH Date: Fri, 7 Nov 2025 14:04:57 +0700 Subject: [PATCH 2/4] chore: update version to 1.3.3 and add Maven shade plugin profile --- pom.xml | 66 +++++++++++-------- .../singularitylib/plugin/CorePlugin.java | 2 +- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index c124c83..d97248d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.pinont singularitylib - 1.3.3-SNAPSHOT + 1.3.3 jar SingularityLib @@ -38,6 +38,45 @@ + + + with-shade + + + shade + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + + + org.reflections:reflections + + org/reflections/** + + + + + + + package + + shade + + + + + + + + + + https://github.com/Pinont/SingularityLib scm:git:https://github.com/Pinont/SingularityLib.git @@ -131,31 +170,6 @@ - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.3 - - - - org.reflections:reflections - - org/reflections/** - - - - - - - package - - shade - - - - - org.apache.maven.plugins diff --git a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java index 7b86156..8bf03e6 100644 --- a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java +++ b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java @@ -99,7 +99,7 @@ public static void sendConsoleMessage(String message) { * @return the API version string */ public static String getAPIVersion() { - String version = "1.3.3-SNAPSHOT"; + String version = "1.3.3"; return "V-" + version; } From 55470ae1c3ce1dbe235bb6d97e6ab9f2f52d9f06 Mon Sep 17 00:00:00 2001 From: PinozenTH Date: Fri, 7 Nov 2025 14:15:16 +0700 Subject: [PATCH 3/4] feat: enhance release workflow to include shaded package build and improved artifact handling --- .github/workflows/release.yml | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 934ffca..2b75241 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,25 +112,35 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy + - name: Build (package, with-shade) + run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package + - name: Verify built artifacts run: | set -e echo "Contents of target/:" - ls -1 target - # Capture a primary jar (non sources/javadoc) for convenience - MAIN_JAR=$(ls target/*.jar | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true) + ls -1 target || true + + # Find a primary jar (excluding sources/javadoc) + MAIN_JAR=$(ls target/*.jar 2>/dev/null | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true) if [[ -z "$MAIN_JAR" ]]; then - echo "ERROR: No main artifact jar found." - exit 1 + echo "ERROR: No main artifact jar found." + exit 1 fi - - # Extract filename and remove 'original-' prefix if present + BASENAME=$(basename "$MAIN_JAR") - BASENAME=${BASENAME#original-} - - cp "$MAIN_JAR" "$BASENAME" - echo "Selected main artifact: $MAIN_JAR" - echo "Copied to: $BASENAME" + STRIPPED=${BASENAME#original-} + + if [[ "$BASENAME" != "$STRIPPED" ]]; then + # Found an 'original-' artifact -> produce *-api.jar + API_NAME="${STRIPPED%.jar}-api.jar" + cp "$MAIN_JAR" "$API_NAME" + echo "Found original artifact: $MAIN_JAR -> copied to $API_NAME" + else + # Likely the shaded artifact -> keep basename + cp "$MAIN_JAR" "$BASENAME" + echo "Found main artifact (shaded): $MAIN_JAR -> copied to $BASENAME" + fi - name: Create & Push Git Tag run: | From 53c9c4a8cf2e7f8ebc1a63d66caf1566f1c38643 Mon Sep 17 00:00:00 2001 From: PinozenTH Date: Fri, 7 Nov 2025 14:31:49 +0700 Subject: [PATCH 4/4] feat: add API version management with configuration file and update version retrieval method --- .github/workflows/release.yml | 36 ++----------------- pom.xml | 7 +++- .../singularitylib/api/utils/Common.java | 13 +++++++ .../singularitylib/plugin/CorePlugin.java | 13 ++----- src/main/resources/api-version.yml | 1 + 5 files changed, 24 insertions(+), 46 deletions(-) create mode 100644 src/main/resources/api-version.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b75241..1468104 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,43 +105,13 @@ jobs: fi - name: Build (package) - run: mvn -B -s $GITHUB_WORKSPACE/settings.xml package + run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package - name: Deploy Release to GitHub Packages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy - - name: Build (package, with-shade) - run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package - - - name: Verify built artifacts - run: | - set -e - echo "Contents of target/:" - ls -1 target || true - - # Find a primary jar (excluding sources/javadoc) - MAIN_JAR=$(ls target/*.jar 2>/dev/null | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true) - if [[ -z "$MAIN_JAR" ]]; then - echo "ERROR: No main artifact jar found." - exit 1 - fi - - BASENAME=$(basename "$MAIN_JAR") - STRIPPED=${BASENAME#original-} - - if [[ "$BASENAME" != "$STRIPPED" ]]; then - # Found an 'original-' artifact -> produce *-api.jar - API_NAME="${STRIPPED%.jar}-api.jar" - cp "$MAIN_JAR" "$API_NAME" - echo "Found original artifact: $MAIN_JAR -> copied to $API_NAME" - else - # Likely the shaded artifact -> keep basename - cp "$MAIN_JAR" "$BASENAME" - echo "Found main artifact (shaded): $MAIN_JAR -> copied to $BASENAME" - fi - - name: Create & Push Git Tag run: | set -e @@ -162,9 +132,7 @@ jobs: name: "SingularityLib ${{ steps.version.outputs.version }}" generate_release_notes: true files: | - target/*-sources.jar - target/*-javadoc.jar - singularitylib-*.jar + `target/*.jar` - name: Summary run: | diff --git a/pom.xml b/pom.xml index d97248d..0eb38f4 100644 --- a/pom.xml +++ b/pom.xml @@ -41,11 +41,13 @@ with-shade + shade + @@ -53,6 +55,10 @@ maven-shade-plugin 3.5.3 + + true + shaded + false org.reflections:reflections @@ -76,7 +82,6 @@ - https://github.com/Pinont/SingularityLib scm:git:https://github.com/Pinont/SingularityLib.git diff --git a/src/main/java/com/github/pinont/singularitylib/api/utils/Common.java b/src/main/java/com/github/pinont/singularitylib/api/utils/Common.java index dff5356..de3a047 100644 --- a/src/main/java/com/github/pinont/singularitylib/api/utils/Common.java +++ b/src/main/java/com/github/pinont/singularitylib/api/utils/Common.java @@ -1,6 +1,8 @@ package com.github.pinont.singularitylib.api.utils; import com.github.pinont.singularitylib.api.enums.PlayerInventorySlotType; +import com.github.pinont.singularitylib.api.manager.ConfigManager; +import com.github.pinont.singularitylib.plugin.CorePlugin; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Bukkit; @@ -28,6 +30,17 @@ public class Common { public Common() { } + /** + * Gets the current API version. + * + * @return the API version string + */ + public static String getAPIVersion() { + ConfigManager apiConfig = new ConfigManager(CorePlugin.getInstance(), "api-version.yml"); + String version = apiConfig.getConfig().getString("api-version", "1.0.0"); + return "V-" + version; + } + /** * Colorizes a string message using MiniMessage format. * diff --git a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java index 8bf03e6..abb2860 100644 --- a/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java +++ b/src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java @@ -1,5 +1,6 @@ package com.github.pinont.singularitylib.plugin; +import com.github.pinont.singularitylib.api.utils.Common; import com.github.pinont.singularitylib.plugin.listener.PlayerListener; import com.github.pinont.singularitylib.api.command.SimpleCommand; import com.github.pinont.singularitylib.api.manager.ConfigManager; @@ -93,16 +94,6 @@ public static void sendConsoleMessage(String message) { private final List listeners = new ArrayList<>(); - /** - * Gets the current API version. - * - * @return the API version string - */ - public static String getAPIVersion() { - String version = "1.3.3"; - return "V-" + version; - } - private ConfigManager pluginConfig; /** @@ -174,7 +165,7 @@ public final void onEnable() { } // Initialize API To Plugin. - sendConsoleMessage(ChatColor.WHITE + "" + ChatColor.ITALIC + "Hooked " + ChatColor.YELLOW + ChatColor.ITALIC + this.getName() + ChatColor.WHITE + ChatColor.ITALIC + " into " + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "SingularityAPI! " + getAPIVersion()); + sendConsoleMessage(ChatColor.WHITE + "" + ChatColor.ITALIC + "Hooked " + ChatColor.YELLOW + ChatColor.ITALIC + this.getName() + ChatColor.WHITE + ChatColor.ITALIC + " into " + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "SingularityAPI! " + Common.getAPIVersion()); onPluginStart(); registerAPIListener(this, new PlayerListener()); // new CommandManager().register(this, this.simpleCommands); diff --git a/src/main/resources/api-version.yml b/src/main/resources/api-version.yml new file mode 100644 index 0000000..ab2f7e7 --- /dev/null +++ b/src/main/resources/api-version.yml @@ -0,0 +1 @@ +api-version: ${version} \ No newline at end of file