Skip to content

Commit aabf4e7

Browse files
author
Pratik Lala
committed
Add Maven Central publishing via Sonatype Central Portal
- pom.xml: add developers, scm, and release profile with maven-source-plugin, maven-javadoc-plugin, maven-gpg-plugin, and central-publishing-maven-plugin - .github/settings.xml: update server id from ossrh to central - release.yml: import GPG key, run mvn deploy -Prelease with OSSRH_USERNAME / OSSRH_PASSWORD / MAVEN_GPG_PASSPHRASE secrets Made-with: Cursor
1 parent bc1f31d commit aabf4e7

File tree

3 files changed

+154
-5
lines changed

3 files changed

+154
-5
lines changed

.github/settings.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
Maven settings used by the GitHub Actions release workflow.
3+
Credentials are injected from GitHub repository secrets at runtime.
4+
Do NOT hard-code any values here.
5+
-->
6+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
7+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
9+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
10+
<servers>
11+
<server>
12+
<id>central</id>
13+
<username>${env.OSSRH_USERNAME}</username>
14+
<password>${env.OSSRH_PASSWORD}</password>
15+
</server>
16+
</servers>
17+
</settings>

.github/workflows/release.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: Release — GitHub Release
1+
name: Release — GitHub Release + Maven Central
22

33
# Trigger: push a version tag
44
# git tag v1.0.0 && git push origin v1.0.0
55
#
6-
# No secrets required. Builds the JARs and attaches them to a GitHub Release.
7-
# Maven Central publishing will be added in a future workflow once credentials are available.
6+
# Required repository secrets:
7+
# OSSRH_USERNAME — Sonatype Central Portal token username
8+
# OSSRH_PASSWORD — Sonatype Central Portal token password
9+
# GPG_PRIVATE_KEY — gpg --export-secret-keys --armor <key-id>
10+
# GPG_PASSPHRASE — passphrase for the GPG key above
811

912
on:
1013
push:
@@ -51,8 +54,15 @@ jobs:
5154
-DnewVersion=${{ steps.version.outputs.version }} \
5255
-DgenerateBackupPoms=false
5356
54-
- name: Build and test
55-
run: mvn --batch-mode clean verify
57+
- name: Import GPG key
58+
run: echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
59+
60+
- name: Build, sign and publish to Maven Central
61+
run: mvn --batch-mode clean deploy -Prelease --settings .github/settings.xml
62+
env:
63+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
64+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
65+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
5666

5767
- name: Create GitHub Release
5868
uses: softprops/action-gh-release@v2

pom.xml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,50 @@
2020
</license>
2121
</licenses>
2222

23+
<developers>
24+
<developer>
25+
<id>pratik3558</id>
26+
<name>Pratik</name>
27+
<organization>Intuit</organization>
28+
</developer>
29+
<developer>
30+
<id>poojachow</id>
31+
<name>Pooja</name>
32+
<organization>Intuit</organization>
33+
</developer>
34+
<developer>
35+
<id>suthirrpreethum</id>
36+
<name>Suthirr</name>
37+
<organization>Intuit</organization>
38+
</developer>
39+
<developer>
40+
<id>ashishpandey85</id>
41+
<name>Ashish</name>
42+
<organization>Intuit</organization>
43+
</developer>
44+
<developer>
45+
<id>akupireddy</id>
46+
<name>Arun</name>
47+
<organization>Intuit</organization>
48+
</developer>
49+
<developer>
50+
<id>chinmayb0</id>
51+
<name>Chinmay</name>
52+
<organization>Intuit</organization>
53+
</developer>
54+
<developer>
55+
<id>leomoise</id>
56+
<name>Daniel</name>
57+
<organization>Intuit</organization>
58+
</developer>
59+
</developers>
60+
61+
<scm>
62+
<connection>scm:git:git://github.com/intuit/json2jsontransformer.git</connection>
63+
<developerConnection>scm:git:ssh://github.com/intuit/json2jsontransformer.git</developerConnection>
64+
<url>https://github.com/intuit/json2jsontransformer</url>
65+
</scm>
66+
2367
<properties>
2468
<java.version>11</java.version>
2569
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -43,6 +87,10 @@
4387
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
4488
<maven-shade-plugin.version>3.5.1</maven-shade-plugin.version>
4589
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
90+
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
91+
<maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>
92+
<maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
93+
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
4694
</properties>
4795

4896
<dependencies>
@@ -217,4 +265,78 @@
217265
</plugin>
218266
</plugins>
219267
</build>
268+
269+
<profiles>
270+
<profile>
271+
<id>release</id>
272+
<build>
273+
<plugins>
274+
<!-- Attach sources JAR -->
275+
<plugin>
276+
<groupId>org.apache.maven.plugins</groupId>
277+
<artifactId>maven-source-plugin</artifactId>
278+
<version>${maven-source-plugin.version}</version>
279+
<executions>
280+
<execution>
281+
<id>attach-sources</id>
282+
<goals>
283+
<goal>jar-no-fork</goal>
284+
</goals>
285+
</execution>
286+
</executions>
287+
</plugin>
288+
289+
<!-- Attach Javadoc JAR -->
290+
<plugin>
291+
<groupId>org.apache.maven.plugins</groupId>
292+
<artifactId>maven-javadoc-plugin</artifactId>
293+
<version>${maven-javadoc-plugin.version}</version>
294+
<executions>
295+
<execution>
296+
<id>attach-javadocs</id>
297+
<goals>
298+
<goal>jar</goal>
299+
</goals>
300+
</execution>
301+
</executions>
302+
</plugin>
303+
304+
<!-- GPG signing — passphrase read from MAVEN_GPG_PASSPHRASE env var -->
305+
<plugin>
306+
<groupId>org.apache.maven.plugins</groupId>
307+
<artifactId>maven-gpg-plugin</artifactId>
308+
<version>${maven-gpg-plugin.version}</version>
309+
<executions>
310+
<execution>
311+
<id>sign-artifacts</id>
312+
<phase>verify</phase>
313+
<goals>
314+
<goal>sign</goal>
315+
</goals>
316+
<configuration>
317+
<gpgArguments>
318+
<arg>--pinentry-mode</arg>
319+
<arg>loopback</arg>
320+
</gpgArguments>
321+
</configuration>
322+
</execution>
323+
</executions>
324+
</plugin>
325+
326+
<!-- Publish to Maven Central via Sonatype Central Portal -->
327+
<plugin>
328+
<groupId>org.sonatype.central</groupId>
329+
<artifactId>central-publishing-maven-plugin</artifactId>
330+
<version>${central-publishing-maven-plugin.version}</version>
331+
<extensions>true</extensions>
332+
<configuration>
333+
<publishingServerId>central</publishingServerId>
334+
<autoPublish>true</autoPublish>
335+
<waitUntil>published</waitUntil>
336+
</configuration>
337+
</plugin>
338+
</plugins>
339+
</build>
340+
</profile>
341+
</profiles>
220342
</project>

0 commit comments

Comments
 (0)