mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
use atlas for version uploading
This commit is contained in:
35
.github/workflows/build-12110.yml
vendored
35
.github/workflows/build-12110.yml
vendored
@@ -14,6 +14,8 @@ jobs:
|
|||||||
BUILD_NUMBER: ${{ github.run_number }}
|
BUILD_NUMBER: ${{ github.run_number }}
|
||||||
outputs:
|
outputs:
|
||||||
build_number: ${{ env.BUILD_NUMBER }}
|
build_number: ${{ env.BUILD_NUMBER }}
|
||||||
|
jar_file: ${{ steps.prepare_jar.outputs.jar_file }}
|
||||||
|
version: ${{ steps.prepare_jar.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -56,6 +58,7 @@ jobs:
|
|||||||
git config --global core.fscache true
|
git config --global core.fscache true
|
||||||
git config --global gc.auto 256
|
git config --global gc.auto 256
|
||||||
chmod +x gradlew
|
chmod +x gradlew
|
||||||
|
chmod +x scripts/uploadBuild.sh
|
||||||
|
|
||||||
- name: Apply Patches
|
- name: Apply Patches
|
||||||
run: |
|
run: |
|
||||||
@@ -65,18 +68,22 @@ jobs:
|
|||||||
- name: Build Paperclip Jar
|
- name: Build Paperclip Jar
|
||||||
run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel --no-daemon
|
run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel --no-daemon
|
||||||
|
|
||||||
- name: Prepare Release Info
|
- name: Prepare and Move Paperclip Jar
|
||||||
run: bash scripts/releaseInfo.sh
|
id: prepare_jar
|
||||||
env:
|
run: |
|
||||||
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
|
VERSION="1.21.10"
|
||||||
|
BUILD="${BUILD_NUMBER}"
|
||||||
|
JAR_NAME="divinemc-${VERSION}-${BUILD}.jar"
|
||||||
|
mv divinemc-server/build/libs/divinemc-paperclip-*-mojmap.jar divinemc-server/build/libs/${JAR_NAME}
|
||||||
|
echo "jar_file=divinemc-server/build/libs/${JAR_NAME}" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
echo "JAR_FILE=divinemc-server/build/libs/${JAR_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create Release
|
- name: Upload to API
|
||||||
uses: ncipollo/release-action@v1.15.0
|
env:
|
||||||
with:
|
API_URL: 'https://api.bxteam.org'
|
||||||
artifacts: ${{ env.jar }}
|
API_KEY: ${{ secrets.ATLAS_API_KEY }}
|
||||||
bodyFile: ${{ env.info }}
|
PROJECT_KEY: 'divinemc'
|
||||||
tag: ${{ env.tag }}
|
VERSION_BRANCH: 'ver/1.21.10'
|
||||||
name: ${{ env.name }}
|
JAR_FILE: ${{ env.JAR_FILE }}
|
||||||
prerelease: ${{ env.experimental }}
|
run: bash scripts/uploadBuild.sh
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
makeLatest: ${{ env.make_latest }}
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ index 6194d6d8952864c71cc4017a639b818e4ecccea9..46e62dead64e18691122a6dfaa1df77a
|
|||||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
index a5a7334f7a1f147945079f20aa04b4f317d9e94c..5f595378d68fb9e3f069fdb6cbd70e8927ffe7e2 100644
|
index a5a7334f7a1f147945079f20aa04b4f317d9e94c..9db450c3f87c552fc01a16002b6029cfdc3a5a60 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
@@ -36,7 +36,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -36,7 +36,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
@@ -35,7 +35,7 @@ index a5a7334f7a1f147945079f20aa04b4f317d9e94c..5f595378d68fb9e3f069fdb6cbd70e89
|
|||||||
private static final int DISTANCE_UNKNOWN = -2;
|
private static final int DISTANCE_UNKNOWN = -2;
|
||||||
// Purpur start - Rebrand
|
// Purpur start - Rebrand
|
||||||
- private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads";
|
- private static final String DOWNLOAD_PAGE = "https://purpurmc.org/downloads";
|
||||||
+ private static final String DOWNLOAD_PAGE = "https://github.com/BX-Team/DivineMC/releases/latest"; // DivineMC - Rebrand
|
+ private static final String DOWNLOAD_PAGE = "https://bxteam.org/downloads/divinemc"; // DivineMC - Rebrand
|
||||||
private static int distance = DISTANCE_UNKNOWN; public int distance() { return distance; }
|
private static int distance = DISTANCE_UNKNOWN; public int distance() { return distance; }
|
||||||
// Purpur end - Rebrand
|
// Purpur end - Rebrand
|
||||||
|
|
||||||
@@ -48,58 +48,39 @@ index a5a7334f7a1f147945079f20aa04b4f317d9e94c..5f595378d68fb9e3f069fdb6cbd70e89
|
|||||||
}
|
}
|
||||||
final @Nullable Component history = this.getHistory();
|
final @Nullable Component history = this.getHistory();
|
||||||
|
|
||||||
@@ -60,18 +60,13 @@ public class PaperVersionFetcher implements VersionFetcher {
|
@@ -86,18 +86,18 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
}
|
|
||||||
|
|
||||||
private static Component getUpdateStatusMessage(final String repo, final ServerBuildInfo build) {
|
|
||||||
- //int distance = DISTANCE_ERROR; // Purpur - use field - Rebrand
|
|
||||||
-
|
|
||||||
- final OptionalInt buildNumber = build.buildNumber();
|
|
||||||
- if (buildNumber.isPresent()) {
|
|
||||||
- distance = fetchDistanceFromSiteApi(build, buildNumber.getAsInt());
|
|
||||||
- } else {
|
|
||||||
- final Optional<String> gitBranch = build.gitBranch();
|
|
||||||
- final Optional<String> gitCommit = build.gitCommit();
|
|
||||||
- if (gitBranch.isPresent() && gitCommit.isPresent()) {
|
|
||||||
- distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get());
|
|
||||||
- }
|
|
||||||
+ // DivineMC start - Rebrand
|
|
||||||
+ final Optional<String> gitBranch = build.gitBranch();
|
|
||||||
+ final Optional<String> gitCommit = build.gitCommit();
|
|
||||||
+ if (gitBranch.isPresent() && gitCommit.isPresent()) {
|
|
||||||
+ distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get());
|
|
||||||
}
|
|
||||||
+ // DivineMC end - Rebrand
|
|
||||||
|
|
||||||
return switch (distance) {
|
|
||||||
case DISTANCE_ERROR -> text("* Error obtaining version information", NamedTextColor.RED); // Purpur - Rebrand
|
|
||||||
@@ -86,26 +81,6 @@ public class PaperVersionFetcher implements VersionFetcher {
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) {
|
- private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) {
|
||||||
- try {
|
+ // DivineMC start - Rebrand
|
||||||
- try (final BufferedReader reader = Resources.asCharSource(
|
+ private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int localBuildNumber) {
|
||||||
|
try {
|
||||||
|
try (final BufferedReader reader = Resources.asCharSource(
|
||||||
- URI.create("https://api.purpurmc.org/v2/purpur/" + build.minecraftVersionId()).toURL(), // Purpur - Rebrand
|
- URI.create("https://api.purpurmc.org/v2/purpur/" + build.minecraftVersionId()).toURL(), // Purpur - Rebrand
|
||||||
- StandardCharsets.UTF_8
|
+ URI.create("https://api.bxteam.org/v2/projects/divinemc/versions/" + build.minecraftVersionId() + "/builds/latest").toURL(),
|
||||||
- ).openBufferedStream()) {
|
StandardCharsets.UTF_8
|
||||||
- final JsonObject json = new Gson().fromJson(reader, JsonObject.class);
|
).openBufferedStream()) {
|
||||||
|
final JsonObject json = new Gson().fromJson(reader, JsonObject.class);
|
||||||
- //final JsonArray builds = json.getAsJsonArray("builds"); // Purpur - Rebrand
|
- //final JsonArray builds = json.getAsJsonArray("builds"); // Purpur - Rebrand
|
||||||
- final int latest = json.getAsJsonObject("builds").getAsJsonPrimitive("latest").getAsInt(); // Purpur - Rebrand
|
- final int latest = json.getAsJsonObject("builds").getAsJsonPrimitive("latest").getAsInt(); // Purpur - Rebrand
|
||||||
- return latest - jenkinsBuild;
|
- return latest - jenkinsBuild;
|
||||||
- } catch (final JsonSyntaxException ex) {
|
+ final int latest = json.getAsJsonPrimitive("id").getAsInt();
|
||||||
|
+ return latest - localBuildNumber;
|
||||||
|
} catch (final JsonSyntaxException ex) {
|
||||||
- LOGGER.error("Error parsing json from Purpur's downloads API", ex); // Purpur - Rebrand
|
- LOGGER.error("Error parsing json from Purpur's downloads API", ex); // Purpur - Rebrand
|
||||||
- return DISTANCE_ERROR;
|
+ LOGGER.error("Error parsing json from DivineMC's downloads API", ex);
|
||||||
- }
|
return DISTANCE_ERROR;
|
||||||
- } catch (final IOException e) {
|
}
|
||||||
- LOGGER.error("Error while parsing version", e);
|
} catch (final IOException e) {
|
||||||
- return DISTANCE_ERROR;
|
@@ -105,6 +105,7 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
- }
|
return DISTANCE_ERROR;
|
||||||
- }
|
}
|
||||||
-
|
}
|
||||||
|
+ // DivineMC end - Rebrand
|
||||||
|
|
||||||
// Contributed by Techcable <Techcable@outlook.com> in GH-65
|
// Contributed by Techcable <Techcable@outlook.com> in GH-65
|
||||||
private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) {
|
private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) {
|
||||||
try {
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||||
index bc7e4e5560708fea89c584b1d8b471f4966f311a..6567ff18cb1c21230565c2d92caf3a7f7f915c17 100644
|
index bc7e4e5560708fea89c584b1d8b471f4966f311a..6567ff18cb1c21230565c2d92caf3a7f7f915c17 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sha256() {
|
|
||||||
sha256sum "$1" | awk '{print $1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
sha1() {
|
|
||||||
sha1sum "$1" | awk '{print $1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
md5() {
|
|
||||||
md5sum "$1" | awk '{print $1}'
|
|
||||||
}
|
|
||||||
|
|
||||||
prop() {
|
|
||||||
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
|
|
||||||
}
|
|
||||||
|
|
||||||
commitid=$(git log --pretty='%h' -1)
|
|
||||||
mcversion=$(prop mcVersion)
|
|
||||||
version=$(prop version)
|
|
||||||
experimental=$(prop experimental)
|
|
||||||
tagid="$mcversion-$BUILD_NUMBER-$commitid"
|
|
||||||
jarName="divinemc-$mcversion-$BUILD_NUMBER.jar"
|
|
||||||
divinemcid="DivineMC-$tagid"
|
|
||||||
changelog="changelog.md"
|
|
||||||
make_latest=$([ "$experimental" = "true" ] && echo "false" || echo "true")
|
|
||||||
|
|
||||||
rm -f $changelog
|
|
||||||
|
|
||||||
mv divinemc-server/build/libs/divinemc-paperclip-"$version"-mojmap.jar "$jarName"
|
|
||||||
{
|
|
||||||
echo "name=$divinemcid"
|
|
||||||
echo "tag=$tagid"
|
|
||||||
echo "jar=$jarName"
|
|
||||||
echo "info=$changelog"
|
|
||||||
echo "experimental=$experimental"
|
|
||||||
echo "make_latest=$make_latest"
|
|
||||||
} >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
{
|
|
||||||
echo "### 📜 Commits"
|
|
||||||
if [ "$experimental" = "true" ]; then
|
|
||||||
echo "> [!WARNING]"
|
|
||||||
echo "> This is an experimental build, it may contain bugs and issues. Use at your own risk."
|
|
||||||
echo "> **Backups are mandatory!**"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
} >> $changelog
|
|
||||||
|
|
||||||
number=$(git log --oneline ver/1.21.10 ^"$(git describe --tags --abbrev=0)" | wc -l)
|
|
||||||
git log --pretty='- [`%h`](https://github.com/BX-Team/DivineMC/commit/%H) %s' "-$number" >> $changelog
|
|
||||||
|
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "### 🔒 Checksums"
|
|
||||||
echo "| File | $jarName |"
|
|
||||||
echo "| ---- | ---- |"
|
|
||||||
echo "| MD5 | $(md5 "$jarName") |"
|
|
||||||
echo "| SHA1 | $(sha1 "$jarName") |"
|
|
||||||
echo "| SHA256 | $(sha256 "$jarName") |"
|
|
||||||
} >> $changelog
|
|
||||||
67
scripts/uploadBuild.sh
Normal file
67
scripts/uploadBuild.sh
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
prop() {
|
||||||
|
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -z "$API_URL" ] && { echo "Error: API_URL not set"; exit 1; }
|
||||||
|
[ -z "$API_KEY" ] && { echo "Error: API_KEY not set"; exit 1; }
|
||||||
|
[ -z "$PROJECT_KEY" ] && { echo "Error: PROJECT_KEY not set"; exit 1; }
|
||||||
|
|
||||||
|
MC_VERSION=$(prop mcVersion)
|
||||||
|
[ -z "$MC_VERSION" ] && { echo "Error: mcVersion not found in gradle.properties"; exit 1; }
|
||||||
|
|
||||||
|
VERSION_BRANCH=${VERSION_BRANCH:-"ver/$MC_VERSION"}
|
||||||
|
|
||||||
|
if [ "$(prop experimental)" = "true" ]; then
|
||||||
|
CHANNEL="BETA"
|
||||||
|
else
|
||||||
|
CHANNEL="STABLE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
if [ -n "$LAST_TAG" ]; then
|
||||||
|
COMMIT_COUNT=$(git log --oneline "$VERSION_BRANCH" ^"$LAST_TAG" 2>/dev/null | wc -l | tr -d ' ')
|
||||||
|
else
|
||||||
|
COMMIT_COUNT=$(git log --oneline "$VERSION_BRANCH" 2>/dev/null | wc -l | tr -d ' ')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$COMMIT_COUNT" -gt 0 ]; then
|
||||||
|
COMMITS_JSON=$(git log --pretty='{"sha":"%H","message":"%s","time":"%cI"}' "$VERSION_BRANCH" -"$COMMIT_COUNT" | \
|
||||||
|
sed ':a;N;$!ba;s/\n/,/g' | \
|
||||||
|
sed 's/"/\\"/g' | \
|
||||||
|
sed 's/\\\\"/\\"/g')
|
||||||
|
COMMITS_JSON="[$COMMITS_JSON]"
|
||||||
|
else
|
||||||
|
COMMITS_JSON="[]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
METADATA=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"channel": "$CHANNEL",
|
||||||
|
"commits": $COMMITS_JSON
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Uploading: $PROJECT_KEY $MC_VERSION ($CHANNEL)"
|
||||||
|
|
||||||
|
UPLOAD_RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||||
|
-X POST "$API_URL/v2/projects/$PROJECT_KEY/versions/$MC_VERSION/builds/upload" \
|
||||||
|
-H "x-api-key: $API_KEY" \
|
||||||
|
-F "file=@$JAR_FILE" \
|
||||||
|
-F "metadata=$METADATA")
|
||||||
|
|
||||||
|
HTTP_BODY=$(echo "$UPLOAD_RESPONSE" | head -n -1)
|
||||||
|
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 201 ]; then
|
||||||
|
BUILD_ID=$(echo "$HTTP_BODY" | grep -o '"id":[0-9]*' | grep -o '[0-9]*')
|
||||||
|
echo "✓ Build #$BUILD_ID uploaded successfully"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "✗ Upload failed (HTTP $HTTP_CODE)"
|
||||||
|
echo "$HTTP_BODY"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user