Repository navigation
Expand file tree
/
Copy pathrelease.config.js
More file actions
68 lines (66 loc) · 2.4 KB
/
Copy pathrelease.config.js
File metadata and controls
68 lines (66 loc) · 2.4 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Release branches, in ascending version order. semantic-release derives the
// version range each branch may publish from the tags on the branches after it:
//
// - main The 0.x production line. When v1 holds a v1.0.0 tag, main is
// clamped to ">=0.x <1.0.0" and accepts only patch and minor. A
// breaking change merged here then fails the release with
// EINVALIDNEXTVERSION. That failure is the guardrail, not a defect:
// the commit belongs on v1.
// - v1 The next-major development line. It publishes on its own "v1"
// channel, so its GitHub releases are marked pre-release and never
// take the "Latest" badge away from main.
//
// You might ask, why are we not just using release/v1.0.x instead? The reason
// is because we might want multiple feature versions of v1 deployed in
// various environments simultaneously, and using release/v1.0.x would tie us to a
// single patch line, which is less flexible.
//
const branch = process.env.GITHUB_REF_NAME || 'main'
const maintenanceMatch = branch.match(/^release\/v(\d+)\.(\d+)$/)
const branches = [
'main',
{
name: 'v1',
channel: 'v1'
}
]
if (maintenanceMatch) {
const [, major, minor] = maintenanceMatch
branches.push({
name: branch,
range: `${major}.${minor}.x`,
channel: 'maintenance',
prerelease: false
})
}
module.exports = {
branches,
tagFormat: 'v${version}',
plugins: [
[
'@semantic-release/commit-analyzer',
{
// Every conventional commit type triggers at least a patch so that
// running "Create Release" always produces a new version, even if the
// branch contains only chore/docs/ci commits.
releaseRules: [
{ breaking: true, release: 'major' },
{ revert: true, release: 'patch' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'perf', release: 'patch' },
{ type: 'revert', release: 'patch' },
{ type: 'chore', release: 'patch' },
{ type: 'docs', release: 'patch' },
{ type: 'style', release: 'patch' },
{ type: 'refactor', release: 'patch' },
{ type: 'test', release: 'patch' },
{ type: 'build', release: 'patch' },
{ type: 'ci', release: 'patch' }
]
}
],
'@semantic-release/release-notes-generator',
'@semantic-release/github'
]
}