diff --git a/.github/conventional-subject.sh b/.github/conventional-subject.sh new file mode 100755 index 00000000..4474538f --- /dev/null +++ b/.github/conventional-subject.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +status=0 + +while IFS= read -r subject; do + [ -n "$subject" ] || continue + + if ! printf '%s' "$subject" | grep -qE '^(chore|feat|fix)(\([a-z0-9._-]+\))?!?: .+'; then + echo "::error::\"$subject\" must start with chore:, feat: or fix:, optionally scoped. Squash merging takes the pull request title as the commit subject, and release-please only recognises those three types." + status=1 + fi +done + +exit $status diff --git a/.github/release-please-config.json b/.github/release-please-config.json index bc147d94..1a4699bc 100644 --- a/.github/release-please-config.json +++ b/.github/release-please-config.json @@ -15,7 +15,7 @@ { "type": "chore", "section": "Miscellaneous", - "hidden": true + "hidden": false } ], "plugins": [ diff --git a/.github/workflows/main-subjects.yml b/.github/workflows/main-subjects.yml new file mode 100644 index 00000000..6fa50870 --- /dev/null +++ b/.github/workflows/main-subjects.yml @@ -0,0 +1,31 @@ +name: Main subjects + +on: + push: + branches: + - main + +permissions: + contents: read + +jobs: + conventional: + name: Landed commit types + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + with: + fetch-depth: 0 + + - name: Check the landed subjects + env: + BEFORE: ${{ github.event.before }} + AFTER: ${{ github.sha }} + run: | + if git cat-file -e "$BEFORE^{commit}" 2>/dev/null; then + revisions=("$BEFORE..$AFTER") + else + revisions=(--max-count=1 "$AFTER") + fi + + git log --no-merges --format=%s "${revisions[@]}" | .github/conventional-subject.sh diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 00000000..5f4434f5 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,24 @@ +name: PR title + +on: + pull_request: + types: + - opened + - edited + - reopened + - synchronize + +permissions: + contents: read + +jobs: + conventional: + name: Conventional commit type + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 + + - name: Check the title + env: + TITLE: ${{ github.event.pull_request.title }} + run: printf '%s\n' "$TITLE" | .github/conventional-subject.sh