diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d716e279 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,77 @@ +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: Comment PR with artifact URLs + if: success() && github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + 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 + 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