Skip to content

Commit e6f79b1

Browse files
committed
Add changelog
1 parent c93ebae commit e6f79b1

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 v5.0.0 - OpenSearch Dashboards 3.2.0 - Revision 00
6+
7+
### Added
8+
9+
- Support for Wazuh 5.0.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/5_builderpackage_ml_commons_plugin.yml"
1415
VERSION_FILE="${REPO_PATH}/VERSION.json"
1516
VERSION=""
@@ -124,6 +125,62 @@ update_json() {
124125
fi
125126
}
126127

128+
# Function to update CHANGELOG.md
129+
update_changelog() {
130+
log "Updating CHANGELOG.md..."
131+
local changelog_file="${REPO_PATH}/CHANGELOG.md"
132+
133+
# Extract OpenSearch Dashboards version from package.json
134+
# Attempt to extract OpenSearch Dashboards version using sed (WARNING: Fragile!)
135+
# This assumes "pluginPlatform": { ... "version": "x.y.z" ... } structure
136+
# It looks for the block starting with "pluginPlatform": { and ending with }
137+
# Within that block, it finds the line starting with "version": "..." and extracts the value.
138+
# This is significantly less reliable than using jq.
139+
log "Attempting to extract .version from $VERSION_FILE using sed (Note: This is fragile)"
140+
# Extract OpenSearch Dashboards version from package.json (first occurrence of "version")
141+
OPENSEARCH_VERSION=$(sed -n 's/^[[:space:]]*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*$/\1/p' "$PACKAGE_JSON" | head -n 1)
142+
if [ -z "$OPENSEARCH_VERSION" ] || [ "$OPENSEARCH_VERSION" == "null" ]; then
143+
log "ERROR: Could not extract pluginPlatform.version from $PACKAGE_JSON for changelog"
144+
exit 1
145+
fi
146+
log "Detected OpenSearch Dashboards version for changelog: $OPENSEARCH_VERSION"
147+
148+
# Construct the new changelog entry
149+
# Note: Using printf for better handling of newlines and potential special characters
150+
# Use the calculated REVISION variable here
151+
# Prepare the header to search for
152+
local changelog_header="## Wazuh dashboard v${VERSION} - OpenSearch Dashboards ${OPENSEARCH_VERSION} - Revision "
153+
local changelog_header_regex="^${changelog_header}[0-9]+"
154+
155+
# Check if an entry for this version and OpenSearch version already exists
156+
if grep -qE "$changelog_header_regex" "$changelog_file"; then
157+
if [ -n "$STAGE" ]; then
158+
log "Changelog entry for this version and OpenSearch Dashboards version exists. Updating revision only."
159+
# Use sed to update only the revision number in the header
160+
sed_inplace -E "s|(${changelog_header_regex})|${changelog_header}${REVISION}|" "$changelog_file" &&
161+
log "CHANGELOG.md revision updated successfully." || {
162+
log "ERROR: Failed to update revision in $changelog_file"
163+
exit 1
164+
}
165+
fi
166+
else
167+
log "No existing changelog entry for this version and OpenSearch Dashboards version. Inserting new entry."
168+
169+
# Create the new entry directly in the changelog using sed
170+
local temp_file=$(mktemp)
171+
head -n 4 "$changelog_file" >"$temp_file"
172+
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"
173+
tail -n +5 "$changelog_file" >>"$temp_file"
174+
175+
mv "$temp_file" "$changelog_file" || {
176+
log "ERROR: Failed to update $changelog_file"
177+
rm -f "$temp_file" # Clean up temp file on error
178+
exit 1
179+
}
180+
log "CHANGELOG.md updated successfully."
181+
fi
182+
}
183+
127184
# --- Core Logic Functions ---
128185

129186
parse_arguments() {
@@ -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)