# semantic-release-github-releaser

> semantic-release-github plugin that creates a git tag and a GitHub release entry.

Creates a new [GitHub release](https://help.github.com/articles/about-releases/) matching the version of the package being released. When a release is created on GitHub, a git tag is created along with it. Therefore, it's possible to fetch tags from the GitHub repository for every release created.

The release created on GitHub includes a changelog of all changes introduced in the release. The changelog is created using [conventional-changelog](https://www.npmjs.com/package/conventional-changelog), and the format of the changelog is based on the _preset_ value passed to the plugin.

## 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)
      - [debug](#debug)
      - [preset](#preset)
      - [scmToken](#scmtoken)
      - [insecureApi](#insecureapi)
- [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-releaser` plugin for use in your own package publishing tool please run the following command:

```bash
yarn add [--dev] semantic-release-github-releaser
```

## Usage

`semantic-release-github-releaser`, when called, returns a promise.

It takes one parameter, a configuration object, that contains options that alter its behavior, and data needed to generate the changelog.

```javascript
const releaser = require(`semantic-release-github-releaser`);

const config = {};

releaser(config)
  .then(() => { /* Return value `true` for successful release, `false` for no release. */ })
  .catch(() => { /* Do any exception handling here. */ });
```

### Configuration

The `config` object passed to `semantic-release-github-releaser`, as shown in the example above, must have the following properties:

* `pkg`
* `options`

#### 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:

* `debug`
* `preset`
* `scmToken`
* `insecureApi`

##### debug
**Default:** _false_

Set to `true` to enable debug mode. In debug mode all input will be validated, but a release will not be published to GitHub.

This serves a different purpose than the _[Debugging](#debugging)_ section; which simply prints debug messages to the console.

##### preset
**Default:** _angular_

Set to the preferred commit message and changelog format. Once such preset value could be `angular`, which uses the rules codified in [conventional-changelog-angular](https://www.npmjs.com/package/conventional-changelog-angular). The provided preset will be used for extracting information from each commit message based on the format rules established by the preset. Furthermore, the format of the generated chagelog will be based on a template provided by the same preset.

At this time you cannot parse commit messages using one preset, and generate a changelog using the format of another preset.

##### scmToken

An authentication token with access to the to-be-released project on GitHub so that a GitHub release can be created.

**Authentication Requirements**

The account associated with the authentication token must have Write permissions on the project so that this plugin may push tags to the repo, as documented on the [GitHub Permissions](https://help.github.com/articles/repository-permission-levels-for-an-organization/) site.

##### insecureApi
**Default:** _undefined_

By default all API calls to GitHub are made over HTTPS. If, for some reason, that's impossible, those API calls can be made over HTTP instead.

To use HTTP set `insecureApi` to `true`.

> We strongly advise against communicating with GitHub over HTTP, but this option is supported for those cases where configuring SSL for GitHub is not feasible.

## Debugging

To assist users of the `semantic-release-github-releaser` 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-releaser [RELEASE TOOL]
```

On the Windows command line you may do:

```bash
set DEBUG=semantic-release-github-releaser
[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 debugging 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/open-source/semantic-release-github-releaser/blob/master/CONTRIBUTING.md) guide on how you can help improve this project.
