Skip to content

Commit 6f5e9de

Browse files
committed
Support all java versions based on branch in deploy.yml
1 parent 624129c commit 6f5e9de

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,35 @@ env:
2222
BRANCH: ${{ github.event.inputs.branch || github.ref_name }}
2323

2424
jobs:
25+
setup:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
java-versions: ${{ steps.set-matrix.outputs.versions }}
29+
steps:
30+
- name: Determine JDK versions based on branch
31+
id: set-matrix
32+
run: |
33+
BRANCH="${{ env.BRANCH }}"
34+
# Define JDK versions for each branch
35+
# Main branch supports all versions
36+
if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "4.3.x" ]]; then
37+
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
38+
if [[ "$BRANCH" == "4.2.x" ]] || [[ "$BRANCH" == "4.1.x" ]]; then
39+
echo 'versions=["17","21",]' >> $GITHUB_OUTPUT
40+
if [[ "$BRANCH" == "3.1.x" ]]; then
41+
echo 'versions=["8","11","17"]' >> $GITHUB_OUTPUT
42+
# Default: use all versions if branch not specified
43+
else
44+
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
45+
fi
46+
2547
build:
48+
needs: setup
2649
runs-on: ubuntu-latest
2750
timeout-minutes: 60
51+
strategy:
52+
matrix:
53+
java-version: ${{ fromJson(needs.setup.outputs.java-versions) }}
2854

2955
steps:
3056
- name: Checkout code
@@ -33,10 +59,10 @@ jobs:
3359
ref: ${{ env.BRANCH }}
3460
clean: true # Equivalent to WipeWorkspace extension
3561

36-
- name: Set up JDK 17
62+
- name: Set up JDK ${{ matrix.java-version }}
3763
uses: actions/setup-java@v4
3864
with:
39-
java-version: '17'
65+
java-version: ${{ matrix.java-version }}
4066
distribution: 'temurin' # OpenJDK distribution
4167
cache: 'maven'
4268
server-id: repo.spring.io

0 commit comments

Comments
 (0)