Skip to content

Commit 9a2f70b

Browse files
authored
fix(release-script): Add the generation of changelog for the release (#2333)
* chore(changelog): regen missing versions * chore(validate-commit): Accepts type without scope The spec specifies that the scope is optional therefore we should not enforce their use on the CI. However it is still a recommended practice and we will enforce them when merging PRs. * fix(release-script): Added the generation of changelog for the release
1 parent 8830ab0 commit 9a2f70b

File tree

4 files changed

+85
-12
lines changed

4 files changed

+85
-12
lines changed

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
<a name="2.1.3"></a>
2+
## [2.1.3](https://github.com/algolia/instantsearch.js/compare/v2.1.2...v2.1.3) (2017-09-05)
3+
4+
5+
### Bug Fixes
6+
7+
* **Pagination:** add `autohideContainerHOC` to <Pagination /> ([#2296](https://github.com/algolia/instantsearch.js/issues/2296)) ([545f076](https://github.com/algolia/instantsearch.js/commit/545f076))
8+
* **sffv:** no error when not providing noResults and no results ([#2310](https://github.com/algolia/instantsearch.js/issues/2310)) ([cc02b71](https://github.com/algolia/instantsearch.js/commit/cc02b71)), closes [#2087](https://github.com/algolia/instantsearch.js/issues/2087)
9+
10+
11+
12+
<a name="2.1.2"></a>
13+
## [2.1.2](https://github.com/algolia/instantsearch.js/compare/v2.1.1...v2.1.2) (2017-08-24)
14+
15+
16+
### Bug Fixes
17+
18+
* **es:** wrong path to files ([#2295](https://github.com/algolia/instantsearch.js/issues/2295)) ([a437e19](https://github.com/algolia/instantsearch.js/commit/a437e19))
19+
20+
21+
22+
<a name="2.1.1"></a>
23+
## [2.1.1](https://github.com/algolia/instantsearch.js/compare/v2.1.0...v2.1.1) (2017-08-23)
24+
25+
26+
### Bug Fixes
27+
28+
* **build:** provide unminified css as well ([#2292](https://github.com/algolia/instantsearch.js/issues/2292)) ([a79e067](https://github.com/algolia/instantsearch.js/commit/a79e067))
29+
30+
31+
32+
<a name="2.1.0"></a>
33+
# [2.1.0](https://github.com/algolia/instantsearch.js/compare/v2.1.0-beta.4...v2.1.0) (2017-08-21)
34+
35+
36+
### Bug Fixes
37+
38+
* **nvmrc:** upgrade nodejs version ([#2291](https://github.com/algolia/instantsearch.js/issues/2291)) ([94529d4](https://github.com/algolia/instantsearch.js/commit/94529d4))
39+
40+
41+
142
<a name="2.0.2"></a>
243
## [2.0.2](https://github.com/algolia/instantsearch.js/compare/v2.0.1...v2.0.2) (2017-07-24)
344

scripts/conventionalChangelog.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable import/no-commonjs */
2+
3+
module.exports = {
4+
showChangelog,
5+
updateChangelog,
6+
getChangelog,
7+
};
8+
9+
const colors = require('colors/safe');
10+
11+
const baseConvChangelog = 'conventional-changelog -p angular';
12+
13+
function showChangelog(shell) {
14+
shell.echo(colors.yellow.underline('\nNext version changelog:'));
15+
const changelog = shell.exec(`${baseConvChangelog} -u`, { silent: true })
16+
.stdout;
17+
shell.echo(colors.white(changelog));
18+
}
19+
20+
function updateChangelog(shell) {
21+
shell.echo(colors.yellow('⚠️ Updating changelog'));
22+
shell.exec(`${baseConvChangelog} --infile CHANGELOG.md --same-file`, {
23+
silent: true,
24+
});
25+
}
26+
27+
function getChangelog(shell) {
28+
return shell.exec(baseConvChangelog, { silent: true }).stdout.trim();
29+
}

scripts/release.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ const inquirer = require('inquirer');
99
const shell = require('shelljs');
1010
shell.fatal = true;
1111

12+
const {
13+
updateChangelog,
14+
getChangelog,
15+
showChangelog,
16+
} = require('./conventionalChangelog.js');
17+
1218
// check if user can publish new version to npm
1319
const { code: isNotOwner } = shell.exec('$(npm owner add `npm whoami`)', {
1420
silent: true,
@@ -124,6 +130,8 @@ inquirer
124130
`)
125131
);
126132

133+
showChangelog(shell);
134+
127135
inquirer
128136
.prompt([
129137
{
@@ -156,17 +164,7 @@ inquirer
156164

157165
// update changelog
158166
shell.echo(colors.blue('Update changelog'));
159-
const changelog = shell
160-
.exec('conventional-changelog -p angular')
161-
.toString()
162-
.trim();
163-
164-
shell.echo('\nNext version changelog:');
165-
const changelogContent = shell.exec(
166-
'conventional-changelog -u -n scripts/conventional-changelog/',
167-
{ silent: true }
168-
);
169-
shell.echo(colors.white(changelogContent));
167+
const changelog = getChangelog(shell);
170168

171169
// regenerate README TOC
172170
shell.echo(colors.blue('Generate TOCS'));
@@ -175,6 +173,11 @@ inquirer
175173
// regenerate yarn.lock
176174
shell.exec('yarn');
177175

176+
// Update the changelog if stable
177+
if (strategy === 'stable') {
178+
updateChangelog(shell);
179+
}
180+
178181
// git add and tag
179182
const commitMessage = `v${newVersion}\n\n${changelog}`;
180183
shell.exec(

scripts/validate-commit-msgs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for sha in `git log --format=oneline "$RANGE" | cut '-d ' -f1`; do
4444
EXIT=2
4545
elif echo $FIRST_LINE | grep -qE '^Merge (pull request|branch)'; then
4646
echo "OK (merge)"
47-
elif echo $FIRST_LINE | grep -qE '^(feat|fix|docs?|style|refactor|perf|tests?|chore|revert)\(.+\): .*'; then
47+
elif echo $FIRST_LINE | grep -qE '^(feat|fix|docs?|style|refactor|perf|tests?|chore|revert)(\(.+\))?: .*'; then
4848
echo "OK"
4949
else
5050
echo "KO (format): $FIRST_LINE"

0 commit comments

Comments
 (0)