Skip to content

Commit 1dac3e8

Browse files
QU3B1MAlexRuiz7
authored andcommitted
Save plugins and reporting repo hashes on workflow variable and updat… (#502)
* Save plugins and reporting repo hashes on workflow variable and update baptizer script to use it on package naming * Update GHA workflow to save hash on global variable * Update GHA to use env * Update GHA workflow to save the hash on a output variable * Fix environment variable usage * Update baptizer to receive the repositories hashes by parameter Update build GHA to send hashes by parameters to the baptizer script * Update build-scripts README.md with new baptizer parameters * Update build GHA workflow to show the URL of the uploaded package at the job view * Update GHA build workflow to always upload package to the S3 bucket Remove 'upload' check on workflow input * Restore upload input and corresponding validations * Remove commented lines
1 parent 1eea197 commit 1dac3e8

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

.github/workflows/build.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ jobs:
126126
runs-on: ubuntu-latest
127127
env:
128128
plugin_name: wazuh-indexer-${{ matrix.plugins }}
129+
outputs:
130+
hash: ${{ steps.save-hash.outputs.hash }}
129131
steps:
130132
- uses: actions/checkout@v4
131133
with:
@@ -151,6 +153,10 @@ jobs:
151153
- run: ls -lR build/distributions
152154
working-directory: ./plugins/${{ matrix.plugins }}
153155

156+
- name: Save commit hash
157+
id: save-hash
158+
run: echo "hash=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
159+
154160
- name: Upload artifact
155161
uses: actions/upload-artifact@v4
156162
with:
@@ -161,6 +167,8 @@ jobs:
161167
build-reporting-plugin:
162168
if: ${{ inputs.reporting_plugin_ref != '' }}
163169
runs-on: ubuntu-latest
170+
outputs:
171+
hash: ${{ steps.save-hash.outputs.hash }}
164172
env:
165173
plugin_name: wazuh-indexer-reports-scheduler
166174
steps:
@@ -186,6 +194,10 @@ jobs:
186194

187195
- run: ls -lR build/distributions
188196

197+
- name: Save commit hash
198+
id: save-hash
199+
run: echo "hash=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
200+
189201
- name: Upload artifact
190202
uses: actions/upload-artifact@v4
191203
with:
@@ -233,6 +245,8 @@ jobs:
233245
-a ${{ matrix.architecture }} \
234246
-d ${{ matrix.distribution }} \
235247
-r ${{ inputs.revision }} \
248+
-l ${{ needs.build-wazuh-plugins.outputs.hash }} \
249+
-e ${{ needs.build-reporting-plugin.outputs.hash }} \
236250
${{ inputs.is_stage && '-x' || '' }} \
237251
)
238252
echo "name=$name" >> $GITHUB_OUTPUT
@@ -244,6 +258,8 @@ jobs:
244258
-a ${{ matrix.architecture }} \
245259
-d ${{ matrix.distribution }} \
246260
-r ${{ inputs.revision }} \
261+
-l ${{ needs.build-wazuh-plugins.outputs.hash }} \
262+
-e ${{ needs.build-reporting-plugin.outputs.hash }} \
247263
${{ inputs.is_stage && '-x' || '' }} \
248264
)
249265
echo "name=$name" >> $GITHUB_OUTPUT
@@ -299,7 +315,7 @@ jobs:
299315
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/"
300316
aws s3 cp "$src" "$dest"
301317
s3uri="${dest}${{ steps.package.outputs.name }}"
302-
echo "S3 URI: ${s3uri}"
318+
echo "::notice::S3 URI: ${s3uri}"
303319
304320
- name: Upload checksum to S3
305321
if: ${{ inputs.upload && inputs.checksum }}
@@ -308,4 +324,4 @@ jobs:
308324
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/5.x/main/packages/"
309325
aws s3 cp "$src" "$dest"
310326
s3uri="${dest}${{ steps.package.outputs.name }}.sha512"
311-
echo "S3 sha512 URI: ${s3uri}"
327+
echo "::notice::S3 sha512 URI: ${s3uri}"

