diff --git a/tasks/grunt-release.js b/tasks/grunt-release.js index 90974b3..206bfb2 100644 --- a/tasks/grunt-release.js +++ b/tasks/grunt-release.js @@ -32,6 +32,7 @@ module.exports = function(grunt){ version: config.newVersion } }; + var tagType = grunt.template.process(grunt.config.getRaw('release.options.tagType') || 'annotated', templateOptions); var tagName = grunt.template.process(grunt.config.getRaw('release.options.tagName') || '<%= version %>', templateOptions); var commitMessage = grunt.template.process(grunt.config.getRaw('release.options.commitMessage') || 'release <%= version %>', templateOptions); var tagMessage = grunt.template.process(grunt.config.getRaw('release.options.tagMessage') || 'version <%= version %>', templateOptions); @@ -73,6 +74,20 @@ module.exports = function(grunt){ return tag; } + function getTagTypeArg(){ + var type = grunt.option('tagType') || options.tagType; + switch(type) { + case 'annotated': + return arg = '--annotate '; + case 'lightweight': + return ''; + case 'signed': + return '--sign '; + default: + throw grunt.util.error('Unrecognized tagType: "' + type + '".'); + } + } + function ifEnabled(option, fn){ if (options[option]) return fn; } @@ -109,7 +124,7 @@ module.exports = function(grunt){ } function tag(){ - return run('git tag ' + tagName + ' -m "'+ tagMessage +'"', 'created new git tag: ' + tagName); + return run('git tag ' + getTagTypeArg() + tagName + ' -m "'+ tagMessage +'"', 'created new ' + tagType + ' git tag: ' + tagName); } function push(){