Skip to content

Commit d4b8f11

Browse files
authored
Merge pull request #10 from grove693/feature/github-action-deploy
WIP: Add Github Actions for publishing on maven central when creating tag
2 parents 6879cad + 11d128e commit d4b8f11

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and publish code to Maven Central
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
env:
10+
MAVEN_OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
11+
MAVEN_OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
12+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
13+
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Set up Java environment for building and publishing to Maven Central
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 17
21+
distribution: 'adopt'
22+
server-id: ossrh
23+
server-username: MAVEN_OSSRH_USERNAME
24+
server-password: MAVEN_OSSRH_PASSWORD
25+
gpg-private-key: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
26+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
27+
- name: Clean and build project
28+
run: mvn clean package
29+
- name: Create Github release
30+
uses: ncipollo/release-action@v1
31+
with:
32+
allowUpdates: true
33+
artifacts: "${{ github.workspace }}/target/*.jar"
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Publish to the Maven Central Repository
36+
run: |
37+
mvn \
38+
--no-transfer-progress \
39+
--batch-mode \
40+
deploy \
41+
-P release

pom.xml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,39 @@
6666
<plugins>
6767
<plugin>
6868
<artifactId>maven-clean-plugin</artifactId>
69-
<version>3.1.0</version>
69+
<version>3.4.0</version>
7070
</plugin>
7171
<plugin>
7272
<artifactId>maven-resources-plugin</artifactId>
73-
<version>3.0.2</version>
73+
<version>3.3.1</version>
7474
</plugin>
7575
<plugin>
7676
<artifactId>maven-compiler-plugin</artifactId>
7777
<version>3.13.0</version>
7878
</plugin>
7979
<plugin>
8080
<artifactId>maven-surefire-plugin</artifactId>
81-
<version>3.3.0</version>
81+
<version>3.5.0</version>
8282
</plugin>
8383
<plugin>
8484
<artifactId>maven-jar-plugin</artifactId>
8585
<version>3.4.2</version>
8686
</plugin>
8787
<plugin>
8888
<artifactId>maven-install-plugin</artifactId>
89-
<version>2.5.2</version>
89+
<version>3.1.3</version>
9090
</plugin>
9191
<plugin>
9292
<artifactId>maven-deploy-plugin</artifactId>
93-
<version>2.8.2</version>
93+
<version>3.1.3</version>
9494
</plugin>
9595
<plugin>
9696
<artifactId>maven-site-plugin</artifactId>
97-
<version>3.7.1</version>
97+
<version>3.20.0</version>
9898
</plugin>
9999
<plugin>
100100
<artifactId>maven-project-info-reports-plugin</artifactId>
101-
<version>3.0.0</version>
101+
<version>3.7.0</version>
102102
</plugin>
103103
</plugins>
104104
</pluginManagement>
@@ -114,7 +114,7 @@
114114
<plugin>
115115
<groupId>org.apache.maven.plugins</groupId>
116116
<artifactId>maven-source-plugin</artifactId>
117-
<version>3.2.1</version>
117+
<version>3.3.1</version>
118118
<executions>
119119
<execution>
120120
<id>attach-sources</id>
@@ -127,7 +127,7 @@
127127
<plugin>
128128
<groupId>org.sonatype.central</groupId>
129129
<artifactId>central-publishing-maven-plugin</artifactId>
130-
<version>0.5.0</version>
130+
<version>0.6.0</version>
131131
<extensions>true</extensions>
132132
<configuration>
133133
<publishingServerId>central</publishingServerId>
@@ -136,7 +136,7 @@
136136
<plugin>
137137
<groupId>org.apache.maven.plugins</groupId>
138138
<artifactId>maven-javadoc-plugin</artifactId>
139-
<version>3.2.0</version>
139+
<version>3.10.1</version>
140140
<executions>
141141
<execution>
142142
<id>attach-javadocs</id>
@@ -180,7 +180,6 @@
180180
<profile>
181181
<id>release</id>
182182
<activation>
183-
<activeByDefault>true</activeByDefault>
184183
<property>
185184
<name>performRelease</name>
186185
<value>true</value>
@@ -191,14 +190,14 @@
191190
<plugin>
192191
<groupId>org.apache.maven.plugins</groupId>
193192
<artifactId>maven-gpg-plugin</artifactId>
194-
<version>1.6</version>
193+
<version>3.2.7</version>
195194
<executions>
196195
<execution>
197196
<id>sign-artifacts</id>
198197
<phase>verify</phase>
199-
<!-- <goals>-->
200-
<!-- <goal>sign</goal>-->
201-
<!-- </goals>-->
198+
<goals>
199+
<goal>sign</goal>
200+
</goals>
202201
</execution>
203202
</executions>
204203
</plugin>

0 commit comments

Comments
 (0)