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/ /node_modules/
/dist/ /dist/*/

View file

@ -38,6 +38,6 @@ script:
- gulp jshint - gulp jshint
- gulp minify - gulp minify
- gulp test - gulp test
- gulp dist - gulp zip
after_script: after_script:
- '[ "${TRAVIS_BRANCH}" = "develop" ] && [ "${TRAVIS_NODE_VERSION}" = "stable" ] && travis/deploy-prebuilt.sh' - '[ "${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'), merge = require('merge-stream'),
zip = require('gulp-zip'); 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( return merge(
gulp.src([ gulp.src([
'dist/paper-full*.js', 'dist/paper-full*.js',
@ -31,7 +33,7 @@ gulp.task('dist', ['minify', 'docs', 'clean:dist'], function() {
.pipe(gulp.dest('dist')); .pipe(gulp.dest('dist'));
}); });
gulp.task('clean:dist', function() { gulp.task('clean:zip', function() {
return del([ return del([
'dist/paperjs.zip' 'dist/paperjs.zip'
]); ]);

View file

@ -11,31 +11,53 @@
*/ */
var gulp = require('gulp'), var gulp = require('gulp'),
addSrc = require('gulp-add-src'),
bump = require('gulp-bump'), bump = require('gulp-bump'),
git = require('gulp-git-streamed'), git = require('gulp-git-streamed'),
run = require('run-sequence'),
shell = require('gulp-shell'), shell = require('gulp-shell'),
options = require('../utils/options.js')({ suffix: false }); 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() { gulp.task('publish:bump', function() {
return gulp.src([ 'package.json', 'component.json' ]) return gulp.src([ 'package.json', 'component.json' ])
.pipe(bump({ version: options.version })) .pipe(bump({ version: options.version }))
.pipe(gulp.dest('./')) .pipe(gulp.dest('.'));
.pipe(addSrc('src/options.js'))
.pipe(git.add());
}); });
gulp.task('publish', ['publish:bump'], function() { gulp.task('publish:dist', ['dist']);
if (options.branch !== 'develop') {
throw new Error('Publishing is only allowed on the develop branch.'); gulp.task('publish:commit', function() {
}
var message = 'Release version ' + options.version; var message = 'Release version ' + options.version;
return gulp.src('.') return gulp.src('.')
.pipe(git.add())
.pipe(git.commit(message)) .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.checkout('master'))
.pipe(git.merge('develop', { args: '-X theirs' })) .pipe(git.merge('develop', { args: '-X theirs' }))
.pipe(git.push('origin', ['master', 'develop'], { args: '--tags' })) .pipe(git.push('origin', ['master', 'develop'], { args: '--tags' }))
.pipe(shell('npm publish')) .pipe(shell('npm publish'))
.pipe(git.checkout('develop')); .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", "prepush": "gulp test",
"build": "gulp build", "build": "gulp build",
"dist": "gulp dist", "dist": "gulp dist",
"zip": "gulp zip",
"docs": "gulp docs", "docs": "gulp docs",
"load": "gulp load", "load": "gulp load",
"jshint": "gulp jshint", "jshint": "gulp jshint",
@ -47,7 +48,6 @@
"del": "^2.2.1", "del": "^2.2.1",
"extend": "^3.0.0", "extend": "^3.0.0",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-add-src": "^0.2.0",
"gulp-bump": "^2.2.0", "gulp-bump": "^2.2.0",
"gulp-cached": "^1.1.0", "gulp-cached": "^1.1.0",
"gulp-git-streamed": "^1.8.0", "gulp-git-streamed": "^1.8.0",
@ -71,6 +71,7 @@
"qunitjs": "^1.23.0", "qunitjs": "^1.23.0",
"require-dir": "^0.3.0", "require-dir": "^0.3.0",
"resemblejs": "^2.2.1", "resemblejs": "^2.2.1",
"run-sequence": "^1.2.2",
"stats.js": "0.16.0", "stats.js": "0.16.0",
"straps": "^1.9.0" "straps": "^1.9.0"
}, },