Skip to content

Commit f75b9a4

Browse files
committed
add configuration for deploying to maven central
1 parent ffb492c commit f75b9a4

File tree

2 files changed

+82
-24
lines changed

2 files changed

+82
-24
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1-
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2-
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3-
4-
name: Maven Package
5-
1+
name: Publish package to the Maven Central Repository
62
on:
73
release:
84
types: [created]
9-
105
jobs:
11-
build:
12-
6+
publish:
137
runs-on: ubuntu-latest
14-
permissions:
15-
contents: read
16-
packages: write
17-
188
steps:
199
- uses: actions/checkout@v3
20-
- name: Set up JDK 8
10+
- name: Set up Maven Central Repository
2111
uses: actions/setup-java@v3
2212
with:
2313
java-version: '8'
2414
distribution: 'adopt'
25-
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
26-
settings-path: ${{ github.workspace }} # location for the settings.xml file
27-
28-
- name: Build with Maven
29-
run: mvn -B package --file pom.xml
15+
server-id: sonatype-nexus-staging
16+
server-username: MAVEN_USERNAME
17+
server-password: MAVEN_PASSWORD
18+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
19+
gpg-passphrase: GPG_PASSPHRASE
3020

31-
- name: Publish to GitHub Packages Apache Maven
32-
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
21+
- name: Publish package
22+
run: mvn --batch-mode deploy -P deploy
3323
env:
34-
GITHUB_TOKEN: ${{ github.token }}
24+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
25+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
26+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

pom.xml

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,44 @@
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1717
</properties>
1818

19+
<licenses>
20+
<license>
21+
<name>Apache License, Version 2.0</name>
22+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
23+
<distribution>repo</distribution>
24+
</license>
25+
</licenses>
26+
27+
28+
<developers>
29+
<developer>
30+
<name>Barry Pitman</name>
31+
<email>[email protected]</email>
32+
<organization>Ubiquitech</organization>
33+
<organizationUrl>https://ubiquitech.co.za/</organizationUrl>
34+
</developer>
35+
36+
</developers>
37+
38+
<scm>
39+
<url>https://github.com/barrypitman/JUnitXmlFormatter</url>
40+
<connection>scm:git:https://github.com/barrypitman/JUnitXmlFormatter.git</connection>
41+
<developerConnection>scm:git:https://github.com/barrypitman/JUnitXmlFormatter.git</developerConnection>
42+
<tag>HEAD</tag>
43+
</scm>
44+
1945
<distributionManagement>
46+
<snapshotRepository>
47+
<id>sonatype-nexus-snapshots</id>
48+
<name>Sonatype Nexus Snapshots</name>
49+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
50+
</snapshotRepository>
2051
<repository>
21-
<id>github</id>
22-
<name>GitHub Packages</name>
23-
<url>https://maven.pkg.github.com/ubiquitech/staging</url>
52+
<id>sonatype-nexus-staging</id>
53+
<name>Nexus Release Repository</name>
54+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
2455
</repository>
56+
<downloadUrl>https://oss.sonatype.org/content/groups/public/org/knowm/xchart</downloadUrl>
2557
</distributionManagement>
2658

2759
<dependencies>
@@ -31,4 +63,38 @@
3163
<version>4.11</version>
3264
</dependency>
3365
</dependencies>
66+
67+
<profiles>
68+
<profile>
69+
<id>deploy</id>
70+
71+
<build>
72+
<plugins>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-gpg-plugin</artifactId>
76+
<version>3.0.1</version>
77+
<configuration>
78+
<!-- Prevent gpg from using pinentry programs -->
79+
<gpgArguments>
80+
<arg>--pinentry-mode</arg>
81+
<arg>loopback</arg>
82+
</gpgArguments>
83+
</configuration>
84+
<executions>
85+
<execution>
86+
<id>sign-artifacts</id>
87+
<phase>verify</phase>
88+
<goals>
89+
<goal>sign</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
97+
</profile>
98+
</profiles>
99+
34100
</project>

0 commit comments

Comments
 (0)