Gulp: Implement publish task.

This commit is contained in:
Jürg Lehni 2016-01-31 14:30:14 +01:00
parent f803afa4b6
commit 1a3a4be0b6
8 changed files with 65 additions and 14 deletions

View file

@ -17,7 +17,7 @@ var gulp = require('gulp'),
whitespace = require('gulp-whitespace'),
del = require('del'),
extend = require('extend'),
options = require('../utils/options.js');
options = require('../utils/options.js')({ suffix: true });
// Options to be used in Prepro.js preprocessing through the global __options
// object, merged in with the options required above.

View file

@ -14,7 +14,7 @@ var gulp = require('gulp'),
del = require('del'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
options = require('../utils/options.js');
options = require('../utils/options.js')({ suffix: true });
var docOptions = {
local: 'docs', // Generates the offline docs

45
gulp/tasks/publish.js Normal file
View file

@ -0,0 +1,45 @@
/*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
* http://scratchdisk.com/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
var gulp = require('gulp'),
addSrc = require('gulp-add-src'),
bump = require('gulp-bump'),
git = require('gulp-git-streamed'),
shell = require('gulp-shell'),
options = require('../utils/options.js')({ suffix: false });
gulp.task('publish', ['publish:bump', 'publish:release']);
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());
});
gulp.task('publish:release', function() {
if (options.branch !== 'develop') {
throw new Error('Publishing is only allowed on the develop branch.');
}
var message = 'Release version ' + options.version;
return gulp.src('.')
.pipe(git.commit(message))
.pipe(git.tag('v' + options.version, message))
.pipe(git.checkout('master'))
.pipe(git.merge('develop', { args: '-X theirs' }))
.pipe(git.push('origin', 'master' ))
.pipe(git.push('origin', 'develop' ))
.pipe(git.push(null, null, { args: '--tags' } ))
.pipe(shell('npm publish'))
.pipe(git.checkout('develop'));
});

View file

@ -10,7 +10,8 @@
* All rights reserved.
*/
var gitty = require('gitty');
var gitty = require('gitty'),
extend = require('extend');
// Require the __options object, so we have access to the version number and
// make amendments, e.g. the release date.
@ -27,8 +28,11 @@ function git(param) {
// Get the date of the last commit from this branch for release date:
options.date = git('log -1 --pretty=format:%ad');
// If we're not on the master branch, append the branch name to the version:
var branch = git('rev-parse --abbrev-ref HEAD');
if (branch !== 'master')
options.version += '-' + branch;
var branch = git('rev-parse --abbrev-ref HEAD'),
suffix = branch === 'master' ? '' : '-' + branch;
module.exports = options;
module.exports = function(opts) {
return extend({}, options, opts && opts.suffix && {
version: options.version + suffix
});
};

View file

@ -16,7 +16,7 @@
"main": "dist/paper-full.js",
"scripts": {
"lint": "jshint src",
"prepublish": "gulp build"
"prepublish": "gulp minify"
},
"files": [
"AUTHORS.md",
@ -39,14 +39,16 @@
"acorn": "~0.5.0",
"del": "^2.2.0",
"extend": "^3.0.0",
"gitty": "^3.3.3",
"gulp": "^3.9.0",
"gulp-add-src": "^0.2.0",
"gulp-bump": "^1.0.0",
"gulp-cached": "^1.1.0",
"gulp-git-streamed": "^1.0.0",
"gulp-jshint": "^2.0.0",
"gulp-prepro": "^2.2.0",
"gulp-qunits": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-shell": "^0.5.1",
"gulp-shell": "^0.5.2",
"gulp-symlink": "^2.1.3",
"gulp-uglify": "^1.5.1",
"gulp-uncomment": "^0.3.0",

View file

@ -51,8 +51,8 @@ if (typeof window === 'object') {
// dist/paper-node.js
options = require('../src/options.js');
// Override Node.js specific options.
options.version += '-load';
options.load = true;
options.version += '-load';
prepro.setup(function() {
// Return objects to be defined in the preprocess-scope.
// Note that this would be merge in with already existing objects.

View file

@ -15,7 +15,7 @@
// files directly through load.js / Prepro.js during development.
// The paper.js version.
// NOTE: Adjust value here before calling publish.sh, which then updates and
// NOTE: Adjust value here before calling `gulp publish`, which then updates and
// publishes the various JSON package files automatically.
var version = '0.9.25';
// If this file is loaded in the browser, we're in load.js mode.

View file

@ -1,5 +1,5 @@
/*!
* Paper.js v*#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting.
* Paper.js v*#=*__options.version - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: *#=* __options.date
* Date: *#=*__options.date
*
***
*