Skip to content

Instantly share code, notes, and snippets.

@tqh
Created February 5, 2021 15:48
Show Gist options
  • Save tqh/f8ee29ae07a1c5d1adbd04c55548f5b0 to your computer and use it in GitHub Desktop.
Save tqh/f8ee29ae07a1c5d1adbd04c55548f5b0 to your computer and use it in GitHub Desktop.
GitHub Action For Maven Central Deploy
jobs:
deploy:
name: Maven Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v2
- name: Use Java 11
uses: actions/setup-java@v1
with:
java-version: 11
server-id: ossrh
server-username: SONATYPE_USER
server-password: SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Maven Package Source and JavaDoc Jars Signed
env:
GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn -ntp -T 1C package source:jar-no-fork javadoc:jar gpg:sign deploy
...
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution><goals><goal>enforce</goal></goals></execution>
</executions>
<configuration>
<rules>
<requireMavenVersion><version>3.6.3</version></requireMavenVersion>
</rules>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<quiet>true</quiet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<gpgArguments><arg>--batch</arg><arg>--pinentry-mode</arg><arg>loopback</arg></gpgArguments>
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
<interactive>false</interactive>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment