diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 0000000..85746f1 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,33 @@ +name: PR Title + +on: + pull_request_target: + types: [opened, edited, synchronize] + +permissions: + pull-requests: read + +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + requireScope: false + subjectPattern: ^[a-z].+$ + subjectPatternError: "The subject must start with a lowercase letter: '{subject}'" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50db3c5..6da4b4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,7 @@ jobs: uses: bruits/sampo/crates/sampo-github-action@main with: command: auto + pr-title: "chore(release): bump versions and changelogs" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01d948c..ab3d1f6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -174,14 +174,28 @@ This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formattin - Keep functions focused and small - Add docstrings to public functions and classes -### Commit Messages +### PR Titles -Please use [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716). -For the scope, you can also mention the package names. -Use clear, descriptive commit messages that explain the "why" behind the change. +Since all branches are squash-merged, the **PR title becomes the commit message** on `main`. PR titles are validated by CI using [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) format: -These commit conventions are generally most important on commits to main. -All branch commits get squash-merged. +``` +type(scope): subject +``` + +- **type** (required): `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert` +- **scope** (optional): package name or area, e.g. `feat(generaltranslation): add new method` +- **subject** (required): lowercase start, describes the "why" behind the change + +Examples: + +``` +feat: add batch translation support +fix(generaltranslation): handle empty input gracefully +chore: update dependencies +docs: clarify setup instructions +``` + +Individual commit messages on feature branches are not enforced, but following the same convention is encouraged. ## Join The Project Team