name: Publish to Maven Central on: workflow_dispatch: jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout project uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: ref: main fetch-depth: 0 - name: Cache Maven uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ~/.m2/repository key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Setup Java JDK uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0 with: java-version: '11' distribution: 'microsoft' 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 }}