Skip to content

Commit 942fb09

Browse files
committed
ci: update GitHub Actions workflows for Maven build and deploy
- Change trigger for Maven build to only run on the main branch. - Add permissions and concurrency settings to both workflows. - Remove the verify job from the deploy workflow and add validation for release tags. - Ensure coverage reports are uploaded only for non-pull request events.
1 parent ee043d7 commit 942fb09

2 files changed

Lines changed: 33 additions & 23 deletions

File tree

.github/workflows/maven-build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ name: Maven Build
22

33
on:
44
push:
5-
tags:
6-
- 'v*'
5+
branches:
6+
- main
77

88
pull_request:
99
branches:
1010
- main
1111

12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: maven-build-${{ github.ref }}
17+
cancel-in-progress: true
18+
1219
env:
1320
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1421

@@ -34,6 +41,8 @@ jobs:
3441
./mvnw -B package --file pom.xml
3542
3643
- name: Upload coverage reports to Codecov
44+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
3745
uses: codecov/codecov-action@v6
3846
with:
3947
token: ${{ secrets.CODECOV_TOKEN }}
48+
fail_ci_if_error: false

.github/workflows/maven-deploy.yml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,19 @@ on:
55
tags:
66
- 'v*'
77

8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: maven-deploy-${{ github.ref }}
13+
cancel-in-progress: false
14+
815
env:
916
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1017

1118
jobs:
12-
verify:
13-
name: maven verify
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Git Checkout
18-
uses: actions/checkout@v6
19-
20-
- name: Set up JDK 17
21-
uses: actions/setup-java@v5
22-
with:
23-
cache: maven
24-
java-version: '17'
25-
distribution: 'temurin'
26-
27-
- name: Verify with Maven
28-
run: |
29-
chmod +x ./mvnw
30-
./mvnw -B clean verify --file pom.xml
31-
3219
deploy:
3320
name: maven deploy
34-
needs: verify
3521
runs-on: ubuntu-latest
3622

3723
steps:
@@ -50,6 +36,21 @@ jobs:
5036
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
5137
gpg-passphrase: GPG_PASSPHRASE
5238

39+
- name: Validate release tag
40+
run: |
41+
version="$(grep -m1 '<version>' pom.xml | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/')"
42+
tag_version="${GITHUB_REF_NAME#v}"
43+
44+
if [[ "$version" == *-SNAPSHOT ]]; then
45+
echo "Refusing to deploy snapshot version: $version"
46+
exit 1
47+
fi
48+
49+
if [[ "$version" != "$tag_version" ]]; then
50+
echo "Tag version ($tag_version) does not match pom.xml version ($version)"
51+
exit 1
52+
fi
53+
5354
- name: Deploy to Maven Central
5455
run: |
5556
chmod +x ./mvnw

0 commit comments

Comments
 (0)