Skip to content

Commit

Permalink
Publish jar to Maven Central (#120)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiang Zhao <mattisonchao@apache.org>
  • Loading branch information
merlimat and mattisonchao authored Jan 30, 2024
1 parent 95ffb86 commit c1cc49c
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 40 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci-maven-publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI - Maven Publish Release

on:
push:
tags:
- 'v*'
workflow_dispatch:
# Publish nightly builds
schedule:
- cron: '0 0 * * *' # run at midnight UTC
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Protoc
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()
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 }}
142 changes: 102 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
<artifactId>oxia-java</artifactId>
<version>0.0.15-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Oxia Implementations for Java</name>

<inceptionYear>2022</inceptionYear>
<name>Oxia Client SDK for Java</name>
<description>Oxia Client SDK for Java</description>
<url>http://github.com/streanative/oxia-java</url>
<inceptionYear>2023</inceptionYear>

<organization>
<name>StreamNative Inc.</name>
Expand All @@ -50,12 +51,23 @@
<module>pulsar-metadatastore-oxia</module>
</modules>

<scm>
<connection>scm:git:git://github.com/streamnative/oxia-java.git</connection>
<developerConnection>scm:git:ssh://github.com:streamnative/oxia-java.git</developerConnection>
<url>https://github.com/streamnative/oxia-java</url>
</scm>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/streamnative/oxia-java</url>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<name>Snapshot Repository OSSRH</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<properties>
Expand Down Expand Up @@ -349,40 +361,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<doclint>none</doclint>
<notimestamp>true</notimestamp>
<sourceFileExcludes>
<sourceFileExclude>**/generated-sources/*.java</sourceFileExclude>
</sourceFileExcludes>
</configuration>
<executions>
<execution>
<goals>
<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>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
Expand Down Expand Up @@ -465,4 +443,88 @@
</plugins>
</build>

<profiles>
<profile>
<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>
<executions>
<execution>
<id>sign-release-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<doclint>none</doclint>
<notimestamp>true</notimestamp>
<sourceFileExcludes>
<sourceFileExclude>**/generated-sources/*.java</sourceFileExclude>
</sourceFileExcludes>
</configuration>
<executions>
<execution>
<goals>
<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>
<executions>
<execution>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit c1cc49c

Please sign in to comment.