-
Notifications
You must be signed in to change notification settings - Fork 516
81 lines (71 loc) · 2.5 KB
/
version-code-and-release.yml
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
name: Version Code Check and Draft Release
on:
pull_request:
paths:
- 'lib/**'
- 'hunting/**/*.py'
- 'pyproject.toml'
- 'Makefile'
- 'docs/**'
- 'detection_rules/**'
- 'tests/**'
- '**/*.md'
types: [opened, reopened, synchronize, labeled, closed]
permissions:
contents: read
pull-requests: read
jobs:
label_check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Ensure PR has Version Bump Label
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = ['major', 'minor', 'patch'];
const prLabels = context.payload.pull_request.labels.map(label => label.name);
const hasVersionLabel = labels.some(label => prLabels.includes(label));
if (!hasVersionLabel) {
throw new Error("PR must have one of the following labels: major, minor, or patch.");
}
version_check:
if: github.event_name == 'pull_request'
needs: label_check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if core pyproject.toml was updated
run: |
BASE_COMMIT="${{ github.event.pull_request.base.sha }}"
if ! git diff --name-only "$BASE_COMMIT" "$GITHUB_SHA" | grep '^pyproject.toml$'; then
echo "Code changes detected in core, but pyproject.toml was not updated."
exit 1
fi
- name: Check if lib pyproject.toml files were updated
run: |
BASE_COMMIT="${{ github.event.pull_request.base.sha }}"
if git diff --name-only "$BASE_COMMIT" "$GITHUB_SHA" | grep -E 'lib/kql/|lib/kibana/'; then
if ! git diff --name-only "$BASE_COMMIT" "$GITHUB_SHA" | grep -E 'lib/kql/pyproject.toml|lib/kibana/pyproject.toml'; then
echo "Changes detected in kql or kibana library, but respective pyproject.toml was not updated."
exit 1
fi
fi
release_drafter:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Release Drafter
uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}