diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 18f96b095c..d88886cea9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,3 +10,10 @@ ## How to test the changes (if needed) - (How should a reviewer test this functionality.) + +## Labels +Please add exactly one of the following labels to this PR: +- `breaking-change` — This PR introduces a breaking change to the public API +- `non-breaking-change` — This PR does not break any existing functionality + +The label check CI job will fail until one of these labels is applied. diff --git a/.github/release.yml b/.github/release.yml index 8711864f4e..226ed2503f 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -1,5 +1,8 @@ changelog: categories: + - title: Breaking Changes + labels: + - breaking-change - title: New Features labels: - connector-update diff --git a/.github/workflows/label-check.yml b/.github/workflows/label-check.yml new file mode 100644 index 0000000000..4bdf9b0e21 --- /dev/null +++ b/.github/workflows/label-check.yml @@ -0,0 +1,43 @@ +name: Label Check + +on: + pull_request: + types: [opened, reopened, ready_for_review, labeled, unlabeled, synchronize] + +permissions: read-all + +jobs: + label-check: + if: github.actor != 'dependabot[bot]' + runs-on: ubuntu-latest + + permissions: + pull-requests: read + + steps: + - uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.github.com:443 + github.com:443 + + - name: Check for required labels + env: + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} + run: | + HAS_BREAKING=$(echo "$LABELS" | jq 'map(select(. == "breaking-change")) | length') + HAS_NON_BREAKING=$(echo "$LABELS" | jq 'map(select(. == "non-breaking-change")) | length') + + if [ "$HAS_BREAKING" -gt 0 ] && [ "$HAS_NON_BREAKING" -gt 0 ]; then + echo "::error::PR has both 'breaking-change' and 'non-breaking-change' labels. Please remove one — a change cannot be both." + exit 1 + fi + + if [ "$HAS_BREAKING" -eq 0 ] && [ "$HAS_NON_BREAKING" -eq 0 ]; then + echo "::error::PR is missing a required label. Please add exactly one of: 'breaking-change' or 'non-breaking-change'." + exit 1 + fi + + echo "✅ Label check passed."