Skip to content

Commit 9b2e6ce

Browse files
committed
edit checks to run the release workflow
1 parent d102457 commit 9b2e6ce

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

.github/release-drafter.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@ categories:
66
- title: 🐛 Bug Fixes
77
label: 'bug'
88
- title: 🛠 Internal Changes
9-
label: 'maintenance'
9+
labels:
10+
- 'maintenance'
11+
- 'schema'
12+
- 'documentation'
13+
- 'python'
1014
- title: 🔍 Hunting Updates
11-
label: 'hunting'
15+
label: 'Hunting'
1216
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
1317
exclude-labels:
1418
- 'skip-changelog'
19+
version-resolver:
20+
major:
21+
labels:
22+
- 'major'
23+
minor:
24+
labels:
25+
- 'minor'
26+
patch:
27+
labels:
28+
- 'patch'
29+
default: patch
1530
template: |
1631
## Changes
1732
$CHANGES

.github/workflows/version-code-and-release.yml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,58 @@ on:
1010
- 'docs/**'
1111
- 'detection_rules/**'
1212
- 'tests/**'
13+
- '**/*.md'
1314
types: [opened, reopened, synchronize]
14-
push:
15-
branches:
16-
- main
1715

1816
permissions:
19-
contents: write
20-
pull-requests: write
17+
contents: read
18+
pull-requests: read
2119

2220
jobs:
23-
version_check:
21+
label_check:
2422
runs-on: ubuntu-latest
23+
steps:
24+
- name: Ensure PR has Version Bump Label
25+
uses: actions/github-script@v6
26+
with:
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
script: |
29+
const labels = ['major', 'minor', 'patch'];
30+
const prLabels = context.payload.pull_request.labels.map(label => label.name);
31+
const hasVersionLabel = labels.some(label => prLabels.includes(label));
32+
if (!hasVersionLabel) {
33+
throw new Error("PR must have one of the following labels: major, minor, or patch.");
34+
}
2535
36+
version_check:
37+
needs: label_check
38+
runs-on: ubuntu-latest
2639
steps:
2740
- name: Checkout repository
2841
uses: actions/checkout@v4
2942

30-
- name: Check for changes in kql, kibana, hunting, and etc
31-
id: check_changes
43+
- name: Check if core pyproject.toml was updated
3244
run: |
33-
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql|lib/kibana|detection_rules|tests|hunting|etc/' || echo "no-changes")
34-
if [ "$CHANGED_FILES" != "no-changes" ]; then
35-
echo "CHANGES_FOUND=true" >> $GITHUB_ENV
36-
else
37-
echo "CHANGES_FOUND=false" >> $GITHUB_ENV
45+
if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^pyproject.toml$'; then
46+
echo "Code changes detected in core, but pyproject.toml was not updated."
47+
exit 1
3848
fi
3949
40-
- name: Fail if no version bump in pyproject.toml
41-
if: env.CHANGES_FOUND == 'true'
50+
- name: Check if lib pyproject.toml files were updated
4251
run: |
43-
if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'pyproject.toml'; then
44-
echo "Code changes detected in core, but pyproject.toml was not updated."
45-
exit 1
52+
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql/|lib/kibana/'; then
53+
if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -E 'lib/kql/pyproject.toml|lib/kibana/pyproject.toml'; then
54+
echo "Changes detected in kql or kibana library, but respective pyproject.toml was not updated."
55+
exit 1
56+
fi
4657
fi
4758
4859
release_drafter:
60+
if: github.event.pull_request.merged == true && needs.version_check.conclusion == 'success'
4961
needs: version_check
5062
runs-on: ubuntu-latest
51-
63+
permissions:
64+
contents: write
5265
steps:
5366
- name: Checkout repository
5467
uses: actions/checkout@v4

0 commit comments

Comments
 (0)