standard-version(desperated)

版本发布后使用, 用于将commit记录转化为changelog

  1. 安装依赖
yarn add -D standard-version
  1. 添加script命令
  • 对于上传神兵的组件库
// package.json
  "scripts": {
        "release": "yarn build && standard-version && npm publish",
  },
  • 对于手动部署的项目
// package.json
 "scripts": {
        "release": "standard-version",
},
  1. 使用流程
  • 组件库发布时
yarn release
git add .
git commit -m "chore: 更新文档和CHANGELOG.md"
git push
  • 手动部署项目时
// package.json
version: 即将发布版本号 (e.g. 5.12.20)
yarn release
git add .
git commit -m "chore: 更新文档和CHANGELOG.md"
git push
  • 使用monorepo的时候 单独为每个子包生成changelog,关键指令是—commit-path
conventional-changelog --preset angular --release-count 0 --commit-path $PWD/packages/components --pkg $PWD/packages/components/package.json --outfile $PWD/packages/components/CHANGELOG.md

相关文档: https://github.com/conventional-changelog/conventional-changelog/issues/556#issuecomment-555539998 https://github.com/lerna/lerna/tree/main/commands/version#generating-initial-changelogs conventional-changelog的各个参数说明 https://www.kuxiaoxin.com/archives/35