1 | # grunt-bump
|
2 |
|
3 | > Bump package version, create tag, commit, push ...
|
4 |
|
5 | ## Getting Started
|
6 | This plugin requires Grunt.
|
7 |
|
8 | If 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
|
11 | npm install grunt-bump --save-dev
|
12 | ```
|
13 |
|
14 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
|
15 |
|
16 | ```js
|
17 | grunt.loadNpmTasks('grunt-bump');
|
18 | ```
|
19 |
|
20 | ### Configuration
|
21 | In 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
|
24 | grunt.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
|
47 | Type: `Array`
|
48 | Default value: `['package.json']`
|
49 |
|
50 | Maybe 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
|
53 | Type: `Array`
|
54 | Default value: `[]`
|
55 |
|
56 | Sometimes 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
|
59 | bump: {
|
60 | files: ['package.json', 'component.json'],
|
61 | updateConfigs: ['pkg', 'component']
|
62 | }
|
63 | ```
|
64 |
|
65 | #### options.commit
|
66 | Type: `Boolean`
|
67 | Default value: `true`
|
68 |
|
69 | Should the changes be committed? False if you want to do additional things.
|
70 |
|
71 | #### options.commitMessage
|
72 | Type: `String`
|
73 | Default value: `Release v%VERSION%`
|
74 |
|
75 | If so, what is the commit message ? You can use `%VERSION%` which will get replaced with the new version.
|
76 |
|
77 | #### options.commitFiles
|
78 | Type: `Array`
|
79 | Default value: `['package.json']`
|
80 |
|
81 | An array of files that you want to commit. You can use `['-a']` to commit all files.
|
82 |
|
83 | #### options.createTag
|
84 | Type: `Boolean`
|
85 | Default value: `true`
|
86 |
|
87 | Create a Git tag?
|
88 |
|
89 | #### options.tagName
|
90 | Type: `String`
|
91 | Default value: `v%VERSION%`
|
92 |
|
93 | If `options.createTag` is set to true, then this is the name of that tag (`%VERSION%` placeholder is available).
|
94 |
|
95 | #### options.tagMessage
|
96 | Type: `String`
|
97 | Default value: `Version %VERSION%`
|
98 |
|
99 | If `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
|
102 | Type: `Boolean`
|
103 | Default value: `true`
|
104 |
|
105 | Push the changes to a remote repo?
|
106 |
|
107 | #### options.pushTo
|
108 | Type: `String`
|
109 | Default value: `upstream`
|
110 |
|
111 | If `options.push` is set to true, which remote repo should it go to?
|
112 |
|
113 | #### options.gitDescribeOptions
|
114 | Type: `String`
|
115 | Default value: `--tags --always --abbrev=1 --dirty=-d`
|
116 |
|
117 | Options to use with `$ git describe`
|
118 |
|
119 | #### options.globalReplace
|
120 | Type: `Boolean`
|
121 | Default value: `false`
|
122 |
|
123 | Replace all occurrences of the version in the file. When set to `false`, only the first occurrence will be replaced.
|
124 |
|
125 | ### Usage Examples
|
126 |
|
127 | Let'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 |
|
173 | If 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 |
|
183 | Sometimes 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
|
192 | See 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
|
195 | Copyright (c) 2014 Vojta Jína. Licensed under the MIT license.
|