Skip to content

Commit 7ca1b16

Browse files
committed
Auto-publish master to Maven Central
1 parent e5799f3 commit 7ca1b16

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/cache@v1
2727
with:
2828
path: ~/.m2
29-
key: m2
29+
key: m2-cache-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}
3030

3131
- name: Set up JDK ${{ matrix.java }}
3232
uses: joschi/setup-jdk@2d2c40de6fb6af3db2a3d2bedd57eb02442521c4
@@ -36,3 +36,39 @@ jobs:
3636

3737
- name: Build with Maven
3838
run: mvn verify -B -"Dgpg.skip"
39+
40+
release:
41+
if: github.ref == 'refs/heads/master'
42+
needs: test
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v1
46+
47+
- name: Cache Maven dependencies
48+
uses: actions/cache@v1
49+
with:
50+
path: ~/.m2
51+
key: m2-cache-8-x64-ubuntu-latest
52+
53+
- name: Set up JDK 8
54+
uses: joschi/setup-jdk@2d2c40de6fb6af3db2a3d2bedd57eb02442521c4
55+
with:
56+
java-version: '8'
57+
architecture: 'x64'
58+
server-id: ossrh
59+
server-username: SONATYPE_USER
60+
server-password: SONATYPE_PW
61+
62+
- name: Release to Maven Central
63+
env:
64+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
65+
SONATYPE_PW: ${{ secrets.SONATYPE_PW }}
66+
run: |
67+
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
68+
gpg --list-secret-keys --keyid-format LONG
69+
mvn \
70+
--no-transfer-progress \
71+
--batch-mode \
72+
-Dgpg.passphrase="${{ secrets.GPG_PW }}" \
73+
-DperformRelease=true \
74+
deploy

pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
</goals>
6666
</execution>
6767
</executions>
68+
<configuration>
69+
<gpgArguments>
70+
<arg>--pinentry-mode</arg>
71+
<arg>loopback</arg>
72+
</gpgArguments>
73+
</configuration>
6874
</plugin>
6975

7076
<plugin>
@@ -207,6 +213,24 @@
207213
</execution>
208214
</executions>
209215
</plugin>
216+
217+
<plugin>
218+
<groupId>org.apache.maven.plugins</groupId>
219+
<artifactId>maven-deploy-plugin</artifactId>
220+
<version>2.8.2</version>
221+
</plugin>
222+
223+
<plugin>
224+
<groupId>org.sonatype.plugins</groupId>
225+
<artifactId>nexus-staging-maven-plugin</artifactId>
226+
<version>1.6.8</version>
227+
<extensions>true</extensions>
228+
<configuration>
229+
<serverId>ossrh</serverId>
230+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
231+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
232+
</configuration>
233+
</plugin>
210234
</plugins>
211235
</build>
212236

0 commit comments

Comments
 (0)