Skip to content

Commit 110569b

Browse files
authored
Configure Maven Central snapshot publishing (#20)
1 parent d4f46f4 commit 110569b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
name: Build with JDK ${{ matrix.java }} on ${{ matrix.architecture }}
1919
steps:
2020
- uses: actions/checkout@v4
21-
2221
- name: Setup JDK
2322
uses: actions/setup-java@v4
2423
with:
@@ -29,3 +28,28 @@ jobs:
2928

3029
- name: Build with Maven
3130
run: mvn test
31+
32+
deploy-snapshot:
33+
runs-on: ubuntu-latest
34+
needs: build
35+
if: github.ref == 'refs/heads/main'
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Setup JDK
40+
uses: actions/setup-java@v4
41+
with:
42+
distribution: 'temurin'
43+
java-version: '21'
44+
cache: 'maven'
45+
server-id: central
46+
server-username: CENTRAL_USERNAME
47+
server-password: CENTRAL_PASSWORD
48+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
49+
50+
- name: Deploy Snapshot
51+
run: mvn -B --no-transfer-progress -Psonatype-oss-release -Prelease-sign-artifacts -DskipTests=true deploy
52+
env:
53+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
54+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
55+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@
185185
</execution>
186186
</executions>
187187
</plugin>
188+
<plugin>
189+
<groupId>org.sonatype.central</groupId>
190+
<artifactId>central-publishing-maven-plugin</artifactId>
191+
<version>0.7.0</version>
192+
<extensions>true</extensions>
193+
<configuration>
194+
<publishingServerId>central</publishingServerId>
195+
<centralSnapshotsUrl>https://central.sonatype.com/repository/maven-snapshots/</centralSnapshotsUrl>
196+
</configuration>
197+
</plugin>
188198
<plugin>
189199
<groupId>org.apache.maven.plugins</groupId>
190200
<artifactId>maven-surefire-plugin</artifactId>

0 commit comments

Comments
 (0)