Fix #208 - Prevent grunt publish from destroying the gh-pages branch

This commit is contained in:
Kieran Sedgwick 2014-11-11 18:29:55 -05:00
parent 0d4110ff6f
commit 63f5fdeb6c
2 changed files with 52 additions and 18 deletions

View File

@ -143,7 +143,7 @@ module.exports = function(grunt) {
publish: { publish: {
options: { options: {
branch: 'gh-pages', branch: 'gh-pages',
overwrite: true force: true
} }
}, },
revert: { revert: {
@ -163,21 +163,9 @@ module.exports = function(grunt) {
} }
}, },
gitpull: {
publish: {
options: {
remote: GIT_REMOTE,
branch: 'develop',
force: true
},
}
},
gitcommit: { gitcommit: {
publish: { publish: {
options: { options: {
message: 'Tests for Filer v' +
JSON.parse(fs.readFileSync('./package.json', 'utf8')).version,
noStatus: true noStatus: true
} }
} }
@ -191,6 +179,24 @@ module.exports = function(grunt) {
} }
}, },
gitstash: {
publish: {
},
pop: {
options: {
command: "pop"
}
}
},
gitrm: {
publish: {
files: {
src: ['./dist/filer-test.js']
}
}
},
connect: { connect: {
serverForNode: { serverForNode: {
options: { options: {
@ -205,6 +211,17 @@ module.exports = function(grunt) {
keepalive: true keepalive: true
} }
} }
},
usebanner: {
publish: {
options: {
position: "top"
},
files: {
src: ['./dist/filer-test.js']
}
}
} }
}); });
@ -219,6 +236,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-banner');
grunt.registerTask('develop', ['clean', 'browserify:filerDist', 'browserify:filerIssue225']); grunt.registerTask('develop', ['clean', 'browserify:filerDist', 'browserify:filerIssue225']);
grunt.registerTask('build-tests', ['clean', 'browserify:filerTest']); grunt.registerTask('build-tests', ['clean', 'browserify:filerTest']);
@ -241,15 +259,30 @@ module.exports = function(grunt) {
' to ' + semver.inc(currentVersion, patchLevel).yellow + '?'; ' to ' + semver.inc(currentVersion, patchLevel).yellow + '?';
grunt.config('prompt.confirm.options', promptOpts); grunt.config('prompt.confirm.options', promptOpts);
// Store the new version in the gh-pages commit message
var ghPagesMessage = 'Tests for Filer v' + semver.inc(currentVersion, patchLevel);
grunt.config('gitcommit.publish.options.message', ghPagesMessage);
// Store the new version as a banner in the test file
// NOTE: This is a hack intended to ensure that this build process
// succeeds even if no changes were made to the tests
// before publishing a new version. Otherwise, the automatic
// commit + push to github pages would break a normal build
var bannerMsg = "/* Test file for filerjs v" + semver.inc(currentVersion, patchLevel) + "*/";
grunt.config('usebanner.publish.options.banner', bannerMsg);
grunt.task.run([ grunt.task.run([
'prompt:confirm', 'prompt:confirm',
'checkBranch', 'checkBranch',
'release', 'release',
'bump:' + patchLevel, 'bump:' + patchLevel,
'gitcheckout:publish',
'gitpull:publish',
'build-tests', 'build-tests',
'usebanner:publish',
'gitadd:publish', 'gitadd:publish',
'gitstash:publish',
'gitcheckout:publish',
'gitrm:publish',
'gitstash:pop',
'gitcommit:publish', 'gitcommit:publish',
'gitpush:publish', 'gitpush:publish',
'gitcheckout:revert', 'gitcheckout:revert',

View File

@ -30,6 +30,7 @@
"devDependencies": { "devDependencies": {
"chai": "~1.9.1", "chai": "~1.9.1",
"grunt": "~0.4.0", "grunt": "~0.4.0",
"grunt-banner": "^0.2.3",
"grunt-browserify": "^2.1.0", "grunt-browserify": "^2.1.0",
"grunt-bump": "0.0.13", "grunt-bump": "0.0.13",
"grunt-contrib-clean": "~0.4.0", "grunt-contrib-clean": "~0.4.0",
@ -39,14 +40,14 @@
"grunt-contrib-jshint": "~0.7.1", "grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.1.2", "grunt-contrib-uglify": "~0.1.2",
"grunt-contrib-watch": "~0.3.1", "grunt-contrib-watch": "~0.3.1",
"grunt-git": "0.3.1", "grunt-git": "git://github.com/sedge/grunt-git.git#gitrm",
"grunt-npm": "git://github.com/sedge/grunt-npm.git#branchcheck", "grunt-npm": "git://github.com/sedge/grunt-npm.git#branchcheck",
"grunt-prompt": "^1.1.0", "grunt-prompt": "^1.1.0",
"grunt-shell": "~0.7.0", "grunt-shell": "~0.7.0",
"habitat": "^1.1.0", "habitat": "^1.1.0",
"mocha": "~1.18.2", "mocha": "~1.18.2",
"semver": "^2.3.0", "requirejs": "^2.1.14",
"requirejs": "^2.1.14" "semver": "^2.3.0"
}, },
"main": "./src/index.js" "main": "./src/index.js"
} }