semantic-release-github-notifier
Version:
semantic-release-github plugin that notifies GitHub issues and pull requests of a related package release.
153 lines (94 loc) • 7.34 kB
Markdown
# semantic-release-github-notifier
[](https://gitlab.com/hyper-expanse/semantic-release-github-notifier/commits/master)
[](https://codecov.io/gl/hyper-expanse/semantic-release-github-notifier)
> semantic-release-github plugin to post comments to GitHub issues closed by changes included in a package release.
A comment is posted to each issue that has been closed by a change included in a release of your package.
The message that will be posted says: `Version [THE VERSION RELEASED] has been released.`
## Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [pkg](#pkg)
- [options](#options)
- [dryRun](#dryrun)
- [monoRepo](#monorepo)
- [scmToken](#scmtoken)
- [tagSplitter](#tagsplitter)
- [data](#data)
- [commits](#commits)
- [version](#version)
- [Debugging](#debugging)
- [Node Support Policy](#node-support-policy)
- [Contributing](#contributing)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Installation
To install the `semantic-release-github-notifier` plugin for use in your own package publishing tool please run the following command:
```bash
yarn add [--dev] semantic-release-github-notifier
```
## Usage
`semantic-release-github-notifier`, when called, returns a promise.
It takes one parameter, a configuration object, that contains options that alter its behavior, and data needed to create issue comments.
```javascript
const notifier = require(`semantic-release-github-notifier`);
const config = {};
notifier(config)
.then(() => { /* Comments, if any, have been successfully posted to GitHub. */ })
.catch(() => { /* Do any exception handling here. */ });
```
### Configuration
The configuration parameter required by `semantic-release-github-notifier` must have the following properties:
### pkg
A copy of the to-be-released project's `package.json` file. This must include a `repository` property with the path to the project's git repository on GitHub. Please see npm's documentation on the [format of the repository field](https://docs.npmjs.com/files/package.json#repository<Paste>). The repository field is parsed by [git-pkg-repo](get-pkg-repo), supporting many formats, including HTTPS and SSH.
### options
`options` is an object with the following properties:
* `dryRun`
* `monoRepo`
* `scmToken`
* `tagSplitter`
#### dryRun
**Default:** _false_
Set to `true` to enable dry run. When conducting a dry run all configuration options and commits will be validated, but no comments will be posted to GitHub.
Conducting a dry run serves a different purpose than what's served by the _[Debugging](#debugging)_ section below.
#### monoRepo
**Default:** _false_
Set to `true` to enable mono repository support. Mono repositories are those that contain two or more packages within a single git repository. Mono repositories typically use tags in the form of `package-name@1.0.0` for individual packages, allowing each package to have their own independent set of versions.
#### scmToken
An authentication token with access to the to-be-released project so that comments can be posted to the project's issues.
**Authentication Requirements**
The authentication token must belong to a user or service account that has permission to post comments to the project.
#### tagSplitter
**Default:** _@_
This is an optional property used when the `monoRepo` option is set to `true`. `tagSplitter` allows you to specify a different character that separates the package name from the package's version in the git tag name. For example, to support `package-name#1.0.0`, set `tagSplitter` to `#`.
### data
`data` is an object with the following properties:
#### commits
An array containing each commit's message in the form of a string.
#### version
A string that's a valid [semantic version](https://semver.org/) representing the version that has been released.
## Debugging
To assist users of the `semantic-release-github-notifier` plugin with debugging the behavior of this module we use the [debug](https://www.npmjs.com/package/debug) utility package to print information about the release process to the console. To enable debug message printing, the environment variable `DEBUG`, which is the variable used by the `debug` package, must be set to a value configured by the package containing the debug messages to be printed.
To print debug messages on a unix system set the environment variable `DEBUG` with the name of this package prior to executing a tool that invokes this plugin:
```bash
DEBUG=semantic-release-github-notifier [RELEASE TOOL]
```
On the Windows command line you may do:
```bash
set DEBUG=semantic-release-github-notifier
[RELEASE TOOL]
```
All `semantic-release-github` plugins use `debug` to print information to the console. You can instruct all plugins, and `semantic-release-github`, to print their debug information by using `semantic-release-github*` as the value of the `DEBUG` environment variable.
```bash
DEBUG=semantic-release-github* [RELEASE TOOL]
```
## Node Support Policy
We only support [Long-Term Support](https://github.com/nodejs/LTS) versions of Node.
We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.
It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.
As each Node LTS version reaches its end-of-life we will remove that version from the `node` `engines` property of our package's `package.json` file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.
We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called _current_.
JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our `node` `engines` property. If you encounter issues installing this package, please report the issue to your package manager.
## Contributing
Please read our [contributing](https://gitlab.com/hyper-expanse/semantic-release-github-notifier/blob/master/CONTRIBUTING.md) guide on how you can help improve this project.