Skip to content
Open
2 changes: 1 addition & 1 deletion .github/workflows/maven-merge-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name: Java CI with Maven

on:
push:
pull_request:
branches: [ "master" ]

jobs:
Expand Down
87 changes: 77 additions & 10 deletions .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,107 @@
name: Publish package to the Maven Central Repository

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
release:
types: [ published ]
workflow_dispatch:
inputs:
version:
description: 'Version to deploy (optional, will use pom.xml version if not specified)'
required: false
type: string

jobs:
release:
name: Release on Sonatype OSS
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and test
run: mvn -B clean verify

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: target/surefire-reports/
retention-days: 30

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: target/site/jacoco/
retention-days: 30

publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
needs: build-and-test
if: needs.build-and-test.result == 'success' && (github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
distribution: 'temurin'

- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Set up Apache Maven Central
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
java-version: 17
distribution: 'adopt'
distribution: 'temurin'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Publish to Apache Maven Central
run: mvn -Prelease deploy
run: mvn -B -Prelease deploy
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Create Release Tag
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a v${{ github.event.inputs.version }} -m "Release version ${{ github.event.inputs.version }}"
git push origin v${{ github.event.inputs.version }}
7 changes: 3 additions & 4 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# If the PR has the label release:major, release:minor, or release:patch, this will override bump_version_scheme.
# https://github.com/marketplace/actions/release-tag-new-action
on:
push:
branches:
- master
on:
pull_request:
branches: [ "master" ]

jobs:
release-on-push:
Expand Down
70 changes: 66 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.intuit.rwebpulse</groupId>
<artifactId>rwebpulse</artifactId>
<version>1.0.3</version>
<version>1.0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Spring Web Client</name>
<url>https://github.com/intuit/rwebpulse</url>
Expand Down Expand Up @@ -103,6 +103,17 @@

<build>
<plugins>
<plugin>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<plugin>

is this still needed ?

<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.8.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand All @@ -123,6 +134,57 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
<arg>--batch</arg>
<arg>--yes</arg>
</gpgArguments>
<useAgent>false</useAgent>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -162,7 +224,7 @@
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<serverId>central</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
Expand Down Expand Up @@ -227,11 +289,11 @@
</profiles>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<id>central</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<id>central</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
Expand Down
Loading