Merge pull request #1 from netmanagers/master
[arvados-formula.git] / release.config.js
1 module.exports = {
2   branch: 'master',
3   plugins: [
4       ['@semantic-release/commit-analyzer', {
5         preset: 'angular',
6         releaseRules: './release-rules.js',
7       }],
8       '@semantic-release/release-notes-generator',
9       ['@semantic-release/changelog', {
10         changelogFile: 'CHANGELOG.md',
11         changelogTitle: '# Changelog',
12       }],
13       ['@semantic-release/exec', {
14         prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}',
15       }],
16       ['@semantic-release/git', {
17         assets: ['*.md', 'docs/*.rst', 'FORMULA'],
18       }],
19       '@semantic-release/github',
20   ],
21   generateNotes: {
22     preset: 'angular',
23     writerOpts: {
24       // Required due to upstream bug preventing all types being displayed.
25       // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
26       // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
27       transform: (commit, context) => {
28           const issues = []
29
30           commit.notes.forEach(note => {
31               note.title = `BREAKING CHANGES`
32           })
33
34           // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
35           if (commit.type === `feat`) {
36               commit.type = `Features`
37           } else if (commit.type === `fix`) {
38               commit.type = `Bug Fixes`
39           } else if (commit.type === `perf`) {
40               commit.type = `Performance Improvements`
41           } else if (commit.type === `revert`) {
42               commit.type = `Reverts`
43           } else if (commit.type === `docs`) {
44               commit.type = `Documentation`
45           } else if (commit.type === `style`) {
46               commit.type = `Styles`
47           } else if (commit.type === `refactor`) {
48               commit.type = `Code Refactoring`
49           } else if (commit.type === `test`) {
50               commit.type = `Tests`
51           } else if (commit.type === `build`) {
52               commit.type = `Build System`
53           // } else if (commit.type === `chore`) {
54           //     commit.type = `Maintenance`
55           } else if (commit.type === `ci`) {
56               commit.type = `Continuous Integration`
57           } else {
58               return
59           }
60
61           if (commit.scope === `*`) {
62               commit.scope = ``
63           }
64
65           if (typeof commit.hash === `string`) {
66               commit.shortHash = commit.hash.substring(0, 7)
67           }
68
69           if (typeof commit.subject === `string`) {
70               let url = context.repository
71                   ? `${context.host}/${context.owner}/${context.repository}`
72                   : context.repoUrl
73               if (url) {
74                   url = `${url}/issues/`
75                   // Issue URLs.
76                   commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
77                       issues.push(issue)
78                       return `[#${issue}](${url}${issue})`
79                   })
80               }
81               if (context.host) {
82                   // User URLs.
83                   commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
84                   if (username.includes('/')) {
85                       return `@${username}`
86                   }
87
88                   return `[@${username}](${context.host}/${username})`
89                   })
90               }
91           }
92
93           // remove references that already appear in the subject
94           commit.references = commit.references.filter(reference => {
95               if (issues.indexOf(reference.issue) === -1) {
96                   return true
97               }
98
99               return false
100           })
101
102           return commit
103       },
104     },
105   },
106 };