Skip to content

Commit e09cc6f

Browse files
committed
Build with multiple Java versions in CI
1 parent 83cf6e8 commit e09cc6f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ concurrency:
55
group: ${{ github.workflow }}-${{ github.ref }}
66
cancel-in-progress: true
77

8+
env:
9+
DEFAULT_JAVA_VERSION: 21
10+
811
jobs:
912
build:
10-
name: Build
13+
name: Build for Java ${{ matrix.java }}
1114
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
java:
19+
- 21
20+
- 22
21+
- 23
1222
steps:
1323
- name: 'Checkout'
1424
uses: actions/checkout@v4
@@ -19,8 +29,8 @@ jobs:
1929
- name: 'Setup Java'
2030
uses: actions/setup-java@v4
2131
with:
22-
distribution: 'microsoft'
23-
java-version: 21
32+
distribution: 'adopt-hotspot'
33+
java-version: ${{ matrix.java }}
2434
- name: 'Setup Gradle'
2535
uses: gradle/actions/setup-gradle@v3
2636
with:
@@ -64,17 +74,17 @@ jobs:
6474
if-no-files-found: error
6575
path: build/libs/*
6676
- name: 'Deploy to CurseForge'
67-
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
77+
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
6878
env:
6979
CURSEFORGE_KEY_SECRET: ${{ secrets.CURSEFORGE_KEY_SECRET }}
7080
run: ./gradlew publishCurseForge
7181
- name: 'Deploy to Modrinth'
72-
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
82+
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
7383
env:
7484
MODRINTH_KEY_SECRET: ${{ secrets.MODRINTH_KEY_SECRET }}
7585
run: ./gradlew modrinth
7686
- name: 'Deploy to Maven'
77-
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature')
87+
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
7888
env:
7989
MAVEN_URL: ${{ secrets.MAVEN_URL }}
8090
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}

0 commit comments

Comments
 (0)