Change maven building to a matrix workflow #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Java CI with Maven | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build-spigot: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java-version: [ 8, 17, 21 ] | |
name: Build Spigot (JDK ${{ matrix.java-version }}) | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup JDK ${{ matrix.java-version }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: "temurin" | |
cache: maven | |
- name: Build Spigot (JDK 8) | |
if: matrix.java-version == 8 | |
uses: SpraxDev/Action-SpigotMC@v4 | |
with: | |
versions: 1.16.5, 1.16.3, 1.16.1, 1.15.2, 1.14.4, 1.13.2, 1.13, 1.12.2 | |
remapped: true | |
- name: Build Spigot (JDK 17) | |
if: matrix.java-version == 17 | |
uses: SpraxDev/Action-SpigotMC@v4 | |
with: | |
versions: 1.20.1, 1.19, 1.18.2, 1.18.1, 1.17.1 | |
remapped: true | |
- name: Build Spigot (JDK 21) | |
if: matrix.java-version == 21 | |
uses: SpraxDev/Action-SpigotMC@v4 | |
with: | |
versions: 1.21, 1.20.6, 1.20.4, 1.20.2 | |
remapped: true | |
- name: Archive Maven Repository | |
run: tar -cf maven-repo-${{ matrix.java-version }}.tar -C ~/.m2/repository . | |
- name: Upload Maven Repository | |
uses: actions/upload-artifact@v3 | |
with: | |
name: maven-repo-${{ matrix.java-version }} | |
path: maven-repo-${{ matrix.java-version }}.tar | |
build-maven: | |
runs-on: ubuntu-latest | |
needs: build-spigot | |
name: Build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 21 | |
distribution: "temurin" | |
cache: maven | |
- name: Download Maven Repositories (JDK 8) | |
uses: actions/download-artifact@v3 | |
with: | |
name: maven-repo-8 | |
path: maven-repo-8.tar.gz | |
- name: Download Maven Repositories (JDK 17) | |
uses: actions/download-artifact@v3 | |
with: | |
name: maven-repo-17 | |
path: maven-repo-17.tar.gz | |
- name: Download Maven Repositories (JDK 21) | |
uses: actions/download-artifact@v3 | |
with: | |
name: maven-repo-21 | |
path: maven-repo-21.tar.gz | |
- name: Extract Maven Repositories | |
run: | | |
mkdir -p ~/.m2/repository | |
tar --overwrite -xf maven-repo-8.tar -C ~/.m2/repository | |
tar --overwrite -xf maven-repo-17.tar -C ~/.m2/repository | |
tar --overwrite -xf maven-repo-21.tar -C ~/.m2/repository | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
- name: Cache Maven | |
id: cache-primes | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.m2 | |
~/repository | |
key: ${{ github.job }}-${{ hashFiles('**/pom.xml') }} |