forked from opencloud-eu/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease-config.ts
More file actions
112 lines (101 loc) · 2.87 KB
/
release-config.ts
File metadata and controls
112 lines (101 loc) · 2.87 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
export default {
changeTypes: [
{
title: '💥 Breaking changes',
labels: ['breaking', 'Type:Breaking-Change'],
bump: 'major',
weight: 3
},
{
title: '🔒 Security',
labels: ['security', 'Type:Security'],
bump: 'patch',
weight: 2
},
{
title: '✨ Features',
labels: ['feature', 'Type:Feature'],
bump: 'minor',
weight: 1
},
{
title: '📈 Enhancement',
labels: ['enhancement', 'refactor', 'Type:Enhancement'],
bump: 'minor'
},
{
title: '🐛 Bug Fixes',
labels: ['bug', 'Type:Bug'],
bump: 'patch'
},
{
title: '📦️ Dependencies',
labels: ['dependency', 'dependencies', 'Type:Dependencies'],
bump: 'patch',
weight: -1
}
],
useVersionPrefixV: true,
getLatestTag: ({ exec }) => {
// the plugin uses the latest tag to determine the next version
// and the changes that are included in the upcoming release.
const branch = getBranch(exec)
let tags = getTags(exec)
if (branch.startsWith('stable-')) {
const [_, majorAndMinor] = branch.split('-')
// we only care about tags that are within the range of the current stable branch.
// e.g. if the branch is stable-1.2, we only care about tags that are v1.2.x.
const matchingTags = tags.filter((t) => t.startsWith(`v${majorAndMinor}`))
if (matchingTags.length) {
tags = matchingTags
}
}
return tags.pop() || 'v0.0.0'
},
useLatestRelease: ({ exec, nextVersion }) => {
// check if the release should be marked as latest release on GitHub.
const tags = getTags(exec)
const latestTag = tags.pop() || 'v0.0.0'
return compareVersions(latestTag, nextVersion) === -1
}
}
const parseVersion = (tag: string) => {
const version = tag.startsWith('v') ? tag.slice(1) : tag
const [main, pre] = version.split('-')
const [major, minor, patch] = main.split('.').map(Number)
return { major, minor, patch, pre }
}
const getBranch = (exec: any): string => {
return exec('git rev-parse --abbrev-ref HEAD', {
silent: true
}).stdout.trim()
}
const getTags = (exec: any) => {
exec('git fetch --tags', { silent: true })
const tagsOutput = exec('git tag', { silent: true }).stdout.trim()
const tags: string[] = tagsOutput ? tagsOutput.split('\n') : []
return tags.filter((tag) => tag.startsWith('v')).sort(compareVersions)
}
const compareVersions = (a: string, b: string) => {
const va = parseVersion(a)
const vb = parseVersion(b)
if (va.major !== vb.major) {
return va.major - vb.major
}
if (va.minor !== vb.minor) {
return va.minor - vb.minor
}
if (va.patch !== vb.patch) {
return va.patch - vb.patch
}
if (va.pre && !vb.pre) {
return -1
}
if (!va.pre && vb.pre) {
return 1
}
if (va.pre && vb.pre) {
return va.pre.localeCompare(vb.pre)
}
return 0
}