Skip to content

Commit 7010209

Browse files
committed
Adding npm packiging&deployment infrastructure
1 parent e84d907 commit 7010209

File tree

5 files changed

+685
-12
lines changed

5 files changed

+685
-12
lines changed

Gruntfile.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"use strict";
2+
3+
module.exports = function (grunt) {
4+
5+
grunt.loadNpmTasks('grunt-bump');
6+
grunt.loadNpmTasks('grunt-exec');
7+
8+
grunt.initConfig({
9+
bump: {
10+
options: {
11+
files: ['package.json'],
12+
commit: true,
13+
commitMessage: 'Release version %VERSION%',
14+
commitFiles: ['package.json'],
15+
createTag: true,
16+
tagName: '%VERSION%',
17+
tagMessage: 'Version %VERSION%',
18+
push: false,
19+
prereleaseName: 'beta'
20+
}
21+
},
22+
exec: {
23+
ts: {
24+
command: 'node_modules/typescript/bin/tsc'
25+
}
26+
}
27+
});
28+
29+
function execExternal(cmd) {
30+
return function() {
31+
var done = this.async();
32+
grunt.log.ok("Executing " + cmd);
33+
require('child_process').exec(cmd, function(err, stdout, stderr) {
34+
if (err) {
35+
grunt.fatal('Error executing "' + cmd + '": ' + stderr);
36+
}
37+
console.log(stdout);
38+
stderr && console.error(stderr);
39+
done();
40+
});
41+
};
42+
}
43+
44+
grunt.registerTask('release',
45+
'Runs TypeScript compilation, increments the version and makes a tagged commit. Run as "grunt release:type", where "type" is "major", "minor", "patch", "prepatch", etc.)',
46+
versionType => {
47+
grunt.task.run([
48+
'bump:' + versionType,
49+
'exec:ts'
50+
]);
51+
}
52+
);
53+
54+
grunt.registerTask('release:git-push', 'Pushes to git', execExternal('git push origin master --follow-tags'));
55+
56+
grunt.registerTask('release:npm-publish', 'Deploys to npm', execExternal('npm publish .'));
57+
58+
grunt.registerTask('release:deploy', 'Pushes a new release to github and deploys to npm', [
59+
'release:git-push',
60+
'release:npm-publish'
61+
]);
62+
};

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ to your package.json.
1717

1818
The build infrastructure of the addon currently depends on tools that are Mac and Linux specific. Consequently, an installation on Windows will not be possible at this time.
1919

20+
# Release checklist
21+
22+
1. Run `grunt release:<type>` (where `type` is "major", "minor", "patch", "prepatch")
23+
2. Run `grunt release:deploy`
24+
3. Visit [https://github.com/ably/xdelta-async-nodejs-addon/tags](https://github.com/ably/xdelta-async-nodejs-addon/tags) and draft new release for the newly created tag
2025

2126
# License
2227

0 commit comments

Comments
 (0)