API Tracker (Java 25) #7
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: API Tracker (Java 25) | |
| on: | |
| workflow_dispatch: # Manual trigger only | |
| permissions: | |
| issues: write | |
| contents: read | |
| jobs: | |
| track-api: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '25' | |
| distribution: 'temurin' | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-java25-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2 | |
| - name: Build and test project | |
| run: mvn clean install | |
| - name: Run API Tracker | |
| id: tracker | |
| run: | | |
| mvn exec:java \ | |
| -pl json-java21-api-tracker \ | |
| -Dexec.mainClass="io.github.simbo1905.tracker.ApiTrackerRunner" \ | |
| -Dexec.args="INFO" \ | |
| -Djava.util.logging.ConsoleHandler.level=INFO | |
| # Read outputs into environment | |
| echo "fingerprint=$(cat target/api-tracker/fingerprint.txt)" >> $GITHUB_OUTPUT | |
| echo "has_differences=$(cat target/api-tracker/has-differences.txt)" >> $GITHUB_OUTPUT | |
| - name: Upload API report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: api-tracker-report | |
| path: target/api-tracker/ | |
| retention-days: 90 | |
| - name: Check for existing issue | |
| if: steps.tracker.outputs.has_differences == 'true' | |
| id: check_issue | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| FINGERPRINT="${{ steps.tracker.outputs.fingerprint }}" | |
| echo "Looking for existing issue with hash:${FINGERPRINT}" | |
| # Search for open issues with this fingerprint | |
| EXISTING=$(gh issue list --state open --search "hash:${FINGERPRINT} in:title" --json number --jq '.[0].number // empty') | |
| if [ -n "$EXISTING" ]; then | |
| echo "Found existing issue #${EXISTING}" | |
| echo "issue_exists=true" >> $GITHUB_OUTPUT | |
| echo "existing_issue=${EXISTING}" >> $GITHUB_OUTPUT | |
| else | |
| echo "No existing issue found" | |
| echo "issue_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create issue for API differences | |
| if: steps.tracker.outputs.has_differences == 'true' && steps.check_issue.outputs.issue_exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| FINGERPRINT="${{ steps.tracker.outputs.fingerprint }}" | |
| SUMMARY=$(cat target/api-tracker/summary.md) | |
| # Create issue body | |
| cat > /tmp/issue_body.md << EOF | |
| ${SUMMARY} | |
| ## Details | |
| - **Fingerprint**: \`hash:${FINGERPRINT}\` | |
| - **Workflow Run**: [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| - **Artifact**: Download the full JSON report from the workflow artifacts | |
| This issue was auto-generated by the API Tracker workflow. | |
| EOF | |
| gh issue create \ | |
| --title "API drift detected [hash:${FINGERPRINT}]" \ | |
| --body-file /tmp/issue_body.md \ | |
| --label "api-tracking,upstream-sync" |