-
Notifications
You must be signed in to change notification settings - Fork 14
52 lines (44 loc) · 1.44 KB
/
release-label-check.yml
File metadata and controls
52 lines (44 loc) · 1.44 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
name: Release Label Check
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
permissions:
contents: read
pull-requests: read
jobs:
validate_release_labels:
runs-on: ubuntu-latest
steps:
- name: Validate release labels
uses: actions/github-script@v7
with:
script: |
const labels = (context.payload.pull_request?.labels || []).map((l) => l.name);
const categoryLabels = new Set([
'feature',
'bug',
'performance',
'documentation',
'dependencies',
'refactor',
'test',
'chore',
'skip-changelog',
]);
const semverLabels = new Set(['semver:major', 'semver:minor', 'semver:patch']);
const hasCategory = labels.some((label) => categoryLabels.has(label));
const semverCount = labels.filter((label) => semverLabels.has(label)).length;
if (!hasCategory) {
core.setFailed(
'Missing release category label. Add one of: feature, bug, performance, documentation, dependencies, refactor, test, chore, skip-changelog.'
);
return;
}
if (semverCount > 1) {
core.setFailed('Use at most one semver label: semver:major, semver:minor, or semver:patch.');
}