Skip to content

Commit 7b417a2

Browse files
authored
Publish to Maven Central when a tag is pushed. (#115)
1 parent b4ee2bb commit 7b417a2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.github/workflows/maven.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: Java CI with Maven
66
on:
77
push:
88
branches: [master]
9+
tags: ["**"]
910
pull_request:
1011
branches: [master]
1112

@@ -26,6 +27,17 @@ jobs:
2627
distribution: "adopt"
2728
- name: Build with Maven
2829
run: mvn test -B
30+
- name: Import signing key
31+
if: ${{ github.ref_type == 'tag' }}
32+
env:
33+
ARTIFACT_SIGNING_PRIVATE_KEY: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
34+
run: echo "$ARTIFACT_SIGNING_PRIVATE_KEY" | gpg --import
35+
- name: Release to Maven Central
36+
if: ${{ github.ref_type == 'tag' }}
37+
env:
38+
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
39+
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
40+
run: mvn --activate-profiles release deploy --batch-mode --settings .maven_settings.xml
2941

3042
labeler:
3143
needs: build

.maven_settings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
3+
<servers>
4+
<server>
5+
<id>ossrh</id>
6+
<username>${env.SONATYPE_NEXUS_USERNAME}</username>
7+
<password>${env.SONATYPE_NEXUS_PASSWORD}</password>
8+
</server>
9+
</servers>
10+
</settings>

0 commit comments

Comments
 (0)