Update publish workflow #84
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: build | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| - 'feature/**' | |
| pull_request: | |
| branches: | |
| - 'master' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetches all tags for version calculation | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 25 | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| server-id: github # Matches the <id> in pom.xml distributionManagement | |
| settings-path: ${{ github.workspace }} | |
| # Install Xvfb and necessary Gtk/X11 dependencies for xvfb | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y xvfb libgtk-3-0t64 libgbm-dev libasound2t64 | |
| - name: Build with Maven | |
| run: xvfb-run --auto-servernum mvn -B -ntp package jacoco:report --file pom.xml | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Calculate Next Snapshot Version | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| id: versioning # referenced later | |
| run: | | |
| # Get the closest tag on this branch's history | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") | |
| # Extract prefix and increment the last numeric group | |
| PREFIX=$(echo "$LATEST_TAG" | sed -E 's/[0-9]+$//') | |
| LAST_NUM=$(echo "$LATEST_TAG" | grep -oE '[0-9]+$' || echo "0") | |
| NEXT_VERSION="${PREFIX}$((LAST_NUM + 1))-SNAPSHOT" | |
| echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Deploying version: $NEXT_VERSION" | |
| - name: Publish Snapshot | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| run: | | |
| mvn -B -ntp deploy \ | |
| -Drevision=${{ steps.versioning.outputs.next_version }} \ | |
| -DskipTests \ | |
| --settings ${{ github.workspace }}/settings.xml | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |