Skip to content

Commit

Permalink
pull changelog from corresponding branch to generate releases for Mon…
Browse files Browse the repository at this point in the history
…goose 6.x and 7.x
  • Loading branch information
vkarpov15 committed Dec 18, 2024
1 parent 095c14a commit 505942c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/actions/createReleaseFromChangelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ module.exports = task => async function createReleaseFromChangelog(ref) {
if (ref == null) {
return;
}
const changelog = await task.sideEffect(githubOAuth.getChangelog, {});
const branch = (() => {
if (ref.startsWith('6.')) {
return '6.x';
}
if (ref.startsWith('7.')) {
return '7.x';
}
return 'master';
})();
const changelog = await task.sideEffect(githubOAuth.getChangelog, {
branch
});
const lines = changelog.split('\n');
let changelogLines = null;
for (let i = 0; i < lines.length; ++i) {
Expand Down
5 changes: 3 additions & 2 deletions src/integrations/githubOAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ module.exports = {
return axios.post(`https://github.com/login/oauth/access_token`, body, opts).
then(res => res.data);
},
getChangelog() {
const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md';
getChangelog(params) {
const branch = params && params.branch || 'master';
const url = host + '/repos/Automattic/mongoose/contents/CHANGELOG.md?ref=' + branch;
const headers = {
accept: 'application/vnd.github.v3.raw'
};
Expand Down
2 changes: 2 additions & 0 deletions test/createReleaseFromChangelog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ describe('createReleaseFromChangelog', function() {
const [tagAndName, body] = githubOAuth.createRelease.getCall(0).args;
assert.equal(tagAndName, '6.1.1');
assert.equal(body, changelog);
const [{ branch }] = githubOAuth.getChangelog.getCall(0).args;
assert.equal(branch, '6.x');
});
});

0 comments on commit 505942c

Please sign in to comment.