Skip to content

[Release] 0.8.4

[Release] 0.8.4 #129

name: 👀 Detect public API changes
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
new:
description: 'Branch/tag of the new/updated version'
required: true
old:
description: 'Branch/tag of the old/comparison version'
required: true
jobs:
build:
runs-on: macos-14 # Apple Silicon Runner
steps:
- uses: actions/checkout@v4
- uses: n1hility/cancel-previous-runs@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Select latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: 🚚 Fetch repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 👾 Define Diff Versions
run: |
NEW="${{ env.source }}~${{ env.headGithubRepo }}"
OLD="${{ env.target }}~${{ env.baseGithubRepo }}"
if [[ '${{ env.targetBranchName || env.noTargetBranch }}' == release/* ]]
then
LATEST_TAG=$(git describe --tags --abbrev=0)
OLD="$LATEST_TAG~${{ env.baseGithubRepo }}"
fi
# Providing the output to the environment
echo "OLD_VERSION=$OLD" >> $GITHUB_ENV
echo "NEW_VERSION=$NEW" >> $GITHUB_ENV
env:
source: '${{ github.event.inputs.new || github.head_ref }}'
target: '${{ github.event.inputs.old || github.event.pull_request.base.ref }}'
headGithubRepo: '${{github.server_url}}/${{ github.event.pull_request.head.repo.full_name || github.repository}}.git'
baseGithubRepo: '${{github.server_url}}/${{github.repository}}.git'
noTargetBranch: 'no target branch'
targetBranchName: '${{ github.head_ref }}'
- name: 🧰 Build Swift CLI
run: swift build --configuration release
- name: 🏃 Run Diff
run: |
NEW=${{ env.NEW_VERSION }}
OLD=${{ env.OLD_VERSION }}
PLATFORM="macOS"
PROJECT_FOLDER=${{ github.workspace }}
BINARY_PATH="$(swift build --configuration release --show-bin-path)/public-api-diff"
echo "▶️ Running binary at $BINARY_PATH"
$BINARY_PATH project --new "$NEW" --old "$OLD" --platform "$PLATFORM" --output "$PROJECT_FOLDER/api_comparison.md" --log-output "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/logs.txt"
if [[ ${{ env.HEAD_GITHUB_REPO != env.BASE_GITHUB_REPO }} ]]; then
echo "---" >> $GITHUB_STEP_SUMMARY
echo "> [!IMPORTANT]" >> $GITHUB_STEP_SUMMARY
echo "> **Commenting on pull requests from forks is not possible** due to insufficient permissions." >> $GITHUB_STEP_SUMMARY
echo "> Once merged, the output will be posted as an auto-updating comment under the pull request." >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
fi
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
# We only want to comment if we're in a Pull Request and if the Pull Request is not from a forked Repository
# Forked Repositories have different rights for security reasons and thus it's not possible to comment on PRs without lowering the security
# once the tool is merged the base repo rights apply and the script can comment on PRs as expected.
- if: ${{ github.event.pull_request.base.ref != '' && env.HEAD_GITHUB_REPO == env.BASE_GITHUB_REPO }}
name: 📝 Comment on PR
uses: thollander/actions-comment-pull-request@v3
with:
file-path: "${{ github.workspace }}/api_comparison.md"
comment-tag: api_changes
mode: recreate