diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..db9e5eb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,75 @@ +name: Build + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: build-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.set-matrix.outputs.versions }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Detect supported Minecraft versions + id: set-matrix + shell: bash + run: | + versions=$(for d in versions/*/; do [ -f "${d}gradle.properties" ] && basename "$d"; done | sort -V) + [ -n "$versions" ] || { echo "No version folders found under versions/" >&2; exit 1; } + json="["; sep="" + while IFS= read -r v; do + [ -n "$v" ] || continue + json+="${sep}\"${v}\""; sep="," + done <<< "$versions" + json+="]" + echo "versions=$json" >> "$GITHUB_OUTPUT" + + build: + needs: matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + mc: ${{ fromJson(needs.matrix.outputs.versions) }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build (${{ matrix.mc }}) + run: ./gradlew "${{ matrix.mc }}:build" --no-daemon + + - name: Prepare publish-builds (${{ matrix.mc }}) + shell: bash + run: | + # Allow missing files for other MC versions + bash ./copybuilds.sh || true + + - name: Upload artifact (${{ matrix.mc }}) + uses: actions/upload-artifact@v4 + with: + name: tt20-${{ matrix.mc }} + if-no-files-found: error + path: | + publish-builds/*.jar diff --git a/copybuilds.sh b/copybuilds.sh index a7202a2..3d9301c 100755 --- a/copybuilds.sh +++ b/copybuilds.sh @@ -9,3 +9,4 @@ cp versions/1.20.5/build/libs/tt20-0.7.2.jar publish-builds/tt20-0.7.2+mc1.20.5. cp versions/1.21/build/libs/tt20-0.7.2.jar publish-builds/tt20-0.7.2+mc1.21.jar cp versions/1.21.2/build/libs/tt20-0.7.2.jar publish-builds/tt20-0.7.2+mc1.21.2.jar cp versions/1.21.9/build/libs/tt20-0.7.2.jar publish-builds/tt20-0.7.2+mc1.21.9.jar +cp versions/1.21.11/build/libs/tt20-0.7.2.jar publish-builds/tt20-0.7.2+mc1.21.11.jar