Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/auto_release_on_version_change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Create Release on Version Change

on:
push:
branches:
- master
paths:
- "build.gradle.kts"

permissions:
contents: write

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Needed so we can inspect previous commits and tags
fetch-depth: 0

- name: Extract current version from build.gradle.kts
id: current_version
run: |
VERSION_LINE=$(grep '^version' build.gradle.kts | head -n 1 || true)
if [ -z "$VERSION_LINE" ]; then
echo "Could not find version line in build.gradle.kts"
exit 1
fi
VERSION=$(echo "$VERSION_LINE" | sed -E 's/^[^"]*"([^"]+)".*/\1/')
echo "Current version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Extract previous version from build.gradle.kts
id: previous_version
run: |
# If there is no previous commit on this branch, treat it as a version change
if ! git rev-parse HEAD^ >/dev/null 2>&1; then
echo "No previous commit on this branch, treating as version change."
echo "version=" >> "$GITHUB_OUTPUT"
exit 0
fi

VERSION_LINE=$(git show HEAD^:build.gradle.kts | grep '^version' | head -n 1 || true)
if [ -z "$VERSION_LINE" ]; then
echo "Could not find version line in previous build.gradle.kts; treating as version change."
echo "version=" >> "$GITHUB_OUTPUT"
exit 0
fi

VERSION=$(echo "$VERSION_LINE" | sed -E 's/^[^"]*"([^"]+)".*/\1/')
echo "Previous version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Determine if version changed
id: version_changed
run: |
CURR="${{ steps.current_version.outputs.version }}"
PREV="${{ steps.previous_version.outputs.version }}"
echo "Current version: $CURR"
echo "Previous version: $PREV"

if [ -n "$PREV" ] && [ "$CURR" = "$PREV" ]; then
echo "Version did not change."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "Version changed."
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Stop if version did not change
if: steps.version_changed.outputs.changed == 'false'
run: |
echo "Version did not change; skipping release."
exit 0

- name: Determine previous tag
id: previous_tag
if: steps.version_changed.outputs.changed == 'true'
run: |
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
TAG=$(git describe --tags --abbrev=0)
echo "Previous tag: $TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
else
echo "No previous tag found."
echo "tag=" >> "$GITHUB_OUTPUT"
fi

- name: Generate release notes
id: notes
if: steps.version_changed.outputs.changed == 'true'
run: |
PREV_TAG="${{ steps.previous_tag.outputs.tag }}"

if [ -n "$PREV_TAG" ]; then
RANGE="$PREV_TAG..HEAD"
else
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD)
RANGE="$FIRST_COMMIT..HEAD"
fi

echo "Using commit range: $RANGE"
BODY=$(git log --pretty=format:'- %s (%h)' "$RANGE")

{
echo "body<<EOF"
echo "Changes in version ${{ steps.current_version.outputs.version }}"
echo
echo "$BODY"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
if: steps.version_changed.outputs.changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.current_version.outputs.version }}
name: v${{ steps.current_version.outputs.version }}
body: ${{ steps.notes.outputs.body }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public class AsyncMetricsSnapshot {

private final long usedHeap;
private final long commitedHeap;
private final long committedHeap;

private final long totalDisk;
private final long usableDisk;
Expand All @@ -26,14 +26,14 @@ public class AsyncMetricsSnapshot {
private final int availableProcessors;


public AsyncMetricsSnapshot(long usedHeap, long commitedHeap,
public AsyncMetricsSnapshot(long usedHeap, long committedHeap,
long totalDisk, long usableDisk,
long minPing, long maxPing, long avgPing,
double mspt1m, double mspt5m, double mspt15m,
double lastMSPT, double minMSPT, double maxMSPT,
double systemCpuLoadRatio, double processCpuLoadRatio, int availableProcessors) {
this.usedHeap = usedHeap;
this.commitedHeap = commitedHeap;
this.committedHeap = committedHeap;

this.totalDisk = totalDisk;
this.usableDisk = usableDisk;
Expand Down Expand Up @@ -69,8 +69,8 @@ public long getUsedHeap() {
*
* @return the committed heap memory
*/
public long getCommitedHeap() {
return commitedHeap;
public long getCommittedHeap() {
return committedHeap;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,4 @@ public interface IDatabaseService extends Service {
*/
boolean isConnected();

/**
* Disconnects from the InfluxDB instance and cleans up resources.
* This method should be called when the application is shutting down
* or when the connection is no longer needed.
*/
void startRetryTaskIfNeeded();

}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "it.renvins"
version = "0.5.2-SNAPSHOT"
version = "0.5.5-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ public boolean isConnected() {
return this.isConnected;
}


@Override
public void startRetryTaskIfNeeded() {
private void startRetryTaskIfNeeded() {
// FAST EXIT: Because a task is already running
if (retryTask.get() != null) {
return;
Expand Down Expand Up @@ -227,7 +225,7 @@ private void connect() {

if (isPingSuccessful) {
this.isConnected = true;
this.retryCount.set(0);; // Reset retry count on successful connection
this.retryCount.set(0); // Reset retry count on successful connection

stopRetryTask(); // Stop retrying if we just connected
logger.info("Successfully connected to InfluxDB and ping successful...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ private void sendPoints(List<String> points) {

try {
String body = String.join("\n", points);
databaseService.writeLineProtocol(body);
databaseService.writeLineProtocol(body)
.thenAccept(success -> {
if (!success) {
logger.error("Database reported failure on sending metrics.");
}
});
} catch (Exception e) {
logger.error("Failed to send metrics data to the database.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public List<String> format(SyncMetricsSnapshot syncData, AsyncMetricsSnapshot as
.addField("players_online", syncData.getPlayerCount())
// Async data
.addField("used_memory", asyncData.getUsedHeap())
.addField("available_memory", asyncData.getCommitedHeap())
.addField("available_memory", asyncData.getCommittedHeap())
.addField("total_disk_space", asyncData.getTotalDisk())
.addField("usable_disk_space", asyncData.getUsableDisk())
.addField("min_ping", asyncData.getMinPing())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class ChatUtils {

public String format(String message) {
if (message == null) return "";
return message.replace("&", "§");
}
}
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import lombok.Getter;
import org.slf4j.Logger;

@Plugin(id = "serverpulse", name = "ServerPulse", version = "0.5.2-SNAPSHOT",
@Plugin(id = "serverpulse", name = "ServerPulse", version = "0.5.5-SNAPSHOT",
description = "Effortless Minecraft performance monitoring with pre-configured Grafana/InfluxDB via Docker.", authors = {"renvins"})
public class ServerPulseVelocity {

Expand Down