chore: add prerelease script #1005
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: Require release notes for breaking changes | |
| on: | |
| pull_request: | |
| jobs: | |
| release-notes-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check breaking changes + release notes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" | |
| echo "Checking range: $RANGE" | |
| # match conventional commit types that are marked as breaking via `!` | |
| # or messages that containt `BREAKING CHANGE:` | |
| if (git log --format=%B "$RANGE" | grep -E '^BREAKING') || | |
| (git log --format=%s "$RANGE" | grep -v '^fixup!' | cut -d: -f1 | grep -E '!'); then | |
| BREAKING=1 | |
| else | |
| BREAKING=0 | |
| fi | |
| if [ "$BREAKING" -eq 0 ]; then | |
| echo "No breaking changes detected." | |
| exit 0 | |
| fi | |
| # Print changed files of range and check if release notes are part of it. | |
| if git diff --name-only "$RANGE" | \ | |
| grep -q 'cc-book/src/release_notes.md'; then | |
| echo "Release notes updated." | |
| exit 0 | |
| fi | |
| echo "::error::Breaking change detected but cc-book/src/release_notes.md was not updated." | |
| exit 1 |