1 | # grunt-bump
|
2 |
|
3 | **Bump package version, create tag, commit, push...**
|
4 |
|
5 | ## Installation
|
6 |
|
7 | Install npm package, next to your project's `Gruntfile.js` file:
|
8 |
|
9 | npm install grunt-bump --save-dev
|
10 |
|
11 | Add this line to your project's `Gruntfile.js`:
|
12 |
|
13 | grunt.loadNpmTasks('grunt-bump');
|
14 |
|
15 |
|
16 | ## Usage
|
17 |
|
18 | Let's say current version is `0.0.1`.
|
19 |
|
20 | ````
|
21 | $ grunt bump
|
22 | >> Version bumped to 0.0.2
|
23 | >> Committed as "Release v0.0.2"
|
24 | >> Tagged as "v0.0.2"
|
25 | >> Pushed to origin
|
26 |
|
27 | $ grunt bump:patch
|
28 | >> Version bumped to 0.0.3
|
29 | >> Committed as "Release v0.0.3"
|
30 | >> Tagged as "v0.0.3"
|
31 | >> Pushed to origin
|
32 |
|
33 | $ grunt bump:minor
|
34 | >> Version bumped to 0.1.0
|
35 | >> Committed as "Release v0.1.0"
|
36 | >> Tagged as "v0.1.0"
|
37 | >> Pushed to origin
|
38 |
|
39 | $ grunt bump:major
|
40 | >> Version bumped to 1.0.0
|
41 | >> Committed as "Release v1.0.0"
|
42 | >> Tagged as "v1.0.0"
|
43 | >> Pushed to origin
|
44 |
|
45 | $ grunt bump:build
|
46 | >> Version bumped to 1.0.0-1
|
47 | >> Committed as "Release v1.0.0-1"
|
48 | >> Tagged as "v1.0.0-1"
|
49 | >> Pushed to origin
|
50 |
|
51 | $ grunt bump:git
|
52 | >> Version bumped to 1.0.0-1-ge96c
|
53 | >> Committed as "Release v1.0.0-1-ge96c"
|
54 | >> Tagged as "v1.0.0-1-ge96c"
|
55 | >> Pushed to origin
|
56 | ````
|
57 |
|
58 | If you want to jump to an exact version, you can use the ```setversion``` tag in the command line.
|
59 |
|
60 | ```
|
61 | $ grunt bump --setversion=2.0.1
|
62 | >> Version bumped to 2.0.1
|
63 | >> Committed as "Release v2.0.1"
|
64 | >> Tagged as "v2.0.1"
|
65 | >> Pushed to origin
|
66 | ```
|
67 |
|
68 | Sometimes you want to run another task between bumping the version and commiting, for instance generate changelog. You can use `bump-only` and `bump-commit` to achieve that:
|
69 |
|
70 | ```bash
|
71 | $ grunt bump-only:minor
|
72 | $ grunt changelog
|
73 | $ grunt bump-commit
|
74 | ```
|
75 |
|
76 | ## Configuration
|
77 |
|
78 | This shows all the available config options with their default values.
|
79 |
|
80 | ```js
|
81 | bump: {
|
82 | options: {
|
83 | files: ['package.json'],
|
84 | updateConfigs: [],
|
85 | commit: true,
|
86 | commitMessage: 'Release v%VERSION%',
|
87 | commitFiles: ['package.json'], // '-a' for all files
|
88 | createTag: true,
|
89 | tagName: 'v%VERSION%',
|
90 | tagMessage: 'Version %VERSION%',
|
91 | push: true,
|
92 | pushTo: 'upstream',
|
93 | gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
|
94 | }
|
95 | }
|
96 | ```
|
97 |
|
98 | ### files
|
99 | List of files to bump. Maybe you wanna bump 'component.json' as well ?
|
100 |
|
101 | ### updateConfigs
|
102 | 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.
|
103 |
|
104 | ```js
|
105 | bump: {
|
106 | files: ['package.json', 'component.json'],
|
107 | updateConfigs: ['pkg', 'component']
|
108 | }
|
109 | ```
|
110 |
|
111 | ### commit
|
112 | Do you wanna commit the changes ?
|
113 |
|
114 | ### commitMessage
|
115 | If so, what is the commit message ? You can use `%VERSION%` which will get replaced with the new version.
|
116 |
|
117 | ### commitFiles
|
118 | An array of files that you wanna commit. You can use `['-a']` to commit all files.
|
119 |
|
120 | ### createTag
|
121 | Do you wanna create a tag ?
|
122 |
|
123 | ### tagName
|
124 | If so, this is the name of that tag (`%VERSION%` placeholder is available).
|
125 |
|
126 | ### tagMessage
|
127 | Yep, you guessed right, it's the message of that tag - description (`%VERSION%` placeholder is available).
|
128 |
|
129 | ### push
|
130 | Do you wanna push all these changes ?
|
131 |
|
132 | ### pushTo
|
133 | If so, which remote branch would you like to push to ?
|