UNPKG

8.58 kBMarkdownView Raw
1# conventional-gitlab-releaser
2
3[![build status](https://gitlab.com/hyper-expanse/conventional-gitlab-releaser/badges/master/build.svg)](https://gitlab.com/hyper-expanse/conventional-gitlab-releaser/commits/master)
4[![codecov.io](https://codecov.io/gitlab/hyper-expanse/conventional-gitlab-releaser/coverage.svg?branch=master)](https://codecov.io/gitlab/hyper-expanse/conventional-gitlab-releaser?branch=master)
5[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.gitlab.io/cz-cli/)
6
7> Make a new GitLab release from git metadata.
8
9**Note** You don't have to use the angular commit convention. For the best result of the tool to tokenize you commit and produce flexible output, it's recommended to use a commit convention.
10
11## Quick start
12
13[Set up a token first](#setup-token-for-cli).
14
15```sh
16$ npm install -g conventional-gitlab-releaser
17$ cd my-project
18$ conventional-gitlab-releaser -p angular
19```
20
21The above generates a GitLab Release based on commits since the last semver tag that match the pattern of a "Feature", "Fix", "Performance Improvement" or "Breaking Changes".
22
23If you first time use this tool and want to generate all previous releases, you could do
24
25```sh
26$ conventional-gitlab-releaser -p angular -r 0
27```
28
29This will *not* overwrite the releases you have already made. Read ["Regenerate all the releases"](#regenerate-all-the-releases) section if you want to.
30
31All available command line parameters can be listed using [CLI](#cli) : `conventional-gitlab-releaser --help`.
32
33**Hint:** You can alias your command or add it to your package.json. EG: `"gitlab-release": "conventional-gitlab-releaser -p angular -r 0"`.
34
35## Example output
36
37- https://github.com/conventional-changelog/conventional-github-releaser/releases
38- https://github.com/conventional-changelog/conventional-changelog/releases
39
40### Recommended workflow
41
421. Make changes
432. Commit those changes
443. Make sure GitLab CI turns green
454. Bump version in `package.json`
465. Commit `package.json` files
476. Tag
487. Push
498. `conventionalGitlabReleaser`
50
51You have to have a tag on GitLab to make a release. hence `gitRawCommitsOpts.to` defaults to the latest semver tag.
52
53Please use this [gist](https://gist.github.com/stevemao/280ef22ee861323993a0) to make a release or change it to your needs.
54
55## Why
56
57- Based on [conventional-changelog](https://github.com/ajoslin/conventional-changelog) but GitLab releases are more elegant.
58- Easy fully automate changelog generation. You could still add more points on top of it.
59- Detecting prerelease based on semver, ignoring reverted commits, templating with [handlebars.js](https://github.com/wycats/handlebars.js) and links to references, etc. Open an [issue](../../issues/new) if you want more reasonable features.
60- Intelligently setup defaults but yet fully configurable with presets of [popular projects](https://github.com/ajoslin/conventional-changelog#preset).
61- Everything internally or externally is pluggable.
62- A lot of tests and actively maintained.
63
64### Required GitLab CE/EE Edition
65
66Version [8.2](https://about.gitlab.com/2015/11/22/gitlab-8-2-released/), or higher, of GitLab CE/EE is required for `conventional-gitlab-releaser`.
67
68Core features used:
69* [GitLab release page](http://docs.gitlab.com/ce/workflow/releases.html)
70* [API v3](https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/README.md)
71
72> This only applies to you if you're running your own instance of GitLab. GitLab.com is always the latest version of the GitLab application.
73
74## Programmatic Usage
75
76```sh
77$ npm install --save conventional-gitlab-releaser
78```
79
80```js
81var conventionalGitlabReleaser = require('conventional-gitlab-releaser');
82
83var AUTH = {
84 url: 'https://gitlab.com',,
85 token: '0126af95c0e2d9b0a7c78738c4c00a860b04acc8'
86};
87
88conventionalGitlabReleaser(AUTH, {
89 preset: 'angular'
90}, callback);
91```
92
93## API
94
95### conventionalGitlabReleaser(auth, [changelogOpts, [context, [gitRawCommitsOpts, [parserOpts, [writerOpts]]]]], callback)
96
97#### auth
98
99An authentication object containing the following:
100
101* `token` - A [GitLab Private Token](https://gitlab.com/profile/account) with _Developer_ permissions on the project to be released.
102* `url` - The fully qualified domain name for the GitLab instance (such as `https://gitlab.com`).
103
104For example:
105
106```javascript
107{
108 url: 'https://gitlab.com',
109 token: '0126af95c0e2d9b0a7c78738c4c00a860b04acc8'
110}
111```
112
113#### callback
114
115##### callback(err, responses)
116
117###### responses
118
119Type: `array`
120
121An array of responses returned by `gitlab.projects.repository.addTag` calls.
122
123Please check [conventional-changelog](https://github.com/ajoslin/conventional-changelog#api) for other arguments.
124
125There are some changes:
126
127#### changelogOpts
128
129##### transform
130
131Default: grab the whole tag for the version (including a leading v) and format date.
132
133##### releaseCount
134
135Default: `1`
136
137How many releases of changelog you want to generate. It counts from the latest semver tag. Useful when you forgot to generate any previous releases. Set to `0` to regenerate all.
138
139#### gitRawCommitsOpts
140
141##### from
142
143Default: based on `options.releaseCount`.
144
145##### to
146
147Default: latest semver tag
148
149#### writerOpts
150
151##### includeDetails
152
153It is always `true`.
154
155##### headerPartial
156
157Default: `''`
158
159Default header contains the version and date which are already in the release.
160
161## CLI
162
163```sh
164$ npm install --global conventional-gitlab-releaser
165$ conventional-gitlab-releaser --help # for more details
166```
167
168You can supply your auth token by a flag `-t` or `--token`. You can also set up an environment variable `CONVENTIONAL_GITLAB_RELEASER_TOKEN` to avoid typing your token every time.
169
170Note: If all results error, it will print the error messages to stderr and exit with code `1`.
171
172## Setup token for cli
173
174[Get your token](https://gitlab.com/profile/account) and set your environment variable `CONVENTIONAL_GITLAB_RELEASER_TOKEN` to the token you just retrieved. You can google [How to set environment variable](https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=how%20to%20set%20environment%20variable).
175
176## Related
177
178- [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog-cli) - Generate a changelog from git metadata
179- [conventional-recommended-bump](https://github.com/conventional-changelog/conventional-recommended-bump) - Get a recommended version bump based on conventional commits
180- [conventional-commits-detector](https://github.com/conventional-changelog/conventional-commits-detector) - Detect what commit message convention your repository is using
181
182## License
183
184MIT © [Steve Mao](https://github.com/stevemao)
185
186## Node Support Policy
187
188We only support [Long-Term Support](https://github.com/nodejs/LTS) versions of Node.
189
190We 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.
191
192It'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.
193
194As 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.
195
196We 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_.
197
198JavaScript 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.
199
200## Contributing
201
202Please read our [contributing guide](https://gitlab.com/hyper-expanse/conventional-gitlab-releaser/blob/master/CONTRIBUTING.md) to see how you may contribute to this project.