Build - push #954
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
| # Build and Test | |
| # | |
| # Description: | |
| # Builds the project and runs unit tests for every supported Java version. | |
| # | |
| # Triggers: | |
| # - pull_request: when a PR targets main | |
| # - push: when code is pushed to main | |
| # - milestone: when milestone metadata changes | |
| # | |
| # Notes: | |
| # Builds against Java 17, 21, and 25. | |
| name: Build | |
| run-name: Build - ${{ github.event_name }} | |
| on: | |
| workflow_dispatch: | |
| milestone: | |
| types: [created, edited, closed, deleted] | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/build.yml' | |
| - 'sdk/**' | |
| - 'sdk-testing/**' | |
| - 'sdk-integration-tests/**' | |
| - 'examples/**' | |
| - 'pom.xml' | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/build.yml' | |
| - 'sdk/**' | |
| - 'sdk-testing/**' | |
| - 'sdk-integration-tests/**' | |
| - 'examples/**' | |
| - 'pom.xml' | |
| permissions: | |
| contents: read | |
| issues: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| java: | |
| - 17 | |
| - 21 | |
| - 25 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event_name == 'milestone' && github.event.repository.default_branch || github.ref }} | |
| - name: Setup Java ${{ matrix.java }} | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: corretto | |
| java-version: ${{ matrix.java }} | |
| cache: maven | |
| - name: Build and test | |
| run: mvn -B install --file pom.xml | |
| - name: Generate JaCoCo Badge | |
| if: ${{ matrix.java == 17 }} | |
| uses: cicirello/jacoco-badge-generator@72266185b7ee48a6fd74eaf0238395cc8b14fef8 # v2 | |
| with: | |
| jacoco-csv-file: coverage-report/target/site/jacoco-aggregate/jacoco.csv | |
| badges-directory: coverage-report/target/site/jacoco-aggregate | |
| - name: Generate javadoc site | |
| if: ${{ matrix.java == 17 }} | |
| run: mvn -B -pl sdk -am javadoc:javadoc | |
| - name: Generate milestone badge | |
| if: ${{ matrix.java == 17 }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| TITLE=$(gh api repos/${{ github.repository }}/milestones \ | |
| --jq '[.[] | select(.state == "open" and .due_on != null)] | sort_by(.due_on) | .[0].title // empty') | |
| if [ -z "$TITLE" ]; then | |
| URL="https://img.shields.io/badge/Next%20Milestone-No%20milestone-lightgrey" | |
| else | |
| ENCODED=$(echo -n "$TITLE" | jq -sRr @uri | sed 's/-/--/g') | |
| URL="https://img.shields.io/badge/Next%20Milestone-${ENCODED}-blue" | |
| fi | |
| mkdir -p milestone | |
| curl -sfL "$URL" -o milestone/badge.svg | |
| echo "Badge generated for: ${TITLE:-No milestone}" | |
| - name: Configure GitHub Pages | |
| if: ${{ matrix.java == 17 }} | |
| uses: actions/configure-pages@v6 | |
| - name: Prepare GitHub Pages artifact | |
| if: ${{ matrix.java == 17 }} | |
| run: | | |
| mkdir -p github-pages/coverage github-pages/javadoc github-pages/milestone | |
| cp -R coverage-report/target/site/jacoco-aggregate/. github-pages/coverage | |
| cp -R sdk/target/reports/apidocs/. github-pages/javadoc | |
| cp -R milestone/. github-pages/milestone | |
| touch github-pages/.nojekyll | |
| - name: Upload GitHub Pages artifact | |
| if: ${{ matrix.java == 17 }} | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: github-pages | |
| deploy-pages: | |
| if: ${{ github.event_name == 'milestone' || github.ref == 'refs/heads/main' }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |