Skip to content

Commit bd35834

Browse files
ci(releaserc): gerar nota de release para todos os tipos de commit
1 parent 8edd76b commit bd35834

File tree

1 file changed

+79
-1
lines changed

1 file changed

+79
-1
lines changed

.releaserc.js

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,79 @@
11
/* eslint no-template-curly-in-string: 0 */
22

3+
// https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/writer-opts.js
4+
customTransform = (commit, context) => {
5+
const issues = []
6+
7+
commit.notes.forEach(note => {
8+
note.title = 'BREAKING CHANGES'
9+
})
10+
11+
if (commit.type === 'feat') {
12+
commit.type = 'Features'
13+
} else if (commit.type === 'fix') {
14+
commit.type = 'Bug Fixes'
15+
} else if (commit.type === 'perf') {
16+
commit.type = 'Performance Improvements'
17+
} else if (commit.type === 'revert' || commit.revert) {
18+
commit.type = 'Reverts'
19+
} else if (commit.type === 'docs') {
20+
commit.type = 'Documentation'
21+
} else if (commit.type === 'style') {
22+
commit.type = 'Styles'
23+
} else if (commit.type === 'refactor') {
24+
commit.type = 'Code Refactoring'
25+
} else if (commit.type === 'test') {
26+
commit.type = 'Tests'
27+
} else if (commit.type === 'build') {
28+
commit.type = 'Build System'
29+
} else if (commit.type === 'ci') {
30+
commit.type = 'Continuous Integration'
31+
} else {
32+
return
33+
}
34+
35+
if (commit.scope === '*') {
36+
commit.scope = ''
37+
}
38+
39+
if (typeof commit.hash === 'string') {
40+
commit.shortHash = commit.hash.substring(0, 7)
41+
}
42+
43+
if (typeof commit.subject === 'string') {
44+
let url = context.repository
45+
? `${context.host}/${context.owner}/${context.repository}`
46+
: context.repoUrl
47+
if (url) {
48+
url = `${url}/issues/`
49+
// Issue URLs.
50+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
51+
issues.push(issue)
52+
return `[#${issue}](${url}${issue})`
53+
})
54+
}
55+
if (context.host) {
56+
// User URLs.
57+
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
58+
if (username.includes('/')) {
59+
return `@${username}`
60+
}
61+
return `[@${username}](${context.host}/${username})`
62+
})
63+
}
64+
}
65+
66+
// remove references that already appear in the subject
67+
commit.references = commit.references.filter(reference => {
68+
if (issues.indexOf(reference.issue) === -1) {
69+
return true
70+
}
71+
return false
72+
})
73+
74+
return commit
75+
}
76+
377
module.exports = {
478
branches: [
579
// https://github.com/semantic-release/semantic-release/blob/master/docs/usage/workflow-configuration.md#workflow-configuration
@@ -13,7 +87,11 @@ module.exports = {
1387
{ scope: 'no-release', release: false }
1488
]
1589
}],
16-
'@semantic-release/release-notes-generator',
90+
['@semantic-release/release-notes-generator', {
91+
writerOpts: {
92+
transform: customTransform
93+
}
94+
}],
1795
['@semantic-release/changelog', {
1896
changelogTitle: '# Changelog'
1997
}],

0 commit comments

Comments
 (0)