Skip to content

Commit 30e5aa9

Browse files
committed
Add CI/CD workflow with GitHub Actions: build, test, publish to Central Sonatype
1 parent 3261ebb commit 30e5aa9

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
build-test-and-publish:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-java@v4
16+
with:
17+
distribution: 'temurin'
18+
java-version: '24'
19+
20+
- name: Configure Maven settings
21+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
22+
uses: s4u/maven-settings-action@v3.0.0
23+
with:
24+
servers: |
25+
[{
26+
"id": "central",
27+
"username": "${{ secrets.CENTRAL_SONATYPE_USERNAME }}",
28+
"password": "${{ secrets.CENTRAL_SONATYPE_PASSWORD }}"
29+
}]
30+
31+
- name: Import GPG key
32+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
33+
uses: crazy-max/ghaction-import-gpg@v6
34+
with:
35+
gpg_private_key: ${{ secrets.GPG_TEST_PRIV_KEY }}
36+
passphrase: ${{ secrets.GPG_TEST_PASSPHRASE }}
37+
38+
- name: Build
39+
run: mvn --batch-mode clean compile
40+
41+
- name: Test
42+
run: mvn --batch-mode test
43+
44+
- name: Package without gpg
45+
if: github.event_name != 'push' || github.ref != 'refs/heads/master'
46+
run: mvn --batch-mode package -Dmaven.test.skip=true -Dgpg.skip=true
47+
48+
- name: Deploy
49+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
50+
run: mvn --batch-mode deploy
51+
52+
- name: Upload build artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: java-runtime-${{ github.event_name }}-${{ github.event.number || github.sha }}
56+
path: target/*.jar
57+
retention-days: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && 30 || 7 }}
58+
59+
- name: Upload test results
60+
uses: actions/upload-artifact@v4
61+
if: always()
62+
with:
63+
name: test-results-${{ github.event_name }}-${{ github.event.number || github.sha }}
64+
path: target/surefire-reports/
65+
retention-days: 7

0 commit comments

Comments
 (0)