Creating a 7-zip-archive as deployment artifact with grunt and grunt-shell

In certain development projects you’re not given direct access to the production systems of the customer to allow an automated deployment via standard tools. Instead it is required to have some kind of “artifact” that can be transferred to the customer and allows the deployment there.

The following grunt-task does this as a part of the build-process. In this specific case it loads an Ext JS manifest file (produced by Sencha Cmd) to have the application specific settings. The archive is then password-protected to disallow an easy extraction via “unauthorized individuals”.

module.exports = function (grunt) {
  grunt.initConfig({
    buildInfo: grunt.file.readJSON('../src/foobar/build/production/foobar/app.json'),
    shell: {
      dist_customer: {
        command: '"/path/to/7z" a -t7z -p$$SuperSecretPassword$$ /path/to/deployment/folder/foobar_<%= buildInfo.version %>.7z /path/to/deployment/folder/foobar/<%= buildInfo.version %>/*'
      }
    }
  });
 
  grunt.loadNpmTasks('grunt-shell');
 
  grunt.registerTask('default', ['shell']);
};