1. grunt 配置
1.1. grunt
全局安装
grunt-cli
:npm install -g grunt-cli
安装
grunt
:npm install –save-dev grunt
配置
gruntfile.js
:module.exports = function (grunt) { // Project configuration grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), // Grunt-plugins config ... }); // Load tasks [ 'grunt-bump', 'grunt-conventional-changelog' ].forEach(function (task) { grunt.loadNpmTasks(task); }); // Regist tasks grunt.registerTask( 'release', 'Build, bump and publish to Git.', function (type) { grunt.task.run([ 'bump:' +(type || 'patch') + ':bump-only', 'conventionalChangelog', 'bump-commit' ]); } ); };
1.2. grunt-bump
安装
grunt-bump
npm install --save-dev grunt-bump
配置
gruntfile.js
:grunt.initConfig({ bump: { options: { updateConfigs: ['pkg'], commitFiles: [ 'package.json', 'CHANGELOG.md' ], commitMessage: 'chore: release v%VERSION%', prereleaseName: 'rc', pushTo: 'upstream', } }, });
参考
1.3. grunt-conventional-changelog
安装
grunt-conventional-changelog
:npm install --save-dev grunt-conventional-changelog
配置
gruntfile.js
:grunt.initConfig({ conventionalChangelog: { release: { options: { changelogOpts: { preset: 'angular' } }, src: 'CHANGELOG.md' } } });
命令
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
参考
1.4. 执行
grunt release
euqalsgrunt release:patch
grunt release:minor
grunt release:major
grunt release:git
git head 版本后缀grunt release:prepatch
grunt release:preminor
grunt release:premajor
grunt release:prerelease
rc 版本升级