build-scripts/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> [!CAUTION]
44
>
5-
> Be aware that there might be some problems while following the steps in this guide due to outdated information.
5+
> Be aware that there might be some problems while following the steps in this guide due to outdated information.
66
> This document is pending a review. Let us know if you find any issues.
77
88
The packages' generation process consists on 2 steps:
@@ -235,7 +235,7 @@ them, as well as their inputs and outputs.
235235
scripts:
236236
- file: build.sh
237237
description: |
238-
generates a distribution package by running the appropiate Gradle task
238+
generates a distribution package by running the appropiate Gradle task
239239
depending on the parameters.
240240
inputs:
241241
architecture: [x64, arm64] # Note: we only build x86_64 packages
@@ -246,7 +246,7 @@ scripts:
246246

247247
- file: assemble.sh
248248
description: |
249-
bundles the wazuh-indexer package generated in by build.sh with plugins,
249+
bundles the wazuh-indexer package generated in by build.sh with plugins,
250250
configuration files and demo certificates (certificates yet to come).
251251
inputs:
252252
architecture: [x64, arm64] # Note: we only build x86_64 packages
@@ -264,6 +264,8 @@ scripts:
264264
architecture: [x64, arm64] # Note: we only build x86_64 packages
265265
distribution: [tar, deb, rpm]
266266
revision: revision number. 0 by default.
267+
plugins_hash: Commit hash of the `wazuh-indexer-plugins` repository.
268+
reporting_hash: Commit hash of the `wazuh-indexer-reporting` repository.
267269
is_release: if set, uses release naming convention.
268270
is_min: if set, the package name will start by `wazuh-indexer-min`. Used on the build stage.
269271
outputs:

build-scripts/baptizer.sh

+18-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ function usage() {
1010
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'."
1111
echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'."
1212
echo -e "-r REVISION\t[Optional] Package revision, default is '0'."
13+
echo -e "-l PLUGINS_HASH\t[Optional] Commit hash from the wazuh-indexer-plugins repository"
14+
echo -e "-e REPORTING_HASH\t[Optional] Commit hash from the wazuh-indexer-reporting repository"
1315
echo -e "-m MIN\t[Optional] Use naming convention for minimal packages, default is 'false'."
1416
echo -e "-x RELEASE\t[Optional] Use release naming convention, default is 'false'."
1517
echo -e "-h help"
@@ -20,7 +22,7 @@ function usage() {
2022
# ====
2123
function parse_args() {
2224

23-
while getopts ":h:p:a:d:r:mx" arg; do
25+
while getopts ":h:p:a:d:r:l:e:mx" arg; do
2426
case $arg in
2527
h)
2628
usage
@@ -38,6 +40,12 @@ function parse_args() {
3840
r)
3941
REVISION=$OPTARG
4042
;;
43+
l)
44+
PLUGINS_HASH=$OPTARG
45+
;;
46+
e)
47+
REPORTING_HASH=$OPTARG
48+
;;
4149
m)
4250
IS_MIN=true
4351
;;
@@ -122,11 +130,17 @@ function get_release_name() {
122130
# Naming convention for pre-release packages
123131
# ====
124132
function get_devel_name() {
133+
PREFIX=wazuh-indexer
134+
COMMIT_HASH=$GIT_COMMIT
135+
# Add -min to the prefix if corresponds
125136
if "$IS_MIN"; then
126-
PACKAGE_NAME=wazuh-indexer-min_"$VERSION"-"$REVISION"_"$SUFFIX"_"$GIT_COMMIT"."$EXT"
127-
else
128-
PACKAGE_NAME=wazuh-indexer_"$VERSION"-"$REVISION"_"$SUFFIX"_"$GIT_COMMIT"."$EXT"
137+
PREFIX="$PREFIX"-min
138+
fi
139+
# Generate composed commit hash
140+
if [ -n "$PLUGINS_HASH" ] && [ -n "$REPORTING_HASH" ]; then
141+
COMMIT_HASH="$GIT_COMMIT"-"$PLUGINS_HASH"-"$REPORTING_HASH"
129142
fi
143+
PACKAGE_NAME="$PREFIX"_"$VERSION"-"$REVISION"_"$SUFFIX"_"$COMMIT_HASH"."$EXT"
130144
}
131145

132146
# ====

0 commit comments

Comments
 (0)