Skip to content

Commit a6485fc

Browse files
docs:simplify GitHub Actions. (#1514)
1 parent 71a8dcf commit a6485fc

10 files changed

+167
-250
lines changed

.github/workflows/codecov_jdk17.yml

-34
This file was deleted.

.github/workflows/codecov_jdk8.yml

-36
This file was deleted.

.github/workflows/junit.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Junit Test
2+
3+
on:
4+
push:
5+
branches:
6+
- 2024
7+
- 2023
8+
- 2022
9+
- 2021
10+
- 2020
11+
- hoxton
12+
- greenwich
13+
pull_request:
14+
branches:
15+
- 2024
16+
- 2023
17+
- 2022
18+
- 2021
19+
- 2020
20+
- hoxton
21+
- greenwich
22+
23+
jobs:
24+
set-jdks:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
jdks: ${{ steps.set-jdks.outputs.jdks }}
28+
steps:
29+
- name: Set JDK matrix based on branch
30+
id: set-jdks
31+
run: |
32+
shopt -s nocasematch
33+
branch_name=${{ github.ref_name }}
34+
if [ -n "${{ github.base_ref }}" ]; then
35+
branch_name=${{ github.base_ref }}
36+
fi
37+
echo $branch_name
38+
if [[ "$branch_name" == "2024" ]]; then
39+
echo "jdks=[17,21]" >> $GITHUB_OUTPUT
40+
elif [[ "$branch_name" == "2023" ]]; then
41+
echo "jdks=[17,21]" >> $GITHUB_OUTPUT
42+
elif [[ "$branch_name" == "2022" ]]; then
43+
echo "jdks=[17,21]" >> $GITHUB_OUTPUT
44+
elif [[ "$branch_name" == "2021" ]]; then
45+
echo "jdks=[8,11,17,21]" >> $GITHUB_OUTPUT
46+
elif [[ "$branch_name" == "2020" ]]; then
47+
echo "jdks=[8,11,17,21]" >> $GITHUB_OUTPUT
48+
elif [[ "$branch_name" == "hoxton" ]]; then
49+
echo "jdks=[8,11,17,21]" >> $GITHUB_OUTPUT
50+
elif [[ "$branch_name" == "greenwich" ]]; then
51+
echo "jdks=[8,11,17,21]" >> $GITHUB_OUTPUT
52+
else
53+
echo "jdks=[17]" >> $GITHUB_OUTPUT
54+
fi
55+
shopt -u nocasematch
56+
junit:
57+
strategy:
58+
matrix:
59+
java: ${{ fromJson(needs.set-jdks.outputs.jdks) }}
60+
os: [ 'windows-latest', 'ubuntu-latest' ]
61+
runs-on: ${{ matrix.os }}
62+
needs: set-jdks
63+
steps:
64+
- name: Checkout codes
65+
uses: actions/checkout@v4
66+
- name: Set up JDK ${{ matrix.java }}
67+
uses: actions/setup-java@v4
68+
with:
69+
distribution: 'temurin'
70+
java-version: ${{ matrix.java }}
71+
- name: Cache local Maven repository
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.m2/repository
75+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
76+
restore-keys: |
77+
${{ runner.os }}-maven-
78+
- name: Test with Maven
79+
run: mvn clean test -B -U -Psonatype
80+
- name: Upload coverage to Codecov
81+
if: matrix.os == 'ubuntu-latest' && matrix.java == 17
82+
uses: codecov/codecov-action@v4
83+
env:
84+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
85+
with:
86+
files: ${{ github.workspace }}/target/site/jacoco/jacoco.xml

.github/workflows/junit_test_jdk17-21.yml

-40
This file was deleted.

.github/workflows/junit_test_jdk8-21.yml

-43
This file was deleted.

.github/workflows/snapshot.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- 2024
7+
- 2023
8+
- 2022
9+
- 2021
10+
- 2020
11+
- hoxton
12+
- greenwich
13+
14+
jobs:
15+
check-snapshot:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
IS_SNAPSHOT: ${{ steps.check-deploy-type.outputs.IS_SNAPSHOT }}
19+
steps:
20+
- name: Checkout codes
21+
uses: actions/checkout@v4
22+
- name: Check deploy type
23+
id: check-deploy-type
24+
run: |
25+
line="$(grep SNAPSHOT pom.xml || true)"
26+
echo $line
27+
if [ -n "$line" ]; then
28+
echo "IS_SNAPSHOT=true" >> $GITHUB_OUTPUT
29+
else
30+
echo "IS_SNAPSHOT=false" >> $GITHUB_OUTPUT
31+
fi
32+
set-jdk:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
jdk: ${{ steps.set-jdk.outputs.jdk }}
36+
steps:
37+
- name: Set JDK based on branch
38+
id: set-jdk
39+
run: |
40+
shopt -s nocasematch
41+
if [[ "${{ github.ref_name }}" == "2024" ]]; then
42+
echo "jdk=17" >> $GITHUB_OUTPUT
43+
elif [[ "${{ github.ref_name }}" == "2023" ]]; then
44+
echo "jdk=17" >> $GITHUB_OUTPUT
45+
elif [[ "${{ github.ref_name }}" == "2022" ]]; then
46+
echo "jdk=17" >> $GITHUB_OUTPUT
47+
elif [[ "${{ github.ref_name }}" == "2021" ]]; then
48+
echo "jdk=8" >> $GITHUB_OUTPUT
49+
elif [[ "${{ github.ref_name }}" == "2020" ]]; then
50+
echo "jdk=8" >> $GITHUB_OUTPUT
51+
elif [[ "${{ github.ref_name }}" == "hoxton" ]]; then
52+
echo "jdk=8" >> $GITHUB_OUTPUT
53+
elif [[ "${{ github.ref_name }}" == "greenwich" ]]; then
54+
echo "jdk=8" >> $GITHUB_OUTPUT
55+
else
56+
echo "jdk=17" >> $GITHUB_OUTPUT
57+
fi
58+
shopt -u nocasematch
59+
snapshot:
60+
runs-on: ubuntu-latest
61+
needs: [ check-snapshot, set-jdk ]
62+
if: ${{ needs.check-snapshot.outputs.IS_SNAPSHOT == 'true' }}
63+
steps:
64+
- name: Checkout codes
65+
uses: actions/checkout@v4
66+
- name: Set up JDK ${{ needs.set-jdk.outputs.jdk }}
67+
uses: actions/setup-java@v4
68+
with:
69+
java-version: ${{ needs.set-jdk.outputs.jdk }}
70+
distribution: 'temurin'
71+
server-id: nexus-snapshots
72+
server-username: MAVEN_USERNAME
73+
server-password: MAVEN_PASSWORD
74+
- name: Publish package
75+
run: mvn clean deploy -B -U -Psonatype
76+
env:
77+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
78+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

.github/workflows/snapshot_jdk17.yml

-47
This file was deleted.

0 commit comments

Comments
 (0)