Skip to content

aiotrope/skeleton

Repository files navigation

skeleton

Conventional commits friendly template for SOME nodejs projects.

Build-up

Basic project setup

Create git remote project & clone the remote repo locally.

Initialize release-it project

$ npm init release-it
# Publish a GitHub Release with every release? Yes or 
# Where to add the release-it config? › .release-it.json

Configure release-it.json and place the release-it as script in package.json

# release-it.json
{
  "git": {
    "commitMessage": "chore: release v${version}",
    "changelog": "npx auto-changelog --stdout --commit-limit false -u --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs",
    "requireBranch": "main"
  },
  "hooks": {
    "after:bump": "npx auto-changelog -p"
  },
  "github": {
    "release": true
  },
  "npm": {
    "publish": false
  }
}
# package.json
 "scripts": {
    "release": "release-it"
  }

Install Dev dependencies

$ npm i -D @commitlint/{config-conventional,cli} husky auto-changelog

Generate commitlint.config.js

$ echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js

Execute husky

$ npx husky install

Generate commit-msg hook

$ npx husky add .husky/commit-msg 'npx commitlint --edit $1'

Globally install commitizen & adapter

$ npm install -g commitizen cz-conventional-changelog
$ echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

Commit changes

$ git add . 
$ git cz # commitizen

Generate changelog and/or push to remote repo

$ npm run release

Auto releases using changelog

  • Create release.yml in .github/workflows directory.
  • The scripts will generate releases automatically after the code has been pushed to Github.
  • Refer to this link for the sample workflow.