This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
githubRelease.js
65 lines (57 loc) · 1.44 KB
/
githubRelease.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var prompt = require('prompt');
var GitHubApi = require('github');
var colors = require('colors');
colors.setTheme({ warn: 'yellow', error: 'red', success: 'green' });
prompt.start();
var github = new GitHubApi({version: '3.0.0'});
var properties = [
{
description: 'GitHub username',
name: 'username'
},
{
description: 'GitHub password',
name: 'password',
hidden: true
}
];
var login = (callback) => {
prompt.get(properties, (err, result) => {
github.authenticate({
type: 'basic',
username: result.username,
password: result.password
});
github.repos.getLatestRelease({
user: 'OnsenUI',
repo: 'react-onsenui'
}, (err, res) => {
if (err != null) {
console.log('Wrong Username/Password'.warn);
return login(callback);
} else {
callback(res);
}
});
});
};
var data = login((res) => {
var tagname = res.tag_name;
var nodeJSON = require('./package.json');
var version = nodeJSON.version;
if (tagname == version) {
console.log('Error: Version has already been released, update package.json first'.error);
} else {
github.repos.createRelease( {
user: 'OnsenUI',
repo: 'react-onsenui',
tag_name: version
}, function(err, war) {
if (err) {
console.log('An error occurred'.error);
} else {
console.log(('New version ' + version + ' released').success);
}
});
}
});