v0.0.1 - Initial release #3
Workflow file for this run
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 RELEASE to Maven Central | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
| - name: Verify tag matches pom.xml version | |
| run: | | |
| TAG_NAME=${GITHUB_REF_NAME} # e.g., v1.2.3 | |
| RELEASE_VERSION=${TAG_NAME#v} # remove leading 'v' | |
| POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "Git tag: $RELEASE_VERSION" | |
| echo "Pom version: $POM_VERSION" | |
| if [ "${RELEASE_VERSION}-SNAPSHOT" != "$POM_VERSION" ]; then | |
| echo "Error: Git tag ($RELEASE_VERSION) does not match pom.xml version ($POM_VERSION)" | |
| exit 1 | |
| fi | |
| shell: bash | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "[email protected]" | |
| - name: Extract release version | |
| run: | | |
| TAG_NAME=${GITHUB_REF_NAME} | |
| VERSION=${TAG_NAME#v} | |
| echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Update pom.xml to release version | |
| run: | | |
| mvn versions:set -DnewVersion=${{ env.RELEASE_VERSION }} -B -q | |
| git commit -am "Set version to ${{ env.RELEASE_VERSION }}" || echo "No changes" | |
| git push origin "HEAD:${GITHUB_REF_NAME}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run tests | |
| run: mvn clean verify -B | |
| - name: Publish RELEASE to Maven Central | |
| run: mvn deploy -P release -B -DskipTests | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |