Publish to Maven Central #6
This file contains hidden or 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: | |
| inputs: | |
| releaseVersion: | |
| description: 'This release version (example 1.1.1)' | |
| required: true | |
| default: '1.x.x' | |
| nextVersion: | |
| description: 'Next version (example 1.1.2-SNAPSHOT)' | |
| required: true | |
| default: '1.x.x-SNAPSHOT' | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| if: github.actor == 'flexca' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: GPG_PASSPHRASE | |
| - name: Configure Git | |
| run: | | |
| git config --global user.email "action@github.com" | |
| git config --global user.name "GitHub Action" | |
| - name: Release and Deploy | |
| run: | | |
| REPO_URL="https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | |
| mvn --batch-mode release:prepare release:perform \ | |
| -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ | |
| -DdevelopmentVersion=${{ github.event.inputs.nextVersion }} \ | |
| -DpushChanges=true \ | |
| -DlocalCheckout=true \ | |
| -DscmCommentPrefix="[release] " \ | |
| -Darguments="-DskipTests -Prelease" \ | |
| -DdeveloperConnection="scm:git:$REPO_URL" | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: publish | |
| if: github.actor == 'flexca' | |
| steps: | |
| - name: Checkout released tag | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ github.event.inputs.releaseVersion }} | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Build Web-Tool (Release Version) | |
| run: mvn clean package -DskipTests | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./web-tool/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/enot-web-tool:${{ github.event.inputs.releaseVersion }} | |
| ${{ secrets.DOCKERHUB_USERNAME }}/enot-web-tool:latest |