semantic-release-gitlab-releaser
Version:
semantic-release-gitlab plugin that creates a git tag and a GitLab release entry.
147 lines (90 loc) • 7.67 kB
Markdown
# semantic-release-gitlab-releaser
> semantic-release-gitlab plugin that creates a git tag and a GitLab release entry.
Creates a new [GitLab release](http://docs.gitlab.com/ce/workflow/releases.html) matching the version of the package being released. When a release is created on GitLab, a git tag is created along with it. Therefore, it's possible to fetch tags from the GitLab repository for every release created.
The release created on GitLab 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-gitlab-releaser` plugin for use in your own package publishing tool please run the following command:
```bash
yarn add [--dev] semantic-release-gitlab-releaser
```
## Usage
`semantic-release-gitlab-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-gitlab-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-gitlab-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 GitLab. 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 GitLab.
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 GitLab so that a GitLab release can be created.
**Authentication Requirements**
A GitLab [Personal Access Token](https://gitlab.com/profile/personal_access_tokens) with the following scope set:
* `api`
The personal access token must be setup on an account for a member of the project you're wanting to automatically release so that this plugin may use the _Add tags_ action, as documented on the [GitLab Permissions](http://docs.gitlab.com/ce/user/permissions.html) site.
##### insecureApi
**Default:** _undefined_
By default all API calls to GitLab 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 GitLab over HTTP, but this option is supported for those cases where configuring SSL for GitLab is not feasible.
## Debugging
To assist users of the `semantic-release-gitlab-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-gitlab-releaser [RELEASE TOOL]
```
On the Windows command line you may do:
```bash
set DEBUG=semantic-release-gitlab-releaser
[RELEASE TOOL]
```
All `semantic-release-gitlab` plugins use `debug` to print information to the console. You can instruct all plugins, and `semantic-release-gitlab`, to print their debugging information by using `semantic-release-gitlab*` as the value of the `DEBUG` environment variable.
```bash
DEBUG=semantic-release-gitlab* [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-gitlab-releaser/blob/master/CONTRIBUTING.md) guide on how you can help improve this project.