v0.2.0 - Native executable 🎉 #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" != "$POM_VERSION" ]; then | |
| echo "Error: Git tag ($RELEASE_VERSION) does not match pom.xml version ($POM_VERSION)" | |
| exit 1 | |
| fi | |
| echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "[email protected]" | |
| - name: Update pom.xml to release version | |
| run: | | |
| mvn versions:set-property -Dproperty=revision -DnewVersion=${{ env.RELEASE_VERSION }} -B -q | |
| git commit -am "Set version to ${{ env.RELEASE_VERSION }}" || echo "No changes" | |
| git push origin HEAD:main | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run tests | |
| run: mvn clean verify -B | |
| - name: Publish RELEASE to Maven Central | |
| run: mvn deploy -pl jfiletreeprettyprinter-core -P release -B -DskipTests | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Bump to next patch snapshot | |
| run: | | |
| CURRENT=${{ env.RELEASE_VERSION }} | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| NEXT_PATCH=$((PATCH+1)) | |
| NEXT_VERSION="$MAJOR.$MINOR.$NEXT_PATCH-SNAPSHOT" | |
| echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | |
| mvn versions:set-property -Dproperty=revision -DnewVersion=$NEXT_VERSION -B -q | |
| git commit -am "Set version to $NEXT_VERSION" || echo "No changes" | |
| git push origin HEAD:main |