Skip to content

Commit

Permalink
Fixed publishing to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat committed Jan 31, 2024
1 parent 454ca91 commit c0dbfc3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 57 deletions.
31 changes: 12 additions & 19 deletions .github/workflows/ci-maven-publish-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:
cancel-in-progress: true
jobs:
build:
name: Release to Maven Central
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
Expand All @@ -31,23 +32,15 @@ jobs:
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Verify
run: mvn --no-transfer-progress --batch-mode verify
- name: Package surefire test results
if: failure()
run: |
rm -rf test-results
mkdir test-results
find . -type d -name "*surefire*" -exec cp --parents -R {} test-results/ \;
zip -r test-results.zip test-results
- name: Upload test results
uses: actions/upload-artifact@v3
if: failure()

- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
name: test-results
path: test-results.zip
- name: Publish to the Maven Central Repository
run: mvn --batch-mode -Prelease -DskipTests deploy
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
nexus_username: ${{ secrets.SONATYPE_USERNAME }}
nexus_password: ${{ secrets.SONATYPE_PASSWORD }}
server_id: ossrh
maven_profiles: release
maven_goals_phases: clean deploy
maven_args: -DskipTests -Dspotless.skip=true
72 changes: 34 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
</license>
</licenses>

<developers>
<developer>
<organization>StreamNative Inc.</organization>
<organizationUrl>https://streamnative.io/</organizationUrl>
</developer>
</developers>

<modules>
<module>client</module>
<module>client-metrics-api</module>
Expand Down Expand Up @@ -448,42 +455,14 @@
<id>release</id>
<build>
<plugins>
<!-- calculate checksums of source release for Apache dist area -->
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<version>1.11</version>
<executions>
<execution>
<id>source-release-checksum</id>
<goals>
<goal>artifacts</goal>
</goals>
<phase>post-integration-test</phase>
<configuration>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
<algorithm>SHA-512</algorithm>
</algorithms>
<includeClassifiers>source-release</includeClassifiers>
<excludeMainArtifact>true</excludeMainArtifact>
<csvSummary>false</csvSummary>
<attachChecksums>true</attachChecksums>
</configuration>
</execution>
</executions>
</plugin>
<!-- We want to sign the artifact, the POM, and all attached artifacts (except for SHA-512 checksum) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>sign-release-artifacts</id>
<id>attach-sources</id>
<goals>
<goal>sign</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
Expand All @@ -505,26 +484,43 @@
<goal>javadoc</goal>
<goal>jar</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<!-- Prevent `gpg` from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>jar-no-fork</goal>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<stagingProgressTimeoutMinutes>15</stagingProgressTimeoutMinutes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit c0dbfc3

Please sign in to comment.