From a9b7ee6b83ac173092443fd1a662255cfc384fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bachelier?= Date: Thu, 6 Feb 2014 00:16:17 +0100 Subject: [PATCH] quite simple solution to avoid callback --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++ tasks/grunt-release.js | 3 +-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a90424..2865011 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,58 @@ The following are all the release steps, you can disable any you need to: } ``` +### How to run a task between bump and publish. + +The idea here is simply to complete the process of a deployment, which is: + * bump + * do something + * publish + +``` + grunt.initConfig({ + // some configuration here .... + + // then the release configuration + release: { + bump: { + options: { + bump: true, + add: false, + commit: false, + tag: false, + push: false, + pushTags: false, + npm : false + } + }, + publish: { + options: { + bump: false, + commitMessage: 'bump version <%= version %>', + github: { + // your conf + } + } + } + } + }); + + // register a task which enable the following process: + // * bump package.json (or any other json file) + // * do something like create a dist version + // * tag, push, publish + // + // run this task with --type option + // $ grunt dist --type minor + // + grunt.registerTask('deploy', function () { + var version = grunt.option('type') || 'patch'; // default to patch + grunt.task.run('release:bump:' + version); + grunt.task.run(/* your task(s) */); + grunt.task.run('release:publish'); + }); +``` + ### Notes on Github Releases: 1. Yes, you have to use environment variables. I would be a terrible person if I let you check in your username and password into your source code. 2. The [Github Releases API](http://developer.github.com/v3/repos/releases/) is still unstable and may change in the next couple months or so. diff --git a/tasks/grunt-release.js b/tasks/grunt-release.js index 1c02929..5dac3fe 100644 --- a/tasks/grunt-release.js +++ b/tasks/grunt-release.js @@ -10,8 +10,7 @@ var shell = require('shelljs'); var semver = require('semver'); module.exports = function(grunt){ - grunt.registerTask('release', 'bump version, git tag, git push, npm publish', function(type){ - + grunt.registerMultiTask('release', 'bump version, git tag, git push, npm publish', function(type){ //defaults var options = this.options({ bump: true,