Skip to content

Commit 9e68bd0

Browse files
committed
add maven release workflow
1 parent 859548b commit 9e68bd0

File tree

2 files changed

+104
-20
lines changed

2 files changed

+104
-20
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Make release
2+
3+
on:
4+
pull:
5+
push:
6+
branches:
7+
- master
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- name: Set up JDK 8
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: 8
20+
distribution: 'temurin'
21+
- name: Cache Maven packages
22+
uses: actions/cache@v3
23+
with:
24+
path: ~/.m2
25+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: ${{ runner.os }}-m2
27+
- name: Build
28+
run: mvn clean verify
29+
30+
test:
31+
name: Test
32+
needs: build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
with:
37+
fetch-depth: 0
38+
- name: Set up JDK 8
39+
uses: actions/setup-java@v3
40+
with:
41+
java-version: 8
42+
distribution: 'temurin'
43+
- name: Cache Maven packages
44+
uses: actions/cache@v3
45+
with:
46+
path: ~/.m2
47+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
48+
restore-keys: ${{ runner.os }}-m2
49+
- name: Build
50+
run: mvn clean package install -DskipTests=true
51+
- name: Build, test
52+
run: mvn -B test
53+
54+
publish-OSSRH:
55+
runs-on: ubuntu-latest
56+
name: Publish to Maven Central
57+
needs: test
58+
permissions:
59+
contents: read
60+
packages: write
61+
steps:
62+
- uses: actions/checkout@v3
63+
with:
64+
fetch-depth: 0
65+
66+
- id: install-secret-key
67+
name: Install gpg secret key
68+
run: |
69+
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
70+
gpg --list-secret-keys --keyid-format LONG
71+
72+
- name: Set up Maven Central Repository
73+
uses: actions/setup-java@v3
74+
with:
75+
java-version: 8
76+
distribution: 'temurin'
77+
server-id: central
78+
server-username: MAVEN_USERNAME
79+
server-password: MAVEN_PASSWORD
80+
81+
- name: Publish package
82+
run: mvn -DskipTests=true --batch-mode -P release -Dgpg.passphrase=${{ secrets.OSS_PASSWORD }} deploy
83+
env:
84+
MAVEN_USERNAME: ${{ secrets.OSS_USERNAME }}
85+
MAVEN_PASSWORD: ${{ secrets.OSS_PASSWORD }}

pom.xml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,27 @@
192192
</profile>
193193
<profile>
194194
<id>release</id>
195+
<distributionManagement>
196+
<repository>
197+
<id>central</id>
198+
<name>Central Repository OSSRH</name>
199+
<url>https://central.sonatype.com/</url>
200+
</repository>
201+
<snapshotRepository>
202+
<id>central</id>
203+
<name>Central Repository OSSRG Snapshots</name>
204+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
205+
<snapshots>
206+
<enabled>true</enabled>
207+
</snapshots>
208+
</snapshotRepository>
209+
</distributionManagement>
195210
<build>
196211
<plugins>
197212
<plugin>
198213
<groupId>org.apache.maven.plugins</groupId>
199214
<artifactId>maven-gpg-plugin</artifactId>
215+
<version>1.5</version>
200216
<configuration>
201217
<gpgArguments>
202218
<arg>--pinentry-mode</arg>
@@ -216,12 +232,12 @@
216232
<plugin>
217233
<groupId>org.sonatype.central</groupId>
218234
<artifactId>central-publishing-maven-plugin</artifactId>
219-
<version>0.7.0</version>
235+
<version>0.8.0</version>
220236
<extensions>true</extensions>
221237
<configuration>
222-
<publishingServerId>ossrh</publishingServerId>
238+
<publishingServerId>central</publishingServerId>
223239
<autoPublish>true</autoPublish>
224-
<waitUntil>published</waitUntil>
240+
<checksums>required</checksums>
225241
</configuration>
226242
</plugin>
227243
<plugin>
@@ -256,18 +272,6 @@
256272
</execution>
257273
</executions>
258274
</plugin>
259-
<plugin>
260-
<groupId>org.cyclonedx</groupId>
261-
<artifactId>cyclonedx-maven-plugin</artifactId>
262-
<executions>
263-
<execution>
264-
<phase>package</phase>
265-
<goals>
266-
<goal>makeAggregateBom</goal>
267-
</goals>
268-
</execution>
269-
</executions>
270-
</plugin>
271275
</plugins>
272276
</build>
273277
</profile>
@@ -352,11 +356,6 @@
352356
<artifactId>sonar-maven-plugin</artifactId>
353357
<version>5.1.0.4751</version>
354358
</plugin>
355-
<plugin>
356-
<groupId>org.cyclonedx</groupId>
357-
<artifactId>cyclonedx-maven-plugin</artifactId>
358-
<version>2.9.1</version>
359-
</plugin>
360359
</plugins>
361360
</pluginManagement>
362361
<plugins>

0 commit comments

Comments
 (0)