@maggioli-rd/sr-codeowners-plugin
Version:
Maggioli Semantic Release Plugin: Codeowners
76 lines (60 loc) • 3.54 kB
Markdown
# @maggioli-rd/sr-codeowners-plugin
[](https://www.npmjs.com/package/@maggioli-rd/sr-codeowners-plugin)
| Step | Description |
|--------------------|--------------------------------------------------------------------------|
| `verifyConditions` | Execute a shell command to verify if the CODEOWNERS file can be created. |
| `verifyRelease` | Execute a shell command to create the CODEOWNERS file. |
## Configuration
| Options | Description | Default |
|--------------------|-------------------------------------------------------------------------------------------------------------|----------------------------|
| `excludeRegex` | RegEx to exclude authors when creating the CODEOWNERS file. | "" |
| `header` | String inserted in the first line of the CODEOWNERS file as header. | Autogen comment (see code) |
| `codeownersPath` | Path where to create the CODEOWNERS file. | .gitlab/CODEOWNERS |
| `limit` | Number of authors obtained from the ranking of authors with the most commits. | 3 |
| `leaderboard` | Generates the ranking of authors with the most commits and includes it as a comment in the CODEOWNERS file. | true |
## Install
```bash
$ npm install @maggioli-rd/sr-codeowners-plugin -D
```
## Usage
The plugin can be configured in the [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration):
```json
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/git", {
"assets": [
"CHANGELOG.md",
"pubspec.yaml",
"CODEOWNERS"
],
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
}],
["@maggioli-rd/sr-codeowners-plugin", {
"excludeRegex": "semantic-release-bot",
"codeownersPath": "CODEOWNERS",
"limit": 2
}]
]
}
```
### Shareable-Configuration Extension Example (release.config.js)
```javascript
var config = require('@maggioli-rd/semantic-release-flutter');
var gitPluginIndex = config.plugins.findIndex((plugin) => plugin.includes("@semantic-release/git"))
config.plugins[gitPluginIndex][1]["assets"].push(".gitlab/CODEOWNERS")
config.plugins.push(
["@maggioli-rd/sr-codeowners-plugin", {
"excludeRegex": "RenovateBot|semantic-release-bot",
"limit": 5,
"header": "My personal header"
}]
)
module.exports = config
```
## Resources
* [https://semantic-release.gitbook.io/semantic-release/](https://semantic-release.gitbook.io/semantic-release/)
* [https://semantic-release.gitbook.io/semantic-release/developer-guide/plugin](https://semantic-release.gitbook.io/semantic-release/developer-guide/plugin)
* [https://docs.gitlab.com/ee/user/project/codeowners/](https://docs.gitlab.com/ee/user/project/codeowners/)
* [https://git-scm.com/docs/git-shortlog](https://git-scm.com/docs/git-shortlog)