Skip to content

Commit 4f6c902

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

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@ 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+
- 17
20+
- 18
21+
- 19
22+
- 20
23+
- 21
24+
- 22
25+
- 23
1226
steps:
1327
- name: 'Checkout'
1428
uses: actions/checkout@v4
@@ -19,8 +33,8 @@ jobs:
1933
- name: 'Setup Java'
2034
uses: actions/setup-java@v4
2135
with:
22-
distribution: 'microsoft'
23-
java-version: 21
36+
distribution: 'adopt-hotspot'
37+
java-version: ${{ matrix.java }}
2438
- name: 'Setup Gradle'
2539
uses: gradle/actions/setup-gradle@v3
2640
with:
@@ -60,21 +74,22 @@ jobs:
6074
uses: coverallsapp/github-action@v2
6175
- name: 'Deploy as GitHub CI artifacts'
6276
uses: actions/upload-artifact@v4
77+
if: startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
6378
with:
6479
if-no-files-found: error
6580
path: build/libs/*
6681
- name: 'Deploy to CurseForge'
67-
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)
6883
env:
6984
CURSEFORGE_KEY_SECRET: ${{ secrets.CURSEFORGE_KEY_SECRET }}
7085
run: ./gradlew publishCurseForge
7186
- name: 'Deploy to Modrinth'
72-
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
87+
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
7388
env:
7489
MODRINTH_KEY_SECRET: ${{ secrets.MODRINTH_KEY_SECRET }}
7590
run: ./gradlew modrinth
7691
- name: 'Deploy to Maven'
77-
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature')
92+
if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature') && startsWith(matrix.java, env.DEFAULT_JAVA_VERSION)
7893
env:
7994
MAVEN_URL: ${{ secrets.MAVEN_URL }}
8095
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}

0 commit comments

Comments
 (0)