From c50b78e09c1c679dc66c78c532a04d44ba57205d Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Mon, 29 Sep 2025 00:00:58 +0200 Subject: [PATCH 1/3] chore: Build mod in CI --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++++++++ .gitignore | 5 ++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..10a48a0a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build Mod + +on: + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: "8" + distribution: "temurin" + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build with Gradle + run: ./gradlew build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: success() + with: + name: mod-jars + path: build/libs/*.jar + retention-days: 30 + + - name: Upload build artifacts (on failure) + uses: actions/upload-artifact@v4 + if: failure() + with: + name: build-logs + path: | + build/logs/ + .gradle/ + retention-days: 7 diff --git a/.gitignore b/.gitignore index 5bc1827a..8d8de3e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ /* +!/.github !/build\.gradle !/gradle\.properties !/src !/misc !/gradle -!gradlew -!gradlew.bat +!/gradlew +!/gradlew.bat From 2692af4b9209aa25b8f49090607c42042da45628 Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Mon, 29 Sep 2025 00:08:12 +0200 Subject: [PATCH 2/3] Update build.yml --- .github/workflows/build.yml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10a48a0a..b998eab4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,13 +34,40 @@ jobs: - name: Build with Gradle run: ./gradlew build - - name: Upload build artifacts - uses: actions/upload-artifact@v4 + - name: Upload JAR artifacts if: success() + run: | + for jar in build/libs/*.jar; do + if [ -f "$jar" ]; then + artifact_name=$(basename "$jar" .jar) + echo "Uploading $jar as $artifact_name" + gh actions upload-artifact --name "$artifact_name" --path "$jar" --retention-days 30 + fi + done + + - name: Comment PR with artifact URLs + if: success() && github.event_name == 'pull_request' + uses: actions/github-script@v7 with: - name: mod-jars - path: build/libs/*.jar - retention-days: 30 + script: | + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + }); + + let comment = '🦾 Fresh bends, straight out the oven, ready to be tested out:\n'; + for (const artifact of artifacts.data.artifacts) { + const download_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts/${artifact.id}`; + comment += `- [${artifact.name}](${download_url})\n`; + } + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment, + }); - name: Upload build artifacts (on failure) uses: actions/upload-artifact@v4 From 6d019d88bc4128b405a7d1026332a7a75b53feae Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Mon, 29 Sep 2025 00:16:24 +0200 Subject: [PATCH 3/3] Gone back to uploading a single zip file --- .github/workflows/build.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b998eab4..d716e279 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,16 +34,13 @@ jobs: - name: Build with Gradle run: ./gradlew build - - name: Upload JAR artifacts + - name: Upload build artifacts + uses: actions/upload-artifact@v4 if: success() - run: | - for jar in build/libs/*.jar; do - if [ -f "$jar" ]; then - artifact_name=$(basename "$jar" .jar) - echo "Uploading $jar as $artifact_name" - gh actions upload-artifact --name "$artifact_name" --path "$jar" --retention-days 30 - fi - done + with: + name: mod-jars + path: build/libs/*.jar + retention-days: 30 - name: Comment PR with artifact URLs if: success() && github.event_name == 'pull_request'