Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
16 KiB

  1. # **commit-analyzer**
  2. [**semantic-release**](https://github.com/semantic-release/semantic-release) plugin to analyze commits with [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)
  3. [![Travis](https://img.shields.io/travis/semantic-release/commit-analyzer.svg)](https://travis-ci.org/semantic-release/commit-analyzer)
  4. [![Codecov](https://img.shields.io/codecov/c/github/semantic-release/commit-analyzer.svg)](https://codecov.io/gh/semantic-release/commit-analyzer)
  5. [![Greenkeeper badge](https://badges.greenkeeper.io/semantic-release/commit-analyzer.svg)](https://greenkeeper.io/)
  6. [![npm latest version](https://img.shields.io/npm/v/@semantic-release/commit-analyzer/latest.svg)](https://www.npmjs.com/package/@semantic-release/commit-analyzer)
  7. [![npm next version](https://img.shields.io/npm/v/@semantic-release/commit-analyzer/next.svg)](https://www.npmjs.com/package/@semantic-release/commit-analyzer)
  8. | Step | Description |
  9. |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
  10. | `analyzeCommits` | Determine the type of release by analyzing commits with [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog). |
  11. ## Install
  12. ```bash
  13. $ npm install @semantic-release/commit-analyzer -D
  14. ```
  15. ## Usage
  16. The plugin can be configured in the [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/caribou/docs/usage/configuration.md#configuration):
  17. ```json
  18. {
  19. "plugins": [
  20. ["@semantic-release/commit-analyzer", {
  21. "preset": "angular",
  22. "releaseRules": [
  23. {"type": "docs", "scope":"README", "release": "patch"},
  24. {"type": "refactor", "release": "patch"},
  25. {"type": "style", "release": "patch"}
  26. ],
  27. "parserOpts": {
  28. "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
  29. }
  30. }],
  31. "@semantic-release/release-notes-generator"
  32. ]
  33. }
  34. ```
  35. With this example:
  36. - the commits that contains `BREAKING CHANGE`, `BREAKING CHANGES` or `BREAKING` in their body will be considered breaking changes (by default the [angular preset](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/index.js#L14) checks only for `BREAKING CHANGE` and `BREAKING CHANGES`)
  37. - the commits with a 'docs' `type`, a 'README' `scope` will be associated with a `patch` release
  38. - the commits with a 'refactor' `type` will be associated with a `patch` release
  39. - the commits with a 'style' `type` will be associated with a `patch` release
  40. ## Configuration
  41. ### Options
  42. | Option | Description | Default |
  43. |----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
  44. | `preset` | [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset (possible values: [`angular`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular), [`atom`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-atom), [`codemirror`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-codemirror), [`ember`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-ember), [`eslint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint), [`express`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-express), [`jquery`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jquery), [`jshint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jshint)). | [`angular`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular) |
  45. | `config` | NPM package name of a custom [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset. | - |
  46. | `parserOpts` | Additional [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#conventionalcommitsparseroptions) options that will extends the ones loaded by `preset` or `config`. This is convenient to use a [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset with some customizations without having to create a new module. | - |
  47. | `releaseRules` | An external module, a path to a module or an `Array` of rules. See [`releaseRules`](#releaserules). | See [`releaseRules`](#releaserules) |
  48. **Notes**: in order to use a `preset` it must be installed (for example to use the [eslint preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint) you must install it with `npm install conventional-changelog-eslint -D`)
  49. **Note**: `config` will be overwritten by the values of `preset`. You should use either `preset` or `config`, but not both.
  50. **Note**: Individual properties of `parserOpts` will override ones loaded with an explicitly set `preset` or `config`. If `preset` or `config` are not set, only the properties set in `parserOpts` will be used.
  51. #### releaseRules
  52. Release rules are used when deciding if the commits since the last release warrant a new release. If you define custom release rules the default rules will be used if nothing matched. Those rules will be matched against the commit objects resulting of [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser) parsing.
  53. Release rules are used when deciding if the commits since the last release warrant a new release. If you define custom release rules the [default rules](lib/default-release-rules.js) will be used if nothing matched.
  54. ##### Rules definition
  55. This is an `Array` of rule objects. A rule object has a `release` property and 1 or more criteria.
  56. ```json
  57. {
  58. "plugins": [
  59. ["semantic-release/commit-analyzer", {
  60. "preset": "angular",
  61. "releaseRules": [
  62. {"type": "docs", "scope": "README", "release": "patch"},
  63. {"type": "refactor", "scope": "/core-.*/", "release": "minor"},
  64. {"type": "refactor", "release": "patch"}
  65. ]
  66. }],
  67. "@semantic-release/release-notes-generator"
  68. ]
  69. }
  70. ```
  71. ##### Rules matching
  72. Each commit will be compared with each rule and when it matches, the commit will be associated with the release type in the rule's `release` property. If a commit match multiple rules, the highest release type (`major` > `minor` > `patch`) is associated with the commit.
  73. See [release types](lib/default-release-types.js) for the release types hierarchy.
  74. With the previous example:
  75. - Commits with `type` 'docs' and `scope` 'README' will be associated with a `patch` release.
  76. - Commits with `type` 'refactor' and `scope` starting with 'core-' (i.e. 'core-ui', 'core-rules', ...) will be associated with a `minor` release.
  77. - Other commits with `type` 'refactor' (without `scope` or with a `scope` not matching the regexp `/core-.*/`) will be associated with a `patch` release.
  78. ##### Default rules matching
  79. If a commit doesn't match any rule in `releaseRules` it will be evaluated against the [default release rules](lib/default-release-rules.js).
  80. With the previous example:
  81. - Commits with a breaking change will be associated with a `major` release.
  82. - Commits with `type` 'feat' will be associated with a `minor` release.
  83. - Commits with `type` 'fix' will be associated with a `patch` release.
  84. - Commits with `type` 'perf' will be associated with a `patch` release.
  85. ##### No rules matching
  86. If a commit doesn't match any rules in `releaseRules` or in [default release rules](lib/default-release-rules.js) then no release type will be associated with the commit.
  87. With the previous example:
  88. - Commits with `type` 'style' will not be associated with a release type.
  89. - Commits with `type` 'test' will not be associated with a release type.
  90. - Commits with `type` 'chore' will not be associated with a release type.
  91. ##### Multiple commits
  92. If there is multiple commits that match one or more rules, the one with the highest release type will determine the global release type.
  93. Considering the following commits:
  94. - `docs(README): Add more details to the API docs`
  95. - `feat(API): Add a new method to the public API`
  96. With the previous example the release type determined by the plugin will be `minor`.
  97. ##### Specific commit properties
  98. The properties to set in the rules will depends on the commit style chosen. For example [conventional-changelog-angular](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/index.js#L9-L13) use the commit properties `type`, `scope` and `subject` but [conventional-changelog-eslint](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-eslint/index.js#L9-L12) uses `tag` and `message`.
  99. For example with `eslint` preset:
  100. ```json
  101. {
  102. "plugins": [
  103. ["semantic-release/commit-analyzer", {
  104. "preset": "eslint",
  105. "releaseRules": [
  106. {"tag": "Docs", "message":"/README/", "release": "patch"},
  107. {"type": "New", "release": "patch"}
  108. ]
  109. }],
  110. "@semantic-release/release-notes-generator"
  111. ]
  112. }
  113. ```
  114. With this configuration:
  115. - Commits with `tag` 'Docs', that contains 'README' in their header message will be associated with a `patch` release.
  116. - Commits with `tag` 'New' will be associated with a `patch` release.
  117. - Commits with `tag` 'Breaking' will be associated with a `major` release (per [default release rules](lib/default-release-rules.js)).
  118. - Commits with `tag` 'Fix' will be associated with a `patch` release (per [default release rules](lib/default-release-rules.js)).
  119. - Commits with `tag` 'Update' will be associated with a `minor` release (per [default release rules](lib/default-release-rules.js)).
  120. - Commits with `tag` 'New' will be associated with a `minor` release (per [default release rules](lib/default-release-rules.js)).
  121. - All other commits will not be associated with a release type.
  122. ##### External package / file
  123. `releaseRules` can also reference a module, either by it's `npm` name or path:
  124. ```json
  125. {
  126. "plugins": [
  127. ["semantic-release/commit-analyzer", {
  128. "preset": "angular",
  129. "releaseRules": "./config/release-rules.js"
  130. }],
  131. "@semantic-release/release-notes-generator"
  132. ]
  133. }
  134. ```
  135. ```js
  136. // File: config/release-rules.js
  137. module.exports = [
  138. {type: 'docs', scope: 'README', release: 'patch'},
  139. {type: 'refactor', scope: /core-.*/, release: 'minor'},
  140. {type: 'refactor', release: 'patch'},
  141. ];
  142. ```