Skip to content

Commit

Permalink
Build with multiple Java versions in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jan 9, 2025
1 parent 83cf6e8 commit 02b2457
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DEFAULT_JAVA_VERSION: 21

jobs:
build:
name: Build
name: Build for Java ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java:
- 21
- 22
- 23
steps:
- name: 'Checkout'
uses: actions/checkout@v4
Expand All @@ -20,7 +30,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: 21
java-version: ${{ matrix.java }}
- name: 'Setup Gradle'
uses: gradle/actions/setup-gradle@v3
with:
Expand Down Expand Up @@ -64,17 +74,17 @@ jobs:
if-no-files-found: error
path: build/libs/*
- name: 'Deploy to CurseForge'
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
env:
CURSEFORGE_KEY_SECRET: ${{ secrets.CURSEFORGE_KEY_SECRET }}
run: ./gradlew publishCurseForge
- name: 'Deploy to Modrinth'
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
env:
MODRINTH_KEY_SECRET: ${{ secrets.MODRINTH_KEY_SECRET }}
run: ./gradlew modrinth
- name: 'Deploy to Maven'
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature')
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
Expand Down

0 comments on commit 02b2457

Please sign in to comment.