Open14

conventional-changelog を使いこなしたい

odanodan

commitlint の Shared configuration を眺める

https://github.com/conventional-changelog/commitlint#shared-configuration

  • 基本的に <type>(<scope>): <short summary> という形式になっているかをチェックするもの
    • type/scope が lower-case になっているかとか、type の validation をしてくれる
  • @commitlint/config-angular@commitlint/config-conventional は似たような感じ?
  • @commitlint/config-lerna-scopes@commitlint/config-nx-scopes も似たような感じ
    • monorepo の packages 以下に生えているパッケージだけを scope に指定するルールみたい
    • monorepo やってるならこれを選ぶのが良さそう
  • @commitlint/config-patternplatescope を自分で設定できるやつっぽい
    • @commitlint/config-angular` の拡張版

今回は monorepo に commitlint を導入したいので @commitlint/config-lerna-scopes が良さそう

odanodan

config は commitlint.config.ts に書くことができる

型の付け方も含めて書き方は次の通り

commitlint.config.ts
import type { UserConfig } from "@commitlint/types";

const config: UserConfig = { extends: ["@commitlint/config-lerna-scopes"] };

export default config;
odanodan

https://twitter.com/odan3240/status/1496316286607163393

こういう感じかな

check-pull-request-title.yml
name: Check Pull Request Title

on:
  pull_request:
    types: [opened, synchronize, reopened, edited]
  workflow_dispatch:

jobs:
  check:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: nodenv/actions/node-version@main
        id: nodenv
      - name: Use Node.js ${{ steps.nodenv.outputs.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ steps.nodenv.outputs.node-version }}
          cache: yarn
      - name: yarn install
        run: |
          yarn install --frozen-lockfile

      - name: Check title
        run: echo "${{ github.event.pull_request.title }}" | yarn commitlint
odanodan

https://github.com/conventional-changelog/releaser-tools は GitHub/GitLab などのリリース機能のためのツール群のリポジトリ

conventional-github-releaser を使えば良さそう...?

でもこれだと、CHANGELOG 作るのが lerna で、Release 作るのがこのツールになって良くないかな
CHANGELOG.md から Release 作る君が求められているかも

あとタグを push したら自動的に Release も作られるようにしたい

odanodan

lerna-changelogで始める頑張りすぎないリリースノート自動生成 | WEB EGG がリリース系のツールのまとめとしてよかった

  • semantic-release
  • conventional-changelog
    • コミットメッセージで縛る系
  • lerna-changelog
    • プルリクのラベルで縛る系

これらを release-it で使うためにプラグインが存在する形

なので、commitlint で conventional なメッセージに縛っているなら conventional-changelog を使うのが良さそう?