1 | var publishRelease = require('publish-release');
|
2 | var through = require('through2');
|
3 | var gutil = require('gulp-util');
|
4 |
|
5 | var PluginError = gutil.PluginError;
|
6 | var PLUGIN_NAME = 'gulp-github-release';
|
7 |
|
8 | module.exports = function(options) {
|
9 | var files = [];
|
10 |
|
11 | var stream = through.obj(function(file, encoding, next) {
|
12 | files.push(file.path);
|
13 | next();
|
14 | }, function(callback) {
|
15 | var _this = this;
|
16 | var manifest = options.manifest;
|
17 | var repo = manifest && manifest.repository && /git@github\.com:([\w-]+)\/([\w-]+)\.git/.exec(manifest.repository.url);
|
18 |
|
19 | options = options || {};
|
20 | options.token = options.token || process.env.GITHUB_TOKEN;
|
21 | options.assets = files;
|
22 | options.owner = options.owner || repo && repo[1] || undefined;
|
23 | options.repo = options.repo || repo && repo[2] || undefined;
|
24 | options.tag = options.tag || manifest && ('v' + manifest.version) || undefined;
|
25 | options.name = options.name || options.tag;
|
26 |
|
27 | var release = publishRelease(options, callback);
|
28 |
|
29 | release.on('created-release', function() {
|
30 | gutil.log('Release created successfully at https://github.com/' + options.owner + '/' + options.repo + '/releases/tag/' + options.tag);
|
31 | });
|
32 |
|
33 | release.on('upload-asset', function(name) {
|
34 | gutil.log('Uploading asset ' + name);
|
35 | });
|
36 | });
|
37 |
|
38 |
|
39 | stream.resume();
|
40 | return stream;
|
41 | };
|