UNPKG

5.32 kBMarkdownView Raw
1# grunt-bump
2
3> Bump package version, create tag, commit, push ...
4
5## Getting Started
6This plugin requires Grunt.
7
8If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
9
10```shell
11npm install grunt-bump --save-dev
12```
13
14Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
15
16```js
17grunt.loadNpmTasks('grunt-bump');
18```
19
20### Configuration
21In your project's Gruntfile, add a section named `bump` to the data object passed into `grunt.initConfig()`. The options (and defaults) are:
22
23```js
24grunt.initConfig({
25 bump: {
26 options: {
27 files: ['package.json'],
28 updateConfigs: [],
29 commit: true,
30 commitMessage: 'Release v%VERSION%',
31 commitFiles: ['package.json'],
32 createTag: true,
33 tagName: 'v%VERSION%',
34 tagMessage: 'Version %VERSION%',
35 push: true,
36 pushTo: 'upstream',
37 gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
38 globalReplace: false
39 }
40 },
41})
42```
43
44### Options
45
46#### options.files
47Type: `Array`
48Default value: `['package.json']`
49
50Maybe you wanna bump 'component.json' instead? Or maybe both: `['package.json', 'component.json']`? Can be either a list of files to bump (an array of files) or a grunt glob (e.g., `['*.json']`).
51
52#### options.updateConfigs
53Type: `Array`
54Default value: `[]`
55
56Sometimes you load the content of `package.json` into a grunt config. This will update the config property, so that even tasks running in the same grunt process see the updated value.
57
58```js
59bump: {
60 files: ['package.json', 'component.json'],
61 updateConfigs: ['pkg', 'component']
62}
63```
64
65#### options.commit
66Type: `Boolean`
67Default value: `true`
68
69Should the changes be committed? False if you want to do additional things.
70
71#### options.commitMessage
72Type: `String`
73Default value: `Release v%VERSION%`
74
75If so, what is the commit message ? You can use `%VERSION%` which will get replaced with the new version.
76
77#### options.commitFiles
78Type: `Array`
79Default value: `['package.json']`
80
81An array of files that you want to commit. You can use `['-a']` to commit all files.
82
83#### options.createTag
84Type: `Boolean`
85Default value: `true`
86
87Create a Git tag?
88
89#### options.tagName
90Type: `String`
91Default value: `v%VERSION%`
92
93If `options.createTag` is set to true, then this is the name of that tag (`%VERSION%` placeholder is available).
94
95#### options.tagMessage
96Type: `String`
97Default value: `Version %VERSION%`
98
99If `options.createTag` is set to true, then yep, you guessed right, it's the message of that tag - description (`%VERSION%` placeholder is available).
100
101#### options.push
102Type: `Boolean`
103Default value: `true`
104
105Push the changes to a remote repo?
106
107#### options.pushTo
108Type: `String`
109Default value: `upstream`
110
111If `options.push` is set to true, which remote repo should it go to?
112
113#### options.gitDescribeOptions
114Type: `String`
115Default value: `--tags --always --abbrev=1 --dirty=-d`
116
117Options to use with `$ git describe`
118
119#### options.globalReplace
120Type: `Boolean`
121Default value: `false`
122
123Replace all occurrences of the version in the file. When set to `false`, only the first occurrence will be replaced.
124
125### Usage Examples
126
127Let's say current version is `0.0.1`.
128
129```bash
130$ grunt bump
131>> Version bumped to 0.0.2
132>> Committed as "Release v0.0.2"
133>> Tagged as "v0.0.2"
134>> Pushed to origin
135
136$ grunt bump:patch
137>> Version bumped to 0.0.3
138>> Committed as "Release v0.0.3"
139>> Tagged as "v0.0.3"
140>> Pushed to origin
141
142$ grunt bump:minor
143>> Version bumped to 0.1.0
144>> Committed as "Release v0.1.0"
145>> Tagged as "v0.1.0"
146>> Pushed to origin
147
148$ grunt bump:major
149>> Version bumped to 1.0.0
150>> Committed as "Release v1.0.0"
151>> Tagged as "v1.0.0"
152>> Pushed to origin
153
154$ grunt bump:prerelease
155>> Version bumped to 1.0.0-1
156>> Committed as "Release v1.0.0-1"
157>> Tagged as "v1.0.0-1"
158>> Pushed to origin
159
160$ grunt bump:patch
161>> Version bumped to 1.0.1
162>> Committed as "Release v1.0.1"
163>> Tagged as "v1.0.1"
164>> Pushed to origin
165
166$ grunt bump:git
167>> Version bumped to 1.0.1-ge96c
168>> Committed as "Release v1.0.1-ge96c"
169>> Tagged as "v1.0.1-ge96c"
170>> Pushed to origin
171````
172
173If you want to jump to an exact version, you can use the ```setversion``` tag in the command line.
174
175```bash
176$ grunt bump --setversion=2.0.1
177>> Version bumped to 2.0.1
178>> Committed as "Release v2.0.1"
179>> Tagged as "v2.0.1"
180>> Pushed to origin
181```
182
183Sometimes you want to run another task between bumping the version and committing, for instance generate changelog. You can use `bump-only` and `bump-commit` to achieve that:
184
185```bash
186$ grunt bump-only:minor
187$ grunt changelog
188$ grunt bump-commit
189```
190
191## Contributing
192See the [contributing guide](https://github.com/vojtajina/grunt-bump/blob/master/CONTRIBUTING.md) for more information. In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/): `grunt test jshint`.
193
194## License
195Copyright (c) 2014 Vojta Jína. Licensed under the MIT license.