           return
 
         (done) ->
+          # create temp branch
           exec('git', ['checkout', 'head'], done)
           return
 
         (done) ->
-          exec('git', ['commit', '-m', "Version #{cfgNpm.version} for distribution"], done)
+          # Bump version
+          exec('npm', ['version', options.version, '-m', options.message], done)
           return
 
         (done) ->
-          exec('git', ['tag', '-a', "v#{cfgNpm.version}", '-m', "Add tag #{cfgNpm.version}"], done)
-          return
-
-        (done) ->
-          exec('npm', ['publish'], (err, done) ->
+          # Publish to npm
+          exec('npm', ['publish'], (err) ->
             if err?
               console.error(err)
               console.error('RESETTING')
-              exec('git', ['reset'], () -> done(err))
+              async.series([
+                (cb) ->
+                  exec('git', ['checkout', 'master'], cb)
+                  return
+              ], () -> done(err))
             else
               done(err)
+
+            return
           )
           return
 
         (done) ->
+          # Revert to master branch
           exec('git', ['checkout', 'master'], done)
           return
 
         (done) ->
+          # push changes
           exec('git', ['push', 'origin', '--tags'], done)
           return
 


module.exports = util.fnOption(
  {
    output: {}
    extras: [
      'bower.json'
    ]
  }
  (options) ->
    options.output = util.mergeOptions(config.output, options.output)

    exec = (cmd, args, options, cbDone, cbError) ->

          return

        (done) ->
          # Add extras
          if options.extras.length != 0
            exec('git', ['add', '-f'].concat(options.extras), done)
          else
            done()
          return

        (done) ->
          # Add dist folder
          if options.output.dist?
            exec('git', ['add', '-f', path.join(options.output.base, options.output.dist)], done)
          else
