Awesome Open Source
Awesome Open Source

Automatic Versioning Guide

Version Stars Issues

About   |   Requirements   |   Configuration   |   Author

About

This is a quick guide on how to implement automatic semantic versioning using husky.js, commitlint, semantic release and github actions.

Requirements

Configuration

HuskyJS

  1. Install husky
yarn add husky --dev
  1. Enable Git hooks
yarn husky install
  1. To automatically have Git hooks enabled after install, edit package.json
// package.json

{
  "private": true, // <- your package is private, you only need postinstall
  "scripts": {
    "postinstall": "husky install"
  }
}

Commitlint

  1. Install commitlint 🔗
yarn add @commitlint/cli @commitlint/config-conventional --dev
  1. Configure
// commitlint.config.js

module.exports = {
  extends: ["@commitlint/config-conventional"],
};
  1. Add hook
yarn husky add .husky/commit-msg 'yarn commitlint --edit $1'
  1. Test simple usage For a first simple usage test of commitlint you can do the following:
npx commitlint --from HEAD~1 --to HEAD --verbose

Semantic Release

  1. Install semantic-release
yarn add semantic-release --dev
  1. Install plugins 🔗
  • Default plugins

    These four plugins are already part of semantic-release and are listed in order of execution. They do not have to be installed separately:

"@semantic-release/commit-analyzer"
"@semantic-release/release-notes-generator"
"@semantic-release/npm"
"@semantic-release/github"
  • Additional plugins
yarn add @semantic-release/git @semantic-release/changelog --dev
  1. semantic-release configuration 🔗
  • A .releaserc file, written in YAML or JSON, with optional extensions: .yaml / .yml / .json / .js

  • 📝 config file example

  • edite package.json and add release script

// package.json

{
  // ...
  "scripts": {
    "release": "semantic-release"
  }
  // ...
}
  1. CI configuration 🔗

semantic-release: angular

Author


Robson Natanael 🚀

Linkedin Badge Twitter Badge



Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,094,552
Version (20,667
Changelog (4,376
Release Automation (253
Semantic Release (184
Semantic Versions (88