Skip to content

Commit 53c9c4a

Browse files
committed
feat: add API version management with configuration file and update version retrieval method
1 parent 55470ae commit 53c9c4a

5 files changed

Lines changed: 24 additions & 46 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -105,43 +105,13 @@ jobs:
105105
fi
106106
107107
- name: Build (package)
108-
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml package
108+
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package
109109

110110
- name: Deploy Release to GitHub Packages
111111
env:
112112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113113
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy
114114

115-
- name: Build (package, with-shade)
116-
run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests -Pwith-shade package
117-
118-
- name: Verify built artifacts
119-
run: |
120-
set -e
121-
echo "Contents of target/:"
122-
ls -1 target || true
123-
124-
# Find a primary jar (excluding sources/javadoc)
125-
MAIN_JAR=$(ls target/*.jar 2>/dev/null | grep -v '\-sources\.jar$' | grep -v '\-javadoc\.jar$' | head -n1 || true)
126-
if [[ -z "$MAIN_JAR" ]]; then
127-
echo "ERROR: No main artifact jar found."
128-
exit 1
129-
fi
130-
131-
BASENAME=$(basename "$MAIN_JAR")
132-
STRIPPED=${BASENAME#original-}
133-
134-
if [[ "$BASENAME" != "$STRIPPED" ]]; then
135-
# Found an 'original-' artifact -> produce *-api.jar
136-
API_NAME="${STRIPPED%.jar}-api.jar"
137-
cp "$MAIN_JAR" "$API_NAME"
138-
echo "Found original artifact: $MAIN_JAR -> copied to $API_NAME"
139-
else
140-
# Likely the shaded artifact -> keep basename
141-
cp "$MAIN_JAR" "$BASENAME"
142-
echo "Found main artifact (shaded): $MAIN_JAR -> copied to $BASENAME"
143-
fi
144-
145115
- name: Create & Push Git Tag
146116
run: |
147117
set -e
@@ -162,9 +132,7 @@ jobs:
162132
name: "SingularityLib ${{ steps.version.outputs.version }}"
163133
generate_release_notes: true
164134
files: |
165-
target/*-sources.jar
166-
target/*-javadoc.jar
167-
singularitylib-*.jar
135+
`target/*.jar`
168136
169137
- name: Summary
170138
run: |

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,24 @@
4141
<profiles>
4242
<profile>
4343
<id>with-shade</id>
44+
<!-- Optional: still allow activation by property 'shade' if you prefer -Dshade=true -->
4445
<activation>
4546
<property>
4647
<name>shade</name>
4748
</property>
4849
</activation>
50+
4951
<build>
5052
<plugins>
5153
<plugin>
5254
<groupId>org.apache.maven.plugins</groupId>
5355
<artifactId>maven-shade-plugin</artifactId>
5456
<version>3.5.3</version>
5557
<configuration>
58+
<!-- Attach shaded artifact instead of replacing the main jar -->
59+
<shadedArtifactAttached>true</shadedArtifactAttached>
60+
<shadedClassifierName>shaded</shadedClassifierName>
61+
<createDependencyReducedPom>false</createDependencyReducedPom>
5662
<filters>
5763
<filter>
5864
<artifact>org.reflections:reflections</artifact>
@@ -76,7 +82,6 @@
7682
</profile>
7783
</profiles>
7884

79-
8085
<scm>
8186
<url>https://github.com/Pinont/SingularityLib</url>
8287
<connection>scm:git:https://github.com/Pinont/SingularityLib.git</connection>

src/main/java/com/github/pinont/singularitylib/api/utils/Common.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.pinont.singularitylib.api.utils;
22

33
import com.github.pinont.singularitylib.api.enums.PlayerInventorySlotType;
4+
import com.github.pinont.singularitylib.api.manager.ConfigManager;
5+
import com.github.pinont.singularitylib.plugin.CorePlugin;
46
import net.kyori.adventure.text.Component;
57
import net.kyori.adventure.text.minimessage.MiniMessage;
68
import org.bukkit.Bukkit;
@@ -28,6 +30,17 @@ public class Common {
2830
public Common() {
2931
}
3032

33+
/**
34+
* Gets the current API version.
35+
*
36+
* @return the API version string
37+
*/
38+
public static String getAPIVersion() {
39+
ConfigManager apiConfig = new ConfigManager(CorePlugin.getInstance(), "api-version.yml");
40+
String version = apiConfig.getConfig().getString("api-version", "1.0.0");
41+
return "V-" + version;
42+
}
43+
3144
/**
3245
* Colorizes a string message using MiniMessage format.
3346
*

src/main/java/com/github/pinont/singularitylib/plugin/CorePlugin.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.pinont.singularitylib.plugin;
22

3+
import com.github.pinont.singularitylib.api.utils.Common;
34
import com.github.pinont.singularitylib.plugin.listener.PlayerListener;
45
import com.github.pinont.singularitylib.api.command.SimpleCommand;
56
import com.github.pinont.singularitylib.api.manager.ConfigManager;
@@ -93,16 +94,6 @@ public static void sendConsoleMessage(String message) {
9394

9495
private final List<Listener> listeners = new ArrayList<>();
9596

96-
/**
97-
* Gets the current API version.
98-
*
99-
* @return the API version string
100-
*/
101-
public static String getAPIVersion() {
102-
String version = "1.3.3";
103-
return "V-" + version;
104-
}
105-
10697
private ConfigManager pluginConfig;
10798

10899
/**
@@ -174,7 +165,7 @@ public final void onEnable() {
174165
}
175166

176167
// Initialize API To Plugin.
177-
sendConsoleMessage(ChatColor.WHITE + "" + ChatColor.ITALIC + "Hooked " + ChatColor.YELLOW + ChatColor.ITALIC + this.getName() + ChatColor.WHITE + ChatColor.ITALIC + " into " + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "SingularityAPI! " + getAPIVersion());
168+
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());
178169
onPluginStart();
179170
registerAPIListener(this, new PlayerListener());
180171
// new CommandManager().register(this, this.simpleCommands);

src/main/resources/api-version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api-version: ${version}

0 commit comments

Comments
 (0)