Skip to content

Commit a870b6e

Browse files
committed
chore: setup github actions
1 parent 51790f8 commit a870b6e

4 files changed

Lines changed: 129 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Java
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: temurin
21+
java-version: '17'
22+
cache: maven
23+
24+
- name: Build and test
25+
run: mvn -B clean verify

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release to Maven Central
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: '17'
24+
server-id: central
25+
server-username: CENTRAL_USERNAME
26+
server-password: CENTRAL_PASSWORD
27+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
28+
gpg-passphrase: GPG_PASSPHRASE
29+
30+
- name: Get version from pom.xml
31+
id: get_version
32+
run: |
33+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
36+
- name: Build and verify
37+
run: mvn -B clean verify -Prelease
38+
env:
39+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
40+
41+
- name: Deploy to Maven Central
42+
run: mvn -B clean deploy -Prelease
43+
env:
44+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
45+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
46+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
47+
48+
- name: Create GitHub Release
49+
uses: softprops/action-gh-release@v1
50+
with:
51+
tag_name: v${{ steps.get_version.outputs.version }}
52+
name: Release v${{ steps.get_version.outputs.version }}
53+
generate_release_notes: true
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/snapshot.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
snapshot:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: '17'
24+
server-id: central
25+
server-username: CENTRAL_USERNAME
26+
server-password: CENTRAL_PASSWORD
27+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
28+
gpg-passphrase: GPG_PASSPHRASE
29+
30+
- name: Set snapshot version
31+
run: |
32+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
33+
if [[ ! "$VERSION" == *"-SNAPSHOT" ]]; then
34+
mvn versions:set -DnewVersion="${VERSION}-SNAPSHOT" -DgenerateBackupPoms=false
35+
fi
36+
37+
- name: Build and verify
38+
run: mvn -B clean verify -Prelease
39+
env:
40+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
41+
42+
- name: Deploy snapshot to Maven Central
43+
run: mvn -B clean deploy -Prelease
44+
env:
45+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
46+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
47+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@
174174

175175
<distributionManagement>
176176
<snapshotRepository>
177-
<id>central</id>
178-
<url>https://central.sonatype.com/api/v1/publisher</url>
177+
<id>central-snapshots</id>
178+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
179179
</snapshotRepository>
180180
<repository>
181181
<id>central</id>

0 commit comments

Comments
 (0)