Nightly build task

Add a `grunt nightly` build task that copies needed files to a build
folder, then zips them up for distribution. We can also add a tag and
push it to github but I've only tested it with throwaway branches.

I made some guesses about the build folder and dist folder.  If you
have a better way feel free to give some recommendations.

Related to #102.
This commit is contained in:
Jacob Gable 2013-06-10 08:52:04 -05:00
parent 4a630af54a
commit d1300bb49c
2 changed files with 182 additions and 91 deletions

View File

@ -1,9 +1,22 @@
(function () {
"use strict";
var configureGrunt = function (grunt) {
var path = require('path'),
buildDirectory = path.resolve(process.cwd(), '../build'),
distDirectory = path.resolve(process.cwd(), '../dist'),
configureGrunt = function (grunt) {
var cfg = {
// Common paths to be used by tasks
paths: {
build: buildDirectory,
nightlyBuild: path.join(buildDirectory, 'nightly'),
dist: distDirectory,
nightlyDist: path.join(distDirectory, 'nightly')
},
pkg: grunt.file.readJSON('package.json'),
// JSLint all the things!
jslint: {
directives: {
@ -48,6 +61,22 @@
shell: {
bourbon: {
command: 'bourbon install --path core/admin/assets/sass/modules/'
},
commitNightly: {
command: 'git commit package.json -m "Nightly build <%= pkg.version %>"'
},
tagNightly: {
command: 'git tag <%= pkg.version %> -a -m "Nightly build <%= pkg.version %>"'
},
pushMaster: {
command: 'git push origin master'
},
pushMasterTags: {
command: 'git push origin master --tags'
}
},
@ -77,21 +106,54 @@
files: './core/admin/assets/tmpl/**/*.hbs',
tasks: ['handlebars']
}
},
copy: {
nightly: {
files: [{
expand: true,
src: [
'**',
'!node_modules/**',
'!core/shared/data/*.db',
'!.sass*',
'!.af*',
'!.git*',
'!.groc*',
'!.travis.yml'
],
dest: "<%= paths.nightlyBuild %>/<%= pkg.version %>/"
}]
}
},
zip: {
nightly: {
cwd: "<%= paths.nightlyBuild %>/<%= pkg.version %>/",
src: ["<%= paths.nightlyBuild %>/<%= pkg.version %>/**"],
dest: "<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip"
}
}
};
grunt.initConfig(cfg);
grunt.loadNpmTasks("grunt-jslint");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-bump");
grunt.loadNpmTasks("grunt-zip");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-sass");
grunt.loadNpmTasks("grunt-contrib-handlebars");
// Update the package information after changes
grunt.registerTask('updateCurrentPackageInfo', function () {
cfg.pkg = grunt.file.readJSON('package.json');
});
// Prepare the project for development
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
@ -103,6 +165,32 @@
// Run tests and lint code
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
/* Nightly builds
* - Bump patch version in package.json,
* - Copy files to build-folder/nightly/#{version} directory
* - Clean out unnecessary files (travis, .git*, .af*, .groc*)
* - Zip files in build folder to dist-folder/#{version} directory
* - git commit package.json -m "Nightly build #{version}"
* - git tag -a -m "Nightly build #{version}"
* - git push origin master
* - git push origin master --tags
* - TODO: POST to pubsubhubub to notify of new build?
*/
grunt.registerTask("nightly", [
"sass:admin",
"handlebars",
"validate",
"bump",
"updateCurrentPackageInfo",
"copy:nightly",
"zip:nightly",
/* Caution: shit gets real below here */
//"shell:commitNightly",
//"shell:tagNightly",
//"shell:pushMaster",
//"shell:pushMasterTags"
]);
// When you just say "grunt"
grunt.registerTask("default", ['sass:admin', 'handlebars', 'watch']);
};

View File

@ -31,6 +31,9 @@
"sinon": "~1.7.2",
"mocha": "~1.10.0",
"grunt-contrib-handlebars": "~0.5.9",
"grunt-contrib-watch": "~0.4.4"
"grunt-contrib-watch": "~0.4.4",
"grunt-bump": "0.0.2",
"grunt-zip": "~0.9.0",
"grunt-contrib-copy": "~0.4.1"
}
}