diff --git a/.github/workflows/build-12110.yml b/.github/workflows/build-12110.yml index f02d5de..e32f4d4 100644 --- a/.github/workflows/build-12110.yml +++ b/.github/workflows/build-12110.yml @@ -10,10 +10,10 @@ jobs: build: runs-on: blacksmith-8vcpu-ubuntu-2204 if: "!contains(github.event.commits[0].message, '[ci-skip]')" - env: - BUILD_NUMBER: ${{ github.run_number }} outputs: build_number: ${{ env.BUILD_NUMBER }} + jar_file: ${{ steps.prepare_jar.outputs.jar_file }} + version: ${{ steps.prepare_jar.outputs.version }} steps: - name: Checkout repository uses: actions/checkout@v5 @@ -56,6 +56,7 @@ jobs: git config --global core.fscache true git config --global gc.auto 256 chmod +x gradlew + chmod +x scripts/uploadBuild.sh - name: Apply Patches run: | @@ -65,18 +66,23 @@ jobs: - name: Build Paperclip Jar run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel --no-daemon - - name: Prepare Release Info - run: bash scripts/releaseInfo.sh - env: - BUILD_NUMBER: ${{ env.BUILD_NUMBER }} + - name: Prepare and Move Paperclip Jar + id: prepare_jar + run: | + 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 - uses: ncipollo/release-action@v1.15.0 - with: - artifacts: ${{ env.jar }} - bodyFile: ${{ env.info }} - tag: ${{ env.tag }} - name: ${{ env.name }} - prerelease: ${{ env.experimental }} - token: ${{ secrets.GITHUB_TOKEN }} - makeLatest: ${{ env.make_latest }} + - name: Upload to API + env: + API_URL: 'https://api.bxteam.org' + API_KEY: ${{ secrets.ATLAS_API_KEY }} + PROJECT_KEY: 'divinemc' + VERSION_BRANCH: 'ver/1.21.10' + BUILD_NUMBER: ${{ github.run_number }} + JAR_FILE: ${{ env.JAR_FILE }} + run: bash scripts/uploadBuild.sh diff --git a/divinemc-api/build.gradle.kts.patch b/divinemc-api/build.gradle.kts.patch index 759c0fa..932834d 100644 --- a/divinemc-api/build.gradle.kts.patch +++ b/divinemc-api/build.gradle.kts.patch @@ -23,7 +23,7 @@ + api("com.google.guava:guava:33.4.0-jre") // DivineMC - Bump dependencies api("com.google.code.gson:gson:2.11.0") - api("org.yaml:snakeyaml:2.2") -+ api("org.yaml:snakeyaml:2.3") // DivineMC - Bump dependencies ++ api("org.yaml:snakeyaml:2.5") // DivineMC - Bump dependencies api("org.joml:joml:1.10.8") { isTransitive = false // https://github.com/JOML-CI/JOML/issues/352 } diff --git a/divinemc-server/build.gradle.kts.patch b/divinemc-server/build.gradle.kts.patch index 4626bfe..cdc9a13 100644 --- a/divinemc-server/build.gradle.kts.patch +++ b/divinemc-server/build.gradle.kts.patch @@ -72,7 +72,7 @@ } } val log4jPlugins = sourceSets.create("log4jPlugins") { -@@ -154,10 +_,23 @@ +@@ -154,10 +_,22 @@ } dependencies { @@ -80,7 +80,6 @@ + implementation(project(":divinemc-api")) // DivineMC - Rebrand + + // DivineMC start - Dependencies -+ implementation("org.yaml:snakeyaml:2.3") + implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { + exclude(group="org.yaml", module="snakeyaml") + } diff --git a/divinemc-server/paper-patches/features/0001-Rebrand.patch b/divinemc-server/paper-patches/features/0001-Rebrand.patch index 088a2a8..f9b0708 100644 --- a/divinemc-server/paper-patches/features/0001-Rebrand.patch +++ b/divinemc-server/paper-patches/features/0001-Rebrand.patch @@ -27,7 +27,7 @@ index 6194d6d8952864c71cc4017a639b818e4ecccea9..46e62dead64e18691122a6dfaa1df77a metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); 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 +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -36,7 +36,7 @@ public class PaperVersionFetcher implements VersionFetcher { @@ -35,7 +35,7 @@ index a5a7334f7a1f147945079f20aa04b4f317d9e94c..5f595378d68fb9e3f069fdb6cbd70e89 private static final int DISTANCE_UNKNOWN = -2; // Purpur start - Rebrand - 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; } // Purpur end - Rebrand @@ -48,58 +48,39 @@ index a5a7334f7a1f147945079f20aa04b4f317d9e94c..5f595378d68fb9e3f069fdb6cbd70e89 } final @Nullable Component history = this.getHistory(); -@@ -60,18 +60,13 @@ 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 gitBranch = build.gitBranch(); -- final Optional gitCommit = build.gitCommit(); -- if (gitBranch.isPresent() && gitCommit.isPresent()) { -- distance = fetchDistanceFromGitHub(repo, gitBranch.get(), gitCommit.get()); -- } -+ // DivineMC start - Rebrand -+ final Optional gitBranch = build.gitBranch(); -+ final Optional 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 { +@@ -86,18 +86,18 @@ public class PaperVersionFetcher implements VersionFetcher { }; } - private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) { -- try { -- try (final BufferedReader reader = Resources.asCharSource( ++ // DivineMC start - Rebrand ++ 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 -- StandardCharsets.UTF_8 -- ).openBufferedStream()) { -- final JsonObject json = new Gson().fromJson(reader, JsonObject.class); ++ URI.create("https://api.bxteam.org/v2/projects/divinemc/versions/" + build.minecraftVersionId() + "/builds/latest").toURL(), + StandardCharsets.UTF_8 + ).openBufferedStream()) { + final JsonObject json = new Gson().fromJson(reader, JsonObject.class); - //final JsonArray builds = json.getAsJsonArray("builds"); // Purpur - Rebrand - final int latest = json.getAsJsonObject("builds").getAsJsonPrimitive("latest").getAsInt(); // Purpur - Rebrand - 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 -- return DISTANCE_ERROR; -- } -- } catch (final IOException e) { -- LOGGER.error("Error while parsing version", e); -- return DISTANCE_ERROR; -- } -- } -- ++ LOGGER.error("Error parsing json from DivineMC's downloads API", ex); + return DISTANCE_ERROR; + } + } catch (final IOException e) { +@@ -105,6 +105,7 @@ public class PaperVersionFetcher implements VersionFetcher { + return DISTANCE_ERROR; + } + } ++ // DivineMC end - Rebrand + // Contributed by Techcable in GH-65 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 index bc7e4e5560708fea89c584b1d8b471f4966f311a..6567ff18cb1c21230565c2d92caf3a7f7f915c17 100644 --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java diff --git a/scripts/releaseInfo.sh b/scripts/releaseInfo.sh deleted file mode 100644 index 1e6b54b..0000000 --- a/scripts/releaseInfo.sh +++ /dev/null @@ -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 diff --git a/scripts/uploadBuild.sh b/scripts/uploadBuild.sh new file mode 100644 index 0000000..09de83b --- /dev/null +++ b/scripts/uploadBuild.sh @@ -0,0 +1,76 @@ +#!/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="[" + FIRST=true + while IFS= read -r sha && IFS= read -r message && IFS= read -r time; do + if [ "$FIRST" = true ]; then + FIRST=false + else + COMMITS_JSON="$COMMITS_JSON," + fi + + message=$(echo "$message" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed 's/\t/\\t/g' | tr -d '\n\r') + COMMITS_JSON="$COMMITS_JSON{\"sha\":\"$sha\",\"message\":\"$message\",\"time\":\"$time\"}" + done < <(git log --pretty='%H%n%s%n%cI' "$VERSION_BRANCH" -"$COMMIT_COUNT") + COMMITS_JSON="$COMMITS_JSON]" +else + COMMITS_JSON="[]" +fi + +METADATA=$(cat <