116 lines
3.1 KiB
YAML
116 lines
3.1 KiB
YAML
name: Java CI with Gradle
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
env:
|
|
MARKER: '🎈'
|
|
|
|
jobs:
|
|
define-versions:
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
versions: ${{ steps.versions.outputs.versions }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Define Versions
|
|
id: versions
|
|
run: |
|
|
versions="["
|
|
for item in $(ls mc); do
|
|
versions+="\"$item\", "
|
|
done
|
|
|
|
versions="${versions%,*}]"
|
|
echo "versions=$versions" >> "$GITHUB_OUTPUT"
|
|
- name: Ensure that versions.json includes all versions
|
|
run: node -e 'const fs = require("fs"); const versions = JSON.parse(fs.readFileSync("versions.json", "utf8")); const expectedVersions = fs.readdirSync("mc"); if (expectedVersions.length !== versions.length || !expectedVersions.every(v => versions.includes(v))) { throw new Error("versions.json does not match the expected versions in mc/ folder"); }'
|
|
|
|
build:
|
|
needs: define-versions
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
version: ${{ fromJSON(needs.define-versions.outputs.versions) }}
|
|
|
|
name: Build ${{ matrix.version }}
|
|
timeout-minutes: 10
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Validate Gradle wrapper
|
|
uses: gradle/actions/wrapper-validation@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v4
|
|
with:
|
|
add-job-summary-as-pr-comment: on-failure
|
|
|
|
- name: Generate ${{ matrix.version }}
|
|
run: ./gradlew :mc:${{ matrix.version }}:runServer --stacktrace
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: data-${{ matrix.version }}
|
|
path: mc/${{ matrix.version }}/run/server/minecraft-data
|
|
if-no-files-found: error
|
|
|
|
repackage:
|
|
needs: build
|
|
|
|
name: Repackage versions
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- run: npm install
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Upload artifact
|
|
id: uploadMerged
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: merged-data
|
|
path: artifacts/*
|
|
if-no-files-found: error
|
|
|
|
- name: Sending artifacts to minecraft-data
|
|
# Check if PR starts with marker
|
|
if: startsWith(github.event.pull_request.title, env.MARKER)
|
|
env:
|
|
ARTIFACT_URL: ${{ steps.uploadMerged.outputs.artifact-url }}
|
|
GITHUB_TOKEN: ${{ secrets.PAT_PASSWORD }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: node .github/commands/send.js
|