Gulp: Change publish task so that dist folder contains built versions on master branch.

As required by Bower...
This commit is contained in:
Jürg Lehni 2016-07-09 19:48:02 +02:00
parent b29a1e4028
commit 1b1b9a1606
5 changed files with 39 additions and 14 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
/node_modules/
/dist/
/dist/*/

View file

@ -38,6 +38,6 @@ script:
- gulp jshint
- gulp minify
- gulp test
- gulp dist
- gulp zip
after_script:
- '[ "${TRAVIS_BRANCH}" = "develop" ] && [ "${TRAVIS_NODE_VERSION}" = "stable" ] && travis/deploy-prebuilt.sh'

View file

@ -15,7 +15,9 @@ var gulp = require('gulp'),
merge = require('merge-stream'),
zip = require('gulp-zip');
gulp.task('dist', ['minify', 'docs', 'clean:dist'], function() {
gulp.task('dist', ['build', 'minify', 'docs']);
gulp.task('zip', ['clean:zip', 'dist'], function() {
return merge(
gulp.src([
'dist/paper-full*.js',
@ -31,7 +33,7 @@ gulp.task('dist', ['minify', 'docs', 'clean:dist'], function() {
.pipe(gulp.dest('dist'));
});
gulp.task('clean:dist', function() {
gulp.task('clean:zip', function() {
return del([
'dist/paperjs.zip'
]);

View file

@ -11,31 +11,53 @@
*/
var gulp = require('gulp'),
addSrc = require('gulp-add-src'),
bump = require('gulp-bump'),
git = require('gulp-git-streamed'),
run = require('run-sequence'),
shell = require('gulp-shell'),
options = require('../utils/options.js')({ suffix: false });
gulp.task('publish', function() {
if (options.branch !== 'develop') {
throw new Error('Publishing is only allowed on the develop branch.');
}
return run(
'publish:bump',
'publish:dist',
'publish:commit',
'publish:release',
'publish:load'
);
});
gulp.task('publish:bump', function() {
return gulp.src([ 'package.json', 'component.json' ])
.pipe(bump({ version: options.version }))
.pipe(gulp.dest('./'))
.pipe(addSrc('src/options.js'))
.pipe(git.add());
.pipe(gulp.dest('.'));
});
gulp.task('publish', ['publish:bump'], function() {
if (options.branch !== 'develop') {
throw new Error('Publishing is only allowed on the develop branch.');
}
gulp.task('publish:dist', ['dist']);
gulp.task('publish:commit', function() {
var message = 'Release version ' + options.version;
return gulp.src('.')
.pipe(git.add())
.pipe(git.commit(message))
.pipe(git.tag('v' + options.version, message))
.pipe(git.tag('v' + options.version, message));
});
gulp.task('publish:release', function() {
return gulp.src('.')
.pipe(git.checkout('master'))
.pipe(git.merge('develop', { args: '-X theirs' }))
.pipe(git.push('origin', ['master', 'develop'], { args: '--tags' }))
.pipe(shell('npm publish'))
.pipe(git.checkout('develop'));
});
gulp.task('publish:load', ['load'], function() {
return gulp.src('dist')
.pipe(git.add())
.pipe(git.commit('Switch back to load.js versions for development.'))
.pipe(git.push('origin', 'develop'));
});

View file

@ -20,6 +20,7 @@
"prepush": "gulp test",
"build": "gulp build",
"dist": "gulp dist",
"zip": "gulp zip",
"docs": "gulp docs",
"load": "gulp load",
"jshint": "gulp jshint",
@ -47,7 +48,6 @@
"del": "^2.2.1",
"extend": "^3.0.0",
"gulp": "^3.9.1",
"gulp-add-src": "^0.2.0",
"gulp-bump": "^2.2.0",
"gulp-cached": "^1.1.0",
"gulp-git-streamed": "^1.8.0",
@ -71,6 +71,7 @@
"qunitjs": "^1.23.0",
"require-dir": "^0.3.0",
"resemblejs": "^2.2.1",
"run-sequence": "^1.2.2",
"stats.js": "0.16.0",
"straps": "^1.9.0"
},