Skip to content

Commit 5badf86

Browse files
authored
Merge pull request #2144 from sakshamsaxena/almost-eased-up
Automating the release process
2 parents 2f521ca + 5e2eb0d commit 5badf86

File tree

12 files changed

+333
-31
lines changed

12 files changed

+333
-31
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ docs/yuidoc-p5-theme/assets/js/reference.js*
1212
examples/3d/
1313
.idea
1414
.vscode
15+
dist/
16+
p5.zip
17+
bower-repo/
18+
p5-website/

.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"trailing": true,
1212
"undef": true,
1313
"unused": "vars",
14-
14+
"esnext": true,
15+
"predef": ["Promise"],
1516
"node": true
1617
}

Gruntfile.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = function(grunt) {
9696
build: {
9797
src: [
9898
'Gruntfile.js',
99-
'build/**/*.js'
99+
'tasks/**/*.js'
100100
]
101101
},
102102
source: {
@@ -118,7 +118,7 @@ module.exports = function(grunt) {
118118
},
119119
src: [
120120
'Gruntfile.js',
121-
'build/**/*.js'
121+
'tasks/**/*.js'
122122
]
123123
},
124124
source: {
@@ -273,24 +273,6 @@ module.exports = function(grunt) {
273273

274274
// this builds the documentation for the codebase.
275275
yuidoc: getYuidocOptions(),
276-
'release-it': {
277-
options: {
278-
pkgFiles: ['package.json'],
279-
commitMessage: 'release v%s',
280-
tagName: '%s',
281-
tagAnnotation: 'release v%s',
282-
buildCommand: 'grunt',
283-
changelogCommand: 'git log --pretty=format:"* %s (%h)" [REV_RANGE]',
284-
distRepo: 'git@github.com:lmccart/p5.js-release.git',
285-
distStageDir: '.stage',
286-
distFiles: ['lib/*.js', 'lib/addons/*.js'],
287-
distBase: 'lib/',
288-
npm: {
289-
publish: false,
290-
publishPath: 'lib/'
291-
}
292-
}
293-
},
294276

295277
// This is a static server which is used when testing connectivity for the
296278
// p5 library. This avoids needing an internet connection to run the tests.
@@ -345,23 +327,29 @@ module.exports = function(grunt) {
345327
// `grunt combineModules:module_1:module_2` where core
346328
// is included by default in all combinations always.
347329
// NOTE: "module_x" is the name of it's folder in /src.
348-
grunt.loadTasks('build/tasks');
330+
grunt.loadTasks('tasks/build');
331+
332+
// Load release task
333+
grunt.loadTasks('tasks/release');
349334

350335
// Load the external libraries used.
351-
grunt.loadNpmTasks('grunt-jscs');
336+
grunt.loadNpmTasks('grunt-contrib-compress');
337+
grunt.loadNpmTasks('grunt-contrib-connect');
338+
grunt.loadNpmTasks('grunt-contrib-copy');
352339
grunt.loadNpmTasks('grunt-contrib-jshint');
353340
grunt.loadNpmTasks('grunt-contrib-watch');
354341
grunt.loadNpmTasks('grunt-contrib-requirejs');
355-
grunt.loadNpmTasks('grunt-mocha');
356342
grunt.loadNpmTasks('grunt-contrib-yuidoc');
357-
grunt.loadNpmTasks('grunt-update-json');
358343
grunt.loadNpmTasks('grunt-contrib-uglify');
359-
grunt.loadNpmTasks('grunt-contrib-connect');
344+
grunt.loadNpmTasks('grunt-http');
345+
grunt.loadNpmTasks('grunt-jscs');
346+
grunt.loadNpmTasks('grunt-minjson');
347+
grunt.loadNpmTasks('grunt-mocha');
348+
grunt.loadNpmTasks('grunt-mocha-test');
360349
grunt.loadNpmTasks('grunt-newer');
361350
grunt.loadNpmTasks('grunt-release-it');
362351
grunt.loadNpmTasks('grunt-saucelabs');
363-
grunt.loadNpmTasks('grunt-mocha-test');
364-
grunt.loadNpmTasks('grunt-minjson');
352+
grunt.loadNpmTasks('grunt-update-json');
365353

366354
// Create the multitasks.
367355
grunt.registerTask('build', ['browserify', 'uglify', 'requirejs']);

lib/empty-example/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="../p5.min.js"></script>
5+
<script src="../addons/p5.dom.min.js"></script>
6+
<script src="../addons/p5.sound.min.js"></script>
7+
<script src="sketch.js"></script>
8+
<style> body {padding: 0; margin: 0;} </style>
9+
</head>
10+
<body>
11+
</body>
12+
</html>

lib/empty-example/sketch.js

Whitespace-only changes.

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,30 @@
1919
"derequire": "^2.0.0",
2020
"grunt": "^0.4.5",
2121
"grunt-cli": "^0.1.13",
22+
"grunt-contrib-compress": "^1.4.3",
2223
"grunt-contrib-concat": "^0.5.1",
2324
"grunt-contrib-connect": "^0.9.0",
25+
"grunt-contrib-copy": "^1.0.0",
2426
"grunt-contrib-jshint": "^0.11.2",
2527
"grunt-contrib-requirejs": "~0.4.1",
2628
"grunt-contrib-uglify": "^0.7.0",
2729
"grunt-contrib-watch": "~0.5.3",
2830
"grunt-contrib-yuidoc": "1.0.0",
31+
"grunt-http": "^2.2.0",
2932
"grunt-jscs": "^3.0.1",
3033
"grunt-lib-phantomjs": "~0.4.0",
3134
"grunt-minjson": "^0.4.0",
3235
"grunt-mocha": "^1.0.4",
3336
"grunt-mocha-test": "^0.12.7",
3437
"grunt-newer": "^1.1.0",
35-
"grunt-release-it": "^0.2.1",
38+
"grunt-release-it": "^1.0.1",
3639
"grunt-saucelabs": "8.6.1",
3740
"grunt-update-json": "^0.2.1",
3841
"jscs-stylish": "^0.3.1",
3942
"marked": "^0.3.5",
4043
"mocha": "^3.2.0",
41-
"phantomjs": "^2.1.7"
44+
"phantomjs": "^2.1.7",
45+
"request": "^2.81.0"
4246
},
4347
"license": "LGPL-2.1",
4448
"dependencies": {
@@ -54,7 +58,9 @@
5458
"lib/p5.min.js",
5559
"lib/p5.js",
5660
"lib/addons/p5.sound.js",
57-
"lib/addons/p5.dom.js"
61+
"lib/addons/p5.sound.min.js",
62+
"lib/addons/p5.dom.js",
63+
"lib/addons/p5.dom.min.js"
5864
],
5965
"description": "[![Build Status](https://travis-ci.org/processing/p5.js.svg?branch=master)](https://travis-ci.org/processing/p5.js) [![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)",
6066
"bugs": {

tasks/release/release-bower.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* Grunt Task to Release the Library files on dist repo for Bower */
2+
3+
// Using native exec instead of Grunt spawn so as to utilise Promises
4+
const exec = require('child_process').exec;
5+
6+
module.exports = function(grunt) {
7+
8+
grunt.registerTask('release-bower', 'Publishes the new release of p5.js on Bower', function() {
9+
10+
// Async Task
11+
var done = this.async();
12+
// Keep the version handy
13+
var version = require('../../package.json').version;
14+
// Avoiding Callback Hell and using Promises
15+
new Promise(function(resolve, reject) {
16+
// Clone the repo. NEEDS TO BE QUIET. Took 3 hours to realise this.
17+
// Otherwise the stdout screws up
18+
console.log('Cloning the Release repo ...');
19+
exec('rm -rf bower-repo/ && git clone -q https://github.com/lmccart/p5.js-release.git bower-repo',function(err, stdout, stderr) {
20+
if (err) {
21+
reject(err);
22+
}
23+
if (stderr) {
24+
reject(stderr);
25+
}
26+
resolve();
27+
});
28+
}).then(function(resolve, reject) {
29+
// Copy the lib to bower-repo.
30+
// NOTE : Uses 'cp' of UNIX. Make sure it is unaliased in your .bashrc,
31+
// otherwise it may prompt always for overwrite (not desirable)
32+
console.log('Copying new files ...');
33+
return new Promise(function(resolve, reject) {
34+
exec('cp lib/*.js lib/addons bower-repo/lib -r', function(err, stdout, stderr) {
35+
if (err) {
36+
reject(err);
37+
}
38+
if (stderr) {
39+
reject(stderr);
40+
}
41+
resolve();
42+
});
43+
});
44+
}).then(function(resolve, reject) {
45+
// Git add, commit, push
46+
console.log('Pushing out changes ...');
47+
return new Promise(function(resolve, reject) {
48+
exec('git add --all && git commit -am "' + version + '" && git push -q', { cwd: './bower-repo' },function(err, stdout, stderr) {
49+
if (err) {
50+
reject(err);
51+
}
52+
if (stderr) {
53+
reject(stderr);
54+
}
55+
resolve();
56+
done();
57+
});
58+
});
59+
}).catch(function(err) {
60+
throw new Error(err);
61+
});
62+
});
63+
};

tasks/release/release-docs.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* Grunt Task to Release the DOcs on website repo */
2+
3+
// Using native exec instead of Grunt spawn so as to utilise Promises
4+
const exec = require('child_process').exec;
5+
6+
module.exports = function(grunt) {
7+
8+
grunt.registerTask('release-docs', 'Publishes the new docs of p5.js on the website', function() {
9+
10+
// Async Task
11+
var done = this.async();
12+
// Keep the version handy
13+
var version = require('../../package.json').version;
14+
// Avoiding Callback Hell and using Promises
15+
new Promise(function(resolve, reject) {
16+
// Clone the website locally
17+
console.log('Cloning the website ...');
18+
exec('rm -rf p5-website/ && git clone -q https://github.com/sakshamsaxena/p5.js-website.git p5-website',function(err, stdout, stderr) {
19+
if (err) {
20+
reject(err);
21+
}
22+
if (stderr) {
23+
reject(stderr);
24+
}
25+
resolve();
26+
});
27+
}).then(function() {
28+
// Copy the new docs over
29+
console.log('Copying new docs ...');
30+
return new Promise(function(resolve, reject) {
31+
exec('cp -r docs/reference p5-website/dist/', function(err, stdout, stderr) {
32+
if (err) {
33+
reject(err);
34+
}
35+
if (stderr) {
36+
reject(stderr);
37+
}
38+
resolve();
39+
});
40+
});
41+
}).then(function() {
42+
// Add, Commit, Push
43+
console.log('Pushing to GitHub ...');
44+
return new Promise(function(resolve, reject) {
45+
exec('git add --all && git commit -am "Updated Reference for version ' + version + '" && git push', {cwd: './p5-website' }, function(err, stdout, stderr) {
46+
if (err) {
47+
reject(err);
48+
}
49+
if (stderr) {
50+
reject(stderr);
51+
}
52+
resolve();
53+
done();
54+
});
55+
});
56+
}).catch(function(err) {
57+
throw new Error(err);
58+
});
59+
});
60+
};

0 commit comments

Comments
 (0)