release: git fetch all tag with force to avoid "would clobber existin… #28
Workflow file for this run
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: Release to Maven Central | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: olegtarasov/get-tag@v2.1.3 | |
id: tagName | |
with: | |
tagRegex: "(.*)" | |
- name: Set Release version env variable | |
run: | | |
echo "TAG_NAME=${{ steps.tagName.outputs.tag }}" >> $GITHUB_ENV | |
# if no tag exists, this is expected to fail | |
- name: Switch to git tag for release | |
run: | | |
git fetch --all --tags -f | |
git checkout tags/${{ env.TAG_NAME }} -b ${{ env.TAG_NAME }}-tmp-branch | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 11 | |
server-id: sonatype-nexus | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} | |
- name: Deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSWORD }} | |
run: | | |
./mvnw --batch-mode -Drevision=${{ env.TAG_NAME }} -P release clean deploy | |
- name: Create GHA release | |
uses: ncipollo/release-action@v1 | |
with: | |
draft: true | |
artifacts: "sonar-pmd-plugin/target/*.jar" | |
bodyFile: CHANGELOG.md |