@@ -28,162 +28,128 @@ on:
28
28
type : choice
29
29
description : ' New Package'
30
30
required : true
31
+ default : " true"
31
32
options :
32
33
- " true"
33
34
- " false"
34
- add_historical :
35
- type : choice
36
- description : ' Add Historical Rules'
37
- required : true
38
- options :
39
- - " yes"
40
- - " no"
41
- commit_hash :
42
- description : ' Commit hash'
43
- required : true
44
35
45
36
jobs :
46
- check-commit :
47
- name : Check Commit Hash
48
- runs-on : ubuntu-latest
49
- outputs :
50
- is_locked_commit : ${{ steps.check_commit.outputs.check_message }}
51
- steps :
52
- - name : Checkout detection-rules
53
- uses : actions/checkout@v3
54
- with :
55
- path : detection-rules
56
- fetch-depth : 0
57
-
58
- - name : Check commit message
59
- id : check_commit
60
- env :
61
- COMMIT_HASH : " ${{github.event.inputs.commit_hash}}"
62
- run : |
63
- cd detection-rules
64
- COMMIT_MESSAGE=$(git show -s --format=%B $COMMIT_HASH | grep "Lock versions for releases" || true)
65
- if [ -z "$COMMIT_MESSAGE" ]; then
66
- echo "::set-output name=check_message::false"
67
- else
68
- echo "::set-output name=check_message::true"
69
- fi
70
- shell : bash
71
-
72
- fleet-pr :
73
- name : Fleet PR
74
- needs : check-commit
75
- if : needs.check-commit.outputs.is_locked_commit == 'true'
76
- runs-on : ubuntu-latest
77
- steps :
78
- - name : Validate the source branch
79
- uses : actions/github-script@v3
80
- with :
81
- script : |
82
- if ('refs/heads/main' === '${{github.ref}}') {
83
- core.setFailed('Forbidden branch')
84
- }
85
-
86
- - name : Checkout detection-rules
87
- uses : actions/checkout@v3
88
- with :
89
- path : detection-rules
90
- fetch-depth : 0
91
-
92
- - name : Checkout elastic/integrations
93
- uses : actions/checkout@v3
94
- with :
95
- token : ${{ secrets.READ_WRITE_RELEASE_FLEET }}
96
- repository : ${{github.event.inputs.target_repo}}
97
- path : integrations
98
-
99
- - name : Set up Python 3.8
100
- uses : actions/setup-python@v2
101
- with :
102
- python-version : 3.8
103
-
104
- - name : Install Python dependencies
105
- run : |
106
- cd detection-rules
107
- python -m pip install --upgrade pip
108
- pip cache purge
109
- pip install .[dev]
110
-
111
- - name : Checkout commit hash
112
- env :
113
- COMMIT_HASH : ${{github.event.inputs.commit_hash}}
114
- run : |
115
- cd detection-rules
116
- git checkout $COMMIT_HASH
117
-
118
- - name : Bump prebuilt rules package version
119
- env :
120
- PACKAGE_MATURITY : " ${{github.event.inputs.package_maturity}}"
121
- NEW_PACKAGE : " ${{github.event.inputs.new_package}}"
122
- run : |
123
- cd detection-rules
124
- python -m detection_rules dev bump-pkg-versions \
125
- --patch-release \
126
- --new-package $NEW_PACKAGE \
127
- --maturity $PACKAGE_MATURITY
128
-
129
- - name : Store release tag
130
- if : ${{github.event.inputs.package_maturity}} == "ga"
131
- id : packages-version
132
- run : |
133
- cd detection-rules
134
- output=$(cat detection_rules/etc/packages.yml | grep -oP '(?<=\sversion: )\S+')
135
- echo "::set-output name=pkg_version::$output"
136
-
137
- - name : Create release tag
138
- if : ${{github.event.inputs.package_maturity}} == "ga"
139
- env :
140
- RELEASE_TAG : " integration-v${{ steps.packages-version.outputs.pkg_version }}"
141
- run : |
142
- cd detection-rules
143
- git tag $RELEASE_TAG
144
- git push origin $RELEASE_TAG
145
-
146
- - name : Build release package
147
- env :
148
- HISTORICAL : " ${{github.event.inputs.add_historical}}"
149
- run : |
150
- cd detection-rules
151
- python -m detection_rules dev build-release --add-historical $HISTORICAL
152
-
153
- - name : Set github config
154
- run : |
155
- git config --global user.email "72879786+protectionsmachine@users.noreply.github.com"
156
- git config --global user.name "protectionsmachine"
157
-
158
- - name : Setup go
159
- uses : actions/setup-go@v3
160
- with :
161
- go-version : ' ^1.20.1'
162
- check-latest : true
163
-
164
- - name : Build elastic-package
165
- run : |
166
- go install github.com/elastic/elastic-package@latest
167
-
168
- - name : Create the PR to Integrations
169
- env :
170
- DRAFT_ARGS : " ${{startsWith(github.event.inputs.draft,'y') && '--draft' || ' '}}"
171
- TARGET_REPO : " ${{github.event.inputs.target_repo}}"
172
- TARGET_BRANCH : " ${{github.event.inputs.target_branch}}"
173
- LOCAL_REPO : " ../integrations"
174
- GITHUB_TOKEN : " ${{ secrets.READ_WRITE_RELEASE_FLEET }}"
175
- run : |
176
- cd detection-rules
177
- python -m detection_rules dev integrations-pr \
178
- $LOCAL_REPO \
179
- --github-repo $TARGET_REPO \
180
- --base-branch $TARGET_BRANCH \
181
- --assign ${{github.actor}} \
182
- $DRAFT_ARGS
183
-
184
- - name : Archive production artifacts
185
- uses : actions/upload-artifact@v3
186
- with :
187
- name : release-files
188
- path : |
189
- detection-rules/releases
37
+ fleet-pr :
38
+ name : Build package and create PR to integrations
39
+ runs-on : ubuntu-latest
40
+ steps :
41
+ - name : Validate the source branch
42
+ uses : actions/github-script@v3
43
+ with :
44
+ script : |
45
+ if ('refs/heads/main' === '${{github.ref}}') {
46
+ core.setFailed('Forbidden branch')
47
+ }
48
+ - name : Checkout detection-rules
49
+ uses : actions/checkout@v3
50
+ with :
51
+ path : detection-rules
52
+ fetch-depth : 0
53
+
54
+ - name : Extract version lock commit hash
55
+ run : |
56
+ cd detection-rules
57
+ COMMIT_HASH=$(git log --grep='Lock versions for releases' -1 --format='%H')
58
+ echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
59
+ echo "Extracted commit hash: $COMMIT_HASH"
60
+
61
+ - name : Checkout commit hash
62
+ run : |
63
+ cd detection-rules
64
+ echo "Current branch is $GITHUB_REF"
65
+ echo "Checking out commit hash $COMMIT_HASH"
66
+ git checkout $COMMIT_HASH
67
+
68
+ - name : Checkout elastic/integrations
69
+ uses : actions/checkout@v3
70
+ with :
71
+ token : ${{ secrets.READ_WRITE_RELEASE_FLEET }}
72
+ repository : ${{github.event.inputs.target_repo}}
73
+ path : integrations
74
+
75
+ - name : Set up Python 3.8
76
+ uses : actions/setup-python@v2
77
+ with :
78
+ python-version : 3.8
79
+
80
+ - name : Install Python dependencies
81
+ run : |
82
+ cd detection-rules
83
+ python -m pip install --upgrade pip
84
+ pip cache purge
85
+ pip install .[dev]
86
+
87
+ - name : Bump prebuilt rules package version
88
+ env :
89
+ PACKAGE_MATURITY : " ${{github.event.inputs.package_maturity}}"
90
+ NEW_PACKAGE : " ${{github.event.inputs.new_package}}"
91
+ run : |
92
+ cd detection-rules
93
+ python -m detection_rules dev bump-pkg-versions \
94
+ --patch-release \
95
+ --new-package $NEW_PACKAGE \
96
+ --maturity $PACKAGE_MATURITY
97
+
98
+ - name : Store release tag
99
+ if : github.event.inputs.package_maturity == 'ga'
100
+ run : |
101
+ cd detection-rules
102
+ output=$(cat detection_rules/etc/packages.yml | grep -oP '(?<=\sversion: )\S+')
103
+ echo "pkg_version=$output" >> $GITHUB_ENV
104
+
105
+ - name : Create release tag
106
+ if : github.event.inputs.package_maturity == 'ga'
107
+ run : |
108
+ cd detection-rules
109
+ RELEASE_TAG="integration-v${{ env.pkg_version }}"
110
+ echo "Creating release tag: $RELEASE_TAG"
111
+ git tag $RELEASE_TAG
112
+ git push origin $RELEASE_TAG
113
+
114
+ - name : Build release package
115
+ run : |
116
+ cd detection-rules
117
+ python -m detection_rules dev build-release
118
+
119
+ - name : Set github config
120
+ run : |
121
+ git config --global user.email "72879786+protectionsmachine@users.noreply.github.com"
122
+ git config --global user.name "protectionsmachine"
123
+
124
+ - name : Setup go
125
+ uses : actions/setup-go@v3
126
+ with :
127
+ go-version : ' ^1.20.1'
128
+ check-latest : true
129
+
130
+ - name : Build elastic-package
131
+ run : |
132
+ go install github.com/elastic/elastic-package@latest
133
+
134
+ - name : Create the PR to Integrations
135
+ env :
136
+ DRAFT_ARGS : " ${{startsWith(github.event.inputs.draft,'y') && '--draft' || ' '}}"
137
+ TARGET_REPO : " ${{github.event.inputs.target_repo}}"
138
+ TARGET_BRANCH : " ${{github.event.inputs.target_branch}}"
139
+ LOCAL_REPO : " ../integrations"
140
+ GITHUB_TOKEN : " ${{ secrets.READ_WRITE_RELEASE_FLEET }}"
141
+ run : |
142
+ cd detection-rules
143
+ python -m detection_rules dev integrations-pr \
144
+ $LOCAL_REPO \
145
+ --github-repo $TARGET_REPO \
146
+ --base-branch $TARGET_BRANCH \
147
+ --assign ${{github.actor}} \
148
+ $DRAFT_ARGS
149
+
150
+ - name : Archive production artifacts
151
+ uses : actions/upload-artifact@v3
152
+ with :
153
+ name : release-files
154
+ path : |
155
+ detection-rules/releases
0 commit comments