Skip to content

Commit d483409

Browse files
committed
Add changelog
1 parent dae4a9f commit d483409

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Change Log
2+
3+
All notable changes to the Wazuh ML Commons project will be documented in this file.
4+
5+
## Wazuh dashboard v4.14.0 - OpenSearch Dashboards 2.19.3 - Revision 00
6+
7+
### Added
8+
9+
- Support for Wazuh 4.14.0
10+

tools/repository_bumper.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
REPO_PATH=$(git rev-parse --show-toplevel 2>/dev/null)
1111
DATE_TIME=$(date "+%Y-%m-%d_%H-%M-%S-%3N")
1212
LOG_FILE="${SCRIPT_PATH}/repository_bumper_${DATE_TIME}.log"
13+
PACKAGE_JSON="${REPO_PATH}/package.json"
1314
WAZUH_DASHBOARD_ML_COMMONS_WORKFLOW_FILE="${REPO_PATH}/.github/workflows/4_builderpackage_ml_commons_plugin.yml"
1415
VERSION_FILE="${REPO_PATH}/VERSION.json"
1516
VERSION=""
@@ -370,6 +371,62 @@ update_package_json() {
370371
fi
371372
}
372373

374+
# Function to update CHANGELOG.md
375+
update_changelog() {
376+
log "Updating CHANGELOG.md..."
377+
local changelog_file="${REPO_PATH}/CHANGELOG.md"
378+
379+
# Extract OpenSearch Dashboards version from package.json
380+
# Attempt to extract OpenSearch Dashboards version using sed (WARNING: Fragile!)
381+
# This assumes "pluginPlatform": { ... "version": "x.y.z" ... } structure
382+
# It looks for the block starting with "pluginPlatform": { and ending with }
383+
# Within that block, it finds the line starting with "version": "..." and extracts the value.
384+
# This is significantly less reliable than using jq.
385+
log "Attempting to extract .version from $VERSION_FILE using sed (Note: This is fragile)"
386+
# Extract OpenSearch Dashboards version from package.json (first occurrence of "version")
387+
OPENSEARCH_VERSION=$(sed -n 's/^[[:space:]]*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*$/\1/p' "$PACKAGE_JSON" | head -n 1)
388+
if [ -z "$OPENSEARCH_VERSION" ] || [ "$OPENSEARCH_VERSION" == "null" ]; then
389+
log "ERROR: Could not extract pluginPlatform.version from $PACKAGE_JSON for changelog"
390+
exit 1
391+
fi
392+
log "Detected OpenSearch Dashboards version for changelog: $OPENSEARCH_VERSION"
393+
394+
# Construct the new changelog entry
395+
# Note: Using printf for better handling of newlines and potential special characters
396+
# Use the calculated REVISION variable here
397+
# Prepare the header to search for
398+
local changelog_header="## Wazuh dashboard v${VERSION} - OpenSearch Dashboards ${OPENSEARCH_VERSION} - Revision "
399+
local changelog_header_regex="^${changelog_header}[0-9]+"
400+
401+
# Check if an entry for this version and OpenSearch version already exists
402+
if grep -qE "$changelog_header_regex" "$changelog_file"; then
403+
if [ -n "$STAGE" ]; then
404+
log "Changelog entry for this version and OpenSearch Dashboards version exists. Updating revision only."
405+
# Use sed to update only the revision number in the header
406+
sed_inplace -E "s|(${changelog_header_regex})|${changelog_header}${REVISION}|" "$changelog_file" &&
407+
log "CHANGELOG.md revision updated successfully." || {
408+
log "ERROR: Failed to update revision in $changelog_file"
409+
exit 1
410+
}
411+
fi
412+
else
413+
log "No existing changelog entry for this version and OpenSearch Dashboards version. Inserting new entry."
414+
415+
# Create the new entry directly in the changelog using sed
416+
local temp_file=$(mktemp)
417+
head -n 4 "$changelog_file" >"$temp_file"
418+
printf "\n## Wazuh v%s - OpenSearch Dashboards %s - Revision %s\n\n### Added\n\n- Support for Wazuh %s\n\n" "$VERSION" "$OPENSEARCH_VERSION" "$REVISION" "$VERSION" >>"$temp_file"
419+
tail -n +5 "$changelog_file" >>"$temp_file"
420+
421+
mv "$temp_file" "$changelog_file" || {
422+
log "ERROR: Failed to update $changelog_file"
423+
rm -f "$temp_file" # Clean up temp file on error
424+
exit 1
425+
}
426+
log "CHANGELOG.md updated successfully."
427+
fi
428+
}
429+
373430
update_manual_build_workflow() {
374431
local WORKFLOW_FILE="$WAZUH_DASHBOARD_ML_COMMONS_WORKFLOW_FILE"
375432
if [ -f "$WORKFLOW_FILE" ]; then
@@ -489,6 +546,7 @@ main() {
489546

490547
update_root_version_json
491548
update_package_json
549+
update_changelog
492550
update_manual_build_workflow
493551

494552
# Update docker/imposter/wazuh-config.yml

0 commit comments

Comments
 (0)