@wavevision/semantic-release

2.0.2 • Public • Published

Wavevision s.r.o.

Semantic Release

QA Release Commitizen friendly semantic-release npm

Semantic Release setup for Wavevision apps to maintain conventional commits and releases using gitmoji. The package contains bootstrap and configs for:

Installation

yarn add --dev @wavevision/semantic-release

Usage

First, use setup scripts that come with this package.

  • yarn setup-commitizen – setup commitizen config
  • yarn setup-gitflow – setup gitflow-avh branches
  • yarn setup-husky – setup husky hooks for linting your commit messages

Then, create necessary configs in your project root.

release.config.js

This is the main config for semantic-release. Require makeConfig function from @wavevision/semantic-release/config to bootstrap your project config. The function accepts single options parameter which is an object with following shape:

type Options = {
  config: 'gitlab' | 'github'; // needed to setup correct release plugin
  branches: string[]; // list of branches on which releases should happen
  rules?: {
    // map gitmoji to specific release types
    major?: string[] | { exclude?: string[]; include?: string[] };
    minor?: string[] | { exclude?: string[]; include?: string[] };
    patch?: string[] | { exclude?: string[]; include?: string[] };
  };
  templates?: {
    notes?: string; // release notes .hbs template content
    commit?: string; // commit .hbs template content
  };
  git?: {
    enabled: boolean; // enable @semantic-release/git plugin
    assets?: string[]; // relative paths to assets to be commited with a release
  };
  npm?: {
    enabled: boolean; // enable @semantic-release/npm plugin
  };
};

Example

const makeConfig = require('@wavevision/semantic-release/config');
const {
  CONFIG_GITHUB,
} = require('@wavevision/semantic-release/config/constants');

module.exports = makeConfig({
  config: CONFIG_GITHUB,
  branches: ['master'],
  git: { enabled: true, assets: ['package.json'] },
  npm: { enabled: true },
});

This will bootstrap semantic-release for GitHub repository in which releases will happen on master branch. Each new release will change version property inside package.json which will be then committed to the repository. Also, if your package.json does not set private: true, an npm package will be published.

Note: See this FAQ to learn about setting npm published package access.

The gitmoji release rules are by default:

  • major = [:boom:]
  • minor = [:sparkles:]
  • patch = [:bug:, :ambulance:, :lock:]

Templates

The package contains a helper to stringify .hbs templates content from a folder you define. Use it as follows.

const { makeTemplate } = require('@wavevision/semantic-release/config/utils');

const template = makeTemplate('path', 'to', 'templates');
template('notes'); // will return content from path/to/templates/notes.hbs

Constants

As shown in the example @wavevision/semantic-release/config/constants exports set of useful constants to be used with the configuration. See all of them in that module.

commitlint.config.js

Simply use the config from this package.

module.exports = require('@wavevision/semantic-release/commitlint');

Commit CLI

The package also contains bootstrapped commitizen CLI which will help you assemble valid gitmoji commit messages through a simple prompt. Simply run yarn commit and follow the steps.

Note: Longer description, breaking change commit body and list of issues closed are not required.

Package Sidebar

Install

npm i @wavevision/semantic-release

Weekly Downloads

2

Version

2.0.2

License

MIT

Unpacked Size

22 kB

Total Files

22

Last publish

Collaborators

  • vitrozsival