Merge pull request #7 from endee-io/dev #4
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: Release to Maven Central | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| server-id: central | |
| server-username: CENTRAL_USERNAME | |
| server-password: CENTRAL_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: GPG_PASSPHRASE | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Get current version and increment | |
| id: version | |
| run: | | |
| CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Remove -SNAPSHOT if present | |
| RELEASE_VERSION=${CURRENT_VERSION%-SNAPSHOT} | |
| echo "release=$RELEASE_VERSION" >> $GITHUB_OUTPUT | |
| # Calculate next version (increment patch) | |
| IFS='.' read -r major minor patch <<< "$RELEASE_VERSION" | |
| NEXT_VERSION="$major.$minor.$((patch + 1))-SNAPSHOT" | |
| echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Set release version | |
| run: | | |
| mvn versions:set -DnewVersion=${{ steps.version.outputs.release }} -DgenerateBackupPoms=false | |
| - name: Build and verify | |
| run: mvn -B clean verify -Prelease | |
| env: | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Deploy to Maven Central | |
| run: mvn -B deploy -Prelease -DskipTests | |
| env: | |
| CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | |
| CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Create Git tag | |
| run: | | |
| git tag -a "v${{ steps.version.outputs.release }}" -m "Release v${{ steps.version.outputs.release }}" | |
| git push origin "v${{ steps.version.outputs.release }}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.release }} | |
| name: Release v${{ steps.version.outputs.release }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set next development version | |
| run: | | |
| mvn versions:set -DnewVersion=${{ steps.version.outputs.next }} -DgenerateBackupPoms=false | |
| git add pom.xml | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.next }} [skip ci]" | |
| git push origin main |