Add maven central release GH Action workflow

This commit is contained in:
Ilayaperumal Gopinathan
2025-01-29 17:23:12 +00:00
parent 6c5df08c3b
commit ff287a5457
3 changed files with 93 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
name: Release to Maven Central
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Release version"
required: true
jobs:
build:
name: Release project
runs-on: ubuntu-latest
steps:
- name: Check out sources
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Install GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" > gpg.asc
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --yes --passphrase-fd 0 --import gpg.asc
- name: Release to Sonatype OSSRH
env:
SONATYPE_USER: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
./mvnw -B clean install -DskipTests
./mvnw -B clean deploy -Psonatype -s settings.xml
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Deploy documentation
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: ./mvnw -B clean deploy -Pdocumentation

38
pom.xml
View File

@@ -794,6 +794,44 @@
</repository>
</distributionManagement>
</profile>
<profile>
<id>sonatype</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Passphrase consumed from MAVEN_GPG_PASSPHRASE environment variable. -->
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-new</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencyManagement>

View File

@@ -35,6 +35,12 @@
<username>${env.ARTIFACTORY_USERNAME}</username>
<password>${env.ARTIFACTORY_PASSWORD}</password>
</server>
<server>
<id>sonatype-new</id>
<username>${env.SONATYPE_USER}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
</settings>