Skip to content

Detect breaking changes #5

Detect breaking changes

Detect breaking changes #5

name: "Detect breaking changes"
on:
pull_request:
branches:
- main
permissions:
contents: read
jobs:
check-semver:
name: Check semver
runs-on: ubuntu-latest
outputs:
logs: ${{ steps.check_semver.outputs.logs }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch main branch
run: git fetch https://github.com/${{ github.repository }}.git main:refs/remotes/origin/main
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-semver-checks
run: cargo install cargo-semver-checks
- name: Run cargo-semver-checks
id: check_semver
run: |
set +e
cargo semver-checks --baseline-rev origin/main 2>&1 | tee /tmp/semver-output.txt
EXIT_CODE=${PIPESTATUS[0]}
OUTPUT=$(sed 's/\x1b\[[0-9;]*m//g' /tmp/semver-output.txt)
echo "logs<<EOF" >> "$GITHUB_OUTPUT"
echo "$OUTPUT" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
exit $EXIT_CODE
comment-on-pr:
name: Comment on pull request
runs-on: ubuntu-latest
needs: check-semver
if: always()
permissions:
contents: read
pull-requests: write
steps:
- name: Comment
if: ${{ needs.check-semver.result != 'success' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-semver-check-error
message: |
Thank you for opening this pull request!
Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes made since the last release.
Details:
```
${{ needs.check-semver.outputs.logs }}
```
- name: Delete comment
if: ${{ needs.check-semver.result == 'success' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-semver-check-error
delete: true