Publish to Maven Central #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to Maven Central | |
on: | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Cache Maven | |
uses: actions/cache@v2.1.4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Setup Java JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_CENTRAL_TOKEN | |
gpg-private-key: ${{ secrets.GPG_PRIVATEKEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Configure Git user | |
run: | | |
git config user.email "actions@github.com" | |
git config user.name "GitHub Actions" | |
- name: Version | |
id: version | |
run: | | |
release_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) | |
release_version=${release_version%-*} | |
echo ::set-output name=version::${release_version} | |
- name: Release | |
run: | | |
export GPG_TTY=$(tty) | |
./mvnw -Darguments="-Drelease=true" -B release:prepare release:perform -Drelease=true \ | |
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_NAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Git-release | |
run: | | |
./mvnw -B versions:set -DnewVersion=${{steps.version.outputs.version}} | |
./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release | |
env: | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |