-
Notifications
You must be signed in to change notification settings - Fork 4
/
generate.js
122 lines (106 loc) · 4.3 KB
/
generate.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//var GitHubApi = require("github");
var os = require('os');
var fs = require('fs');
var readlineSync = require('readline-sync');
var events = require('events');
var github = require('./auth.js')
var eventEmitter = new events.EventEmitter();
var owner = "github-for-unity";
var repo = "Unity";
github.events.on('authenticated', function(token) {
getReleaseChangeLog();
})
github.login();
function getReleaseChangeLog()
{
github.repos.getReleases({
owner: owner,
repo: repo,
page: 1,
per_page: 2
}, function(err, releases) {
var res = releases.data.filter(function(el) {
return !el.draft;
});
//console.error(JSON.stringify(JSON.parse(JSON.stringify(res)),null,'\t'));
var tag = res[0].tag_name;
var date = res[0].created_at;
github.gitdata.getTags({
owner: owner,
repo: repo,
}, function(err, res) {
var t = res.data.filter(function(el) {
return el.ref == "refs/tags/" + tag;
});
var sha = t[0].object.sha;
console.error("Previous release tag: " + tag);
//console.error(JSON.stringify(JSON.parse(JSON.stringify(res)),null,'\t'));
var list = "# Release Notes" + os.EOL + os.EOL;
github.issues.getForRepo({
owner: owner,
repo: repo,
state: "closed",
labels: "feature",
since: date
}, function(err, res) {
//console.error(JSON.stringify(res));
var hasStuff = res.data.length;
if (hasStuff)
list += "## Features" + os.EOL;
for (var issue in res.data) {
if (issue != "meta")
list += "- #" + res.data[issue].number + " - " + res.data[issue].title + os.EOL;
}
github.issues.getForRepo({
owner: owner,
repo: repo,
state: "closed",
labels: "enhancement",
since: date
}, function(err, res) {
//console.error(JSON.stringify(res));
hasStuff = res.data.length;
if (hasStuff)
list += "## Enhancements" + os.EOL;
for (var issue in res.data) {
if (issue != "meta")
list += "- #" + res.data[issue].number + " - " + res.data[issue].title + os.EOL;
}
github.issues.getForRepo({
owner: owner,
repo: repo,
state: "closed",
labels: "bug",
since: date
}, function(err, res) {
//console.error(JSON.stringify(res));
hasStuff = res.data.length;
if (hasStuff)
list += "## Fixes" + os.EOL;
for (var issue in res.data) {
if (issue != "meta")
list += "- #" + res.data[issue].number + " - " + res.data[issue].title + os.EOL;
}
list += os.EOL;
list += "=====" + os.EOL;
list += "Pull Requests" + os.EOL;
list += "=====" + os.EOL;
github.pullRequests.getAll({
owner: owner,
repo: repo,
state: "closed",
head: sha
}, function(err, res) {
//console.error(JSON.stringify(JSON.parse(JSON.stringify(res)),null,'\t'));
for (var pr in res.data) {
if (res.data[pr].merged_at > date)
list += "- #" + res.data[pr].number + " - " + res.data[pr].title + os.EOL;
}
console.log(list);
});
});
});
});
});
});
}