-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.config.cjs
52 lines (51 loc) · 1.7 KB
/
release.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module.exports = {
branches: [
{ name: 'main' },
...(process.env.BETA_RELEASE === 'true'
? [
{
name: gitBranch(),
channel: 'beta',
prerelease: `beta-${gitSha().substring(0, 8)}`,
},
]
: []),
],
plugins: [
[
'@semantic-release/commit-analyzer',
{
preset: 'angular',
releaseRules: [
{ breaking: true, release: 'major' },
{ revert: true, release: 'patch' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'docs', release: 'patch' },
{ type: 'refactor', release: 'patch' },
],
parserOpts: {
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'],
},
},
],
'@semantic-release/release-notes-generator',
'@semantic-release/github',
'@semantic-release/npm',
],
}
function gitSha() {
return (
process.env.GITHUB_SHA ??
// Fallback, will not be executed in CI environments
require('node:child_process').execSync('git rev-parse HEAD', { cwd: process.cwd(), encoding: 'utf-8' })
)
}
function gitBranch() {
return (
process.env.GITHUB_REF_NAME ??
// Fallback, will not be executed in CI environments
require('node:child_process').execSync('git rev-parse --abbrev-ref HEAD', { cwd: process.cwd(), encoding: 'utf-8' })
)
}