From 1b1b9a16066403228f88c1da983fd6af3f5c8021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 9 Jul 2016 19:48:02 +0200 Subject: [PATCH] Gulp: Change publish task so that dist folder contains built versions on master branch. As required by Bower... --- .gitignore | 2 +- .travis.yml | 2 +- gulp/tasks/dist.js | 6 ++++-- gulp/tasks/publish.js | 40 +++++++++++++++++++++++++++++++--------- package.json | 3 ++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b0a5c349..8dc9c779 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /node_modules/ -/dist/ +/dist/*/ diff --git a/.travis.yml b/.travis.yml index 8ce3097f..cc943b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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' diff --git a/gulp/tasks/dist.js b/gulp/tasks/dist.js index 33f0dc9e..b86ce6b9 100644 --- a/gulp/tasks/dist.js +++ b/gulp/tasks/dist.js @@ -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' ]); diff --git a/gulp/tasks/publish.js b/gulp/tasks/publish.js index d70277a2..b07fe442 100644 --- a/gulp/tasks/publish.js +++ b/gulp/tasks/publish.js @@ -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')); +}); diff --git a/package.json b/package.json index 23b356a2..cddcc5bc 100644 --- a/package.json +++ b/package.json @@ -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" },