From d2417540ee96f520c447ac13685dddb5669e792f Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:30:33 -0500 Subject: [PATCH] Update workflow * Separate build and pr build workflows * Expose build number env var to Leaf --- .github/workflows/build-1214.yml | 15 ++++++----- .github/workflows/build-pr.yml | 40 ++++++++++++++++++++++++++++++ leaf-server/build.gradle.kts.patch | 10 +++++++- 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build-pr.yml diff --git a/.github/workflows/build-1214.yml b/.github/workflows/build-1214.yml index dc191a35..4f4d29b0 100644 --- a/.github/workflows/build-1214.yml +++ b/.github/workflows/build-1214.yml @@ -3,12 +3,13 @@ name: Build Leaf 1.21.4 on: push: branches: [ "ver/1.21.4" ] - pull_request: - branches: [ "ver/1.21.4" ] jobs: build: runs-on: blacksmith-8vcpu-ubuntu-2204 + env: + RUN_NUMBER: ${{ github.run_number }} + steps: - uses: actions/checkout@main - name: Set up JDK @@ -32,11 +33,10 @@ jobs: - name: Rename Paperclip Jar run: | - mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-mojmap.jar - mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-reobf.jar + mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-$RUN_NUMBER-mojmap.jar + mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-$RUN_NUMBER-reobf.jar - name: Publish API - if: github.event_name != 'pull_request' continue-on-error: true run: | echo "REPO_USER=${{ secrets.REPO_USER }}" >> $GITHUB_ENV @@ -55,16 +55,15 @@ jobs: - name: Rename Leaf Jar run: | - mv ./leaf-1.21.4-mojmap.jar ./leaf-1.21.4.jar + mv ./leaf-1.21.4-$RUN_NUMBER-mojmap.jar ./leaf-1.21.4-$RUN_NUMBER.jar # TODO: marvinpinto/action-automatic-releases is archived, need to find new one # Notes: create releases every time, similar changelogs with this, all commits for changelogs - name: Release Leaf - if: github.event_name != 'pull_request' uses: marvinpinto/action-automatic-releases@master with: title: "Leaf 1.21.4" automatic_release_tag: "ver-1.21.4" repo_token: "${{ secrets.GITHUB_TOKEN }}" - files: "./leaf-1.21.4.jar" + files: "./leaf-1.21.4-$RUN_NUMBER.jar" prerelease: false diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 00000000..63470e6e --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,40 @@ +name: Build Pull Request + +on: + pull_request: + branches: [ "ver/1.21.4" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Set up JDK + uses: graalvm/setup-graalvm@main + with: + java-version: 21 + github-token: "${{ secrets.GITHUB_TOKEN }}" + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Configure Git + run: git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions" + + - name: Apply patches + run: ./gradlew -Dorg.gradle.jvmargs="-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true --add-modules jdk.incubator.vector" applyAllPatches --stacktrace --no-daemon + - name: Create MojmapPaperclipJar + run: ./gradlew -Dorg.gradle.jvmargs="-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true --add-modules jdk.incubator.vector" createMojmapPaperclipJar --stacktrace --no-daemon + - name: Create ReobfPaperclipJar + run: ./gradlew -Dorg.gradle.jvmargs="-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true --add-modules jdk.incubator.vector" -Dpaperweight.debug=true createReobfPaperclipJar --stacktrace --no-daemon + + - name: Rename Paperclip Jar + run: | + mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-mojmap.jar + mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-reobf.jar + + - name: Upload Leaf + uses: actions/upload-artifact@main + with: + name: Leaf 1.21.4 + path: ./leaf-1.21.4-*.jar diff --git a/leaf-server/build.gradle.kts.patch b/leaf-server/build.gradle.kts.patch index 1b06de2d..ff3cbaa9 100644 --- a/leaf-server/build.gradle.kts.patch +++ b/leaf-server/build.gradle.kts.patch @@ -169,7 +169,15 @@ } // Gale start - hide irrelevant compilation warnings -@@ -226,14 +_,14 @@ +@@ -219,21 +_,21 @@ + val git = Git(rootProject.layout.projectDirectory.path) + val mcVersion = rootProject.providers.gradleProperty("mcVersion").get() + val build = System.getenv("BUILD_NUMBER") ?: null +- val buildTime = Instant.now() // Gale - branding changes - we don't have ci yet ++ val buildTime = Instant.now() // Leaf - Rebrand - Always use current for build time + val gitHash = git.exec(providers, "rev-parse", "--short=7", "HEAD").get().trim() + val implementationVersion = "$mcVersion-${build ?: "DEV"}-$gitHash" + val date = git.exec(providers, "show", "-s", "--format=%ci", gitHash).get().trim() val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() attributes( "Main-Class" to "org.bukkit.craftbukkit.Main",