From fc4a20a39024471f16f78c90cfbfbd37ee7396b7 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:19:10 +0800 Subject: Update jar name and add build type --- .github/workflows/beta.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index e1d3427c..64a4b2f9 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - bleeding-edge paths-ignore: - 'src/main/resources/assets/skyblocker/lang/**' - 'CHANGELOG.md' @@ -16,6 +17,9 @@ on: - 'CHANGELOG.md' - 'FEATURES.md' - 'README.md' +env: + REF_NAME: ${{ github.ref_name }} + PR_NUMBER: ${{ github.event.number }} jobs: # This workflow contains a single job called "build" @@ -31,9 +35,16 @@ jobs: with: result-encoding: string script: | + let buildType; + if (!process.env.PR_NUMBER) { + buildType = process.env.REF_NAME === "bleeding-edge" ? "alpha" : "beta"; + } else { + buildType = `pr-${process.env.PR_NUMBER}`; + } + const fs = require("fs"); let file = fs.readFileSync("./gradle.properties"); - file = file.toString().split("\n").map(e => e.trim().startsWith("mod_version") ? `${e}-beta-${process.env.GITHUB_SHA.substring(0, 7)}` : e).join("\n"); + file = file.toString().split("\n").map(e => e.trim().startsWith("mod_version") ? `${e}-${buildType}-${process.env.GITHUB_SHA.substring(0, 7)}` : e).join("\n"); fs.writeFileSync("./gradle.properties", file); - name: Set up JDK 21 -- cgit From 404de46cd43ca1e8678381ab507afdc6a41fe177 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:23:10 +0800 Subject: Add name and logging --- .github/workflows/beta.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 64a4b2f9..b78b72e8 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -31,7 +31,8 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 - - uses: actions/github-script@v7 + - name: Set jar name + uses: actions/github-script@v7 with: result-encoding: string script: | @@ -41,6 +42,7 @@ jobs: } else { buildType = `pr-${process.env.PR_NUMBER}`; } + console.log(`Set build type to ${buildType}`); const fs = require("fs"); let file = fs.readFileSync("./gradle.properties"); -- cgit From 0042532eef6e379adb7cbae47bb73f1da4c3e740 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:36:28 +0800 Subject: Update build script to include alpha or beta for all builds --- .github/workflows/beta.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index b78b72e8..9c93a36d 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -29,7 +29,8 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Set jar name uses: actions/github-script@v7 @@ -37,12 +38,11 @@ jobs: result-encoding: string script: | let buildType; - if (!process.env.PR_NUMBER) { - buildType = process.env.REF_NAME === "bleeding-edge" ? "alpha" : "beta"; - } else { - buildType = `pr-${process.env.PR_NUMBER}`; + buildType = process.env.REF_NAME === "master" || process.env.REF_NAME === "main" ? "beta" : "alpha"; + if (process.env.PR_NUMBER) { + buildType += `-pr-${process.env.PR_NUMBER}`; } - console.log(`Set build type to ${buildType}`); + console.log(`Set build type to ${buildType}.`); const fs = require("fs"); let file = fs.readFileSync("./gradle.properties"); @@ -81,7 +81,8 @@ jobs: **/build/reports/ **/build/test-results/ - - uses: actions/github-script@v7 + - name: Process artifacts + uses: actions/github-script@v7 id: fname with: result-encoding: string @@ -89,7 +90,8 @@ jobs: const fs = require("fs") return fs.readdirSync("build/libs/").filter(e => !e.endsWith("dev.jar") && !e.endsWith("sources.jar") && e.endsWith(".jar"))[0].replace(".jar", ""); - - uses: actions/upload-artifact@v4 + - name: Upload artifacts + uses: actions/upload-artifact@v4 with: name: ${{ steps.fname.outputs.result }} path: build/libs/ -- cgit From 37fae048b01a9d9cd82aa9e2e3582d611cd78ae1 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:55:55 +0800 Subject: Fix pr commit sha `process.env.GITHUB_SHA` contains the merge sha for the pr, not the actual latest commit of the pr --- .github/workflows/beta.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 9c93a36d..29690e75 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -20,6 +20,7 @@ on: env: REF_NAME: ${{ github.ref_name }} PR_NUMBER: ${{ github.event.number }} + PR_SHA: ${{ github.event.pull_request.head.sha }} jobs: # This workflow contains a single job called "build" @@ -38,15 +39,19 @@ jobs: result-encoding: string script: | let buildType; + let commitSha; buildType = process.env.REF_NAME === "master" || process.env.REF_NAME === "main" ? "beta" : "alpha"; if (process.env.PR_NUMBER) { buildType += `-pr-${process.env.PR_NUMBER}`; + commitSha = process.env.PR_SHA; + } else { + commitSha = process.env.GITHUB_SHA; } - console.log(`Set build type to ${buildType}.`); + console.log(`Set build type to ${buildType} and commit sha to ${commitSha}`); const fs = require("fs"); let file = fs.readFileSync("./gradle.properties"); - file = file.toString().split("\n").map(e => e.trim().startsWith("mod_version") ? `${e}-${buildType}-${process.env.GITHUB_SHA.substring(0, 7)}` : e).join("\n"); + file = file.toString().split("\n").map(e => e.trim().startsWith("mod_version") ? `${e}-${buildType}-${commitSha.substring(0, 7)}` : e).join("\n"); fs.writeFileSync("./gradle.properties", file); - name: Set up JDK 21 -- cgit From 282202e468a4c622679d0825c06a62cf07fb82e9 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:36:24 +0800 Subject: Add workflow dispatch --- .github/workflows/beta.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 29690e75..88f4842f 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -1,6 +1,7 @@ name: Build Beta on: + workflow_dispatch: merge_group: push: branches: -- cgit