Skip to content

Commit a89cd5d

Browse files
committed
First steps for commit logs on the release page :)
1 parent 878093b commit a89cd5d

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

build/tasks/publish.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function (grunt) {
44
var gitUser = process.env.GIT_USER;
55
var gitPassword = process.env.GIT_PASSWORD;
66
var gitEmail = process.env.GIT_EMAIL;
7+
var releaseNotes;
78

89
function getMasterCommit (repo) {
910
return repo.getMasterCommit();
@@ -65,7 +66,9 @@ module.exports = function (grunt) {
6566
newContent = JSON.parse(blobs[0].toString('utf-8'));
6667
oldContent = JSON.parse(blobs[1].toString('utf-8'));
6768
if (newContent.version != oldContent.version) {
68-
return true;
69+
return buildReleaseNotes(repo, oldContent.version).then(function () {
70+
return true;
71+
});
6972
}
7073
return false;
7174
}).then(function (versionChanged) {
@@ -157,11 +160,11 @@ module.exports = function (grunt) {
157160
}).then(function (parent) {
158161
return repository.createCommit('HEAD', author, author, '[ci skip] Build Version ' + version, oid, [parent]);
159162
}).then(function (id) {
160-
grunt.log.writeln('Created commit ' + id + 'for ' + version);
163+
grunt.log.writeln('Created commit ' + id + ' for ' + version);
161164
return Git.Object.lookup(repository, id, Git.Object.TYPE.COMMIT);
162165
})
163166
.then(function (object) {
164-
return Git.Tag.create(repository, version, object, author, 'Release v'+version, 0); // 0 = don't force tag creation
167+
return Git.Tag.annotationCreate(repository, version, object, author, 'Release v'+version); // 0 = don't force tag creation
165168
}).then(function () {
166169
grunt.log.writeln('Created tag ' + version);
167170
return repository.getRemote('origin');
@@ -186,6 +189,33 @@ module.exports = function (grunt) {
186189
});
187190
}
188191

192+
function buildReleaseNotes (repository, version) {
193+
releaseNotes = '### Release ' + grunt.config.data.version + '\n Commits: \n';
194+
return repository.getReferenceCommit(version).then(function (targetCommit) {
195+
return getMasterCommit(repository).then(function (masterCommit) {
196+
return new Promise(function (resolve) {
197+
var history = masterCommit.history(Git.Revwalk.SORT.TIME);
198+
history.on('end', function (commits) {
199+
for (var i = 0; i < commits.length; i++) {
200+
var commit = commits[i];
201+
if (commit.id().toString() == targetCommit.id().toString()) {
202+
break;
203+
}
204+
205+
if (process.env.TRAVIS_REPO_SLUG) {
206+
releaseNotes += '* [[`' + commit.sha() + '`](https://github.com/' + process.env.TRAVIS_REPO_SLUG + 'commit/' + commit.sha() +')] - ' + commit.summary() + '\n';
207+
} else {
208+
releaseNotes += '* [`' + commit.sha() + '`] - ' + commit.summary() + '\n';
209+
}
210+
}
211+
resolve();
212+
});
213+
history.start();
214+
});
215+
});
216+
});
217+
}
218+
189219
function publishNpm () {
190220
var cwd = process.cwd();
191221
process.chdir(require('path').join(cwd, 'dist/npm'));

0 commit comments

Comments
 (0)