Publish SNAPSHOTs to Sonatype OSS

The following is a quick recipe to publish Maven SNAPSHOTs to the Sonatype OSS maven repository.


name: nightly
on:
  [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout sources
      uses: actions/checkout@v1
    - name: Set up Java
      uses: actions/setup-java@v1
    - name: Build with Maven
      run: mvn -B -DskipTests=true -f pom.xml clean install
    - name: Publish SNAPSHOTS to oss.sonatype.org
      run: mvn --no-transfer-progress -B -DskipTests=true deploy
      env:
          MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
          MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
        

Add the OSSRH_USERNAME secret as a secret to your GitHub account, which is your username for the OSS Sonatype repository. Add the OSSRH_TOKEN secret as a secret to your GitHub account, which is your password for the OSS Sonatype repository.

Make sure your POM file contains the following snippet:


    <distributionManagement>      
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>
        

Posted June 28th, 2021

Up