|
| 1 | +name: 👀 Detect public API changes |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + new: |
| 9 | + description: 'Branch/tag of the new/updated version' |
| 10 | + required: true |
| 11 | + old: |
| 12 | + description: 'Branch/tag of the old/comparison version' |
| 13 | + required: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + |
| 17 | + build: |
| 18 | + runs-on: macos-14 # Apple Silicon Runner |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: n1hility/cancel-previous-runs@v3 |
| 23 | + with: |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + |
| 26 | + - name: Select latest Xcode |
| 27 | + uses: maxim-lobanov/setup-xcode@v1 |
| 28 | + with: |
| 29 | + xcode-version: '15.4' |
| 30 | + |
| 31 | + - name: 🚚 Fetch repo |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - name: 🔍 Detect Changes |
| 37 | + run: | |
| 38 | + PROJECT_FOLDER=$PWD |
| 39 | + |
| 40 | + NEW="${{ env.source }}~${{ env.githubRepo }}" |
| 41 | + if [[ '${{ github.head_ref || env.noTargetBranch }}' == 'release/*' ]] |
| 42 | + then |
| 43 | + LATEST_TAG=$(git describe --tags --abbrev=0) |
| 44 | + OLD="$LATEST_TAG~${{ env.githubRepo }}" |
| 45 | + else |
| 46 | + OLD="${{ env.target }}~${{ env.githubRepo }}" |
| 47 | + fi |
| 48 | + |
| 49 | + cd Scripts |
| 50 | + ./public-api-diff project --new "$NEW" --old "$OLD" --output "$PROJECT_FOLDER/api_comparison.md" --log-output "$PROJECT_FOLDER/logs.txt" |
| 51 | + cat "$PROJECT_FOLDER/logs.txt" |
| 52 | + cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY |
| 53 | + env: |
| 54 | + source: '${{ github.event.inputs.new || github.head_ref }}' |
| 55 | + target: '${{ github.event.inputs.old || github.event.pull_request.base.ref }}' |
| 56 | + githubRepo: '${{github.server_url}}/${{github.repository}}.git' |
| 57 | + noTargetBranch: 'no target branch' |
| 58 | + |
| 59 | + - if: ${{ github.event.pull_request.base.ref != '' }} |
| 60 | + name: 📝 Comment on PR |
| 61 | + uses: thollander/actions-comment-pull-request@v3 |
| 62 | + with: |
| 63 | + file-path: "${{ github.workspace }}/api_comparison.md" |
| 64 | + comment-tag: api_changes |
| 65 | + mode: recreate |
0 commit comments