Gulp: Define publish:website task to keep paperjs.org in sync.

This commit is contained in:
Jürg Lehni 2017-04-20 12:50:09 +02:00
parent 91199f19f0
commit 118deea20b
3 changed files with 101 additions and 50 deletions

4
.gitignore vendored
View file

@ -1,3 +1,5 @@
/.nvmrc
/node_modules/
/dist/*/
/.nvmrc
/dist/*.min.js
/dist/paperjs.zip

View file

@ -28,17 +28,19 @@ gulp.task('docs', ['docs:local', 'build:full'], function() {
});
Object.keys(docOptions).forEach(function(name) {
gulp.task('docs:' + name, ['clean:docs:' + name], shell.task([
'java -cp jsrun.jar:lib/* JsRun app/run.js -c=conf/' + name + '.conf ' +
'-D="renderMode:' + docOptions[name] + '" ' +
'-D="version:' + options.version + '"'
], {
cwd: 'gulp/jsdoc'
}));
gulp.task('docs:' + name, ['clean:docs:' + name], function() {
var mode = docOptions[name];
return gulp.src('src')
.pipe(shell(
['java -cp jsrun.jar:lib/* JsRun app/run.js',
' -c=conf/', name, '.conf ',
' -D="renderMode:', mode, '" ',
' -D="version:', options.version, '"'].join(''),
{ cwd: 'gulp/jsdoc' })
)
});
gulp.task('clean:docs:' + name, function() {
return del([
'dist/' + docOptions[name] + '/**',
]);
return del([ 'dist/' + docOptions[name] + '/**' ]);
});
});

View file

@ -11,14 +11,22 @@
*/
var gulp = require('gulp'),
git = require('gulp-git-streamed'),
jsonEditor = require('gulp-json-editor'),
merge = require('merge-stream'),
path = require('path'),
fs = require('fs'),
del = require('del'),
run = require('run-sequence'),
git = require('gulp-git-streamed'),
shell = require('gulp-shell'),
merge = require('merge-stream'),
rename = require('gulp-rename'),
jsonEditor = require('gulp-json-editor'),
options = require('../utils/options.js');
var packages = ['paper-jsdom', 'paper-jsdom-canvas'],
sitePath = path.resolve('../paperjs.org'),
referencePath = sitePath + '/content/08-Reference',
downloadPath = sitePath + '/content/11-Download',
releaseMessage = null,
jsonOptions = {
end_with_newline: true
};
@ -28,11 +36,12 @@ gulp.task('publish', function() {
throw new Error('Publishing is only allowed on the develop branch.');
}
return run(
'publish:version',
'publish:packages',
'publish:json',
'publish:dist',
'publish:commit',
'publish:release',
'publish:packages',
'publish:website',
'publish:load'
);
});
@ -41,6 +50,10 @@ gulp.task('publish:version', function() {
// Reset the version value since we're executing this on the develop branch,
// but we don't wan the published version suffixed with '-develop'.
options.resetVersion();
releaseMessage = 'Release version ' + options.version;
});
gulp.task('publish:json', ['publish:version'], function() {
return gulp.src(['package.json'])
.pipe(jsonEditor({
version: options.version
@ -48,44 +61,14 @@ gulp.task('publish:version', function() {
.pipe(gulp.dest('.'));
});
gulp.task('publish:packages',
packages.map(function(name) {
return 'publish:packages:' + name;
})
);
gulp.task('publish:dist', ['zip']);
packages.forEach(function(name) {
gulp.task('publish:packages:' + name, function() {
options.resetVersion(); // See 'publish:version'
var message = 'Release version ' + options.version,
path = 'packages/' + name,
opts = { cwd: path };
gulp.src(['package.json'], opts)
.pipe(jsonEditor({
version: options.version,
dependencies: {
paper: options.version
}
}, jsonOptions))
.pipe(gulp.dest(path))
.pipe(git.add(opts))
.pipe(git.commit(message, opts))
.pipe(git.tag('v' + options.version, message, opts))
.pipe(git.push('origin', 'master', { args: '--tags', cwd: path }))
.pipe(shell('npm publish', opts));
});
});
gulp.task('publish:dist', ['dist']);
gulp.task('publish:commit', function() {
options.resetVersion(); // See 'publish:version'
var message = 'Release version ' + options.version;
gulp.task('publish:commit', ['publish:version'], function() {
return gulp.src('.')
.pipe(git.checkout('develop'))
.pipe(git.add())
.pipe(git.commit(message))
.pipe(git.tag('v' + options.version, message));
.pipe(git.commit(releaseMessage))
.pipe(git.tag('v' + options.version, releaseMessage));
});
gulp.task('publish:release', function() {
@ -96,6 +79,70 @@ gulp.task('publish:release', function() {
.pipe(shell('npm publish'));
});
gulp.task('publish:packages',
packages.map(function(name) {
return 'publish:packages:' + name;
})
);
packages.forEach(function(name) {
gulp.task('publish:packages:' + name, ['publish:version'], function() {
var path = 'packages/' + name,
opts = { cwd: path };
gulp.src(['package.json'], opts)
.pipe(jsonEditor({
version: options.version,
dependencies: {
paper: options.version
}
}, jsonOptions))
.pipe(gulp.dest(path))
.pipe(git.add(opts))
.pipe(git.commit(releaseMessage, opts))
.pipe(git.tag('v' + options.version, releaseMessage, opts))
.pipe(git.push('origin', 'master', { args: '--tags', cwd: path }))
.pipe(shell('npm publish', opts));
});
});
gulp.task('publish:website', function() {
if (fs.lstatSync(sitePath).isDirectory()) {
return run(
'publish:website:build',
'publish:website:push'
);
}
});
gulp.task('publish:website:build',
['publish:website:docs', 'publish:website:zip']);
gulp.task('publish:website:docs:clean', function() {
return del([ referencePath + '/*' ], { force: true });
});
gulp.task('publish:website:docs',
['publish:version', 'publish:website:docs:clean', 'docs:server'],
function() {
return gulp.src('dist/serverdocs/**')
.pipe(gulp.dest(referencePath));
});
gulp.task('publish:website:zip', ['publish:version'], function() {
return gulp.src('dist/paperjs.zip')
.pipe(rename({ suffix: '-v' + options.version }))
.pipe(gulp.dest(downloadPath));
});
gulp.task('publish:website:push', ['publish:version'], function() {
var opts = { cwd: sitePath };
return gulp.src(sitePath)
.pipe(git.add(opts))
.pipe(git.commit(releaseMessage, opts))
.pipe(git.tag('v' + options.version, releaseMessage, opts))
.pipe(git.push('origin', 'master', { args: '--tags', cwd: sitePath }));
});
gulp.task('publish:load', ['load'], function() {
return gulp.src('dist')
.pipe(git.checkout('develop'))