@@ -136,9 +136,9 @@ update_changelog() {
136
136
# It looks for the block starting with "pluginPlatform": { and ending with }
137
137
# Within that block, it finds the line starting with "version": "..." and extracts the value.
138
138
# This is significantly less reliable than using jq.
139
- log " Attempting to extract .version from $VERSION_FILE using sed (Note: This is fragile)"
139
+ log " Attempting to extract .version from $PACKAGE_JSON using sed (Note: This is fragile)"
140
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)
141
+ OPENSEARCH_VERSION=$( sed -n ' /"opensearchDashboards": {/,/}/ s/^[[:space:]]*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*$/\1/p' " $PACKAGE_JSON " | head -n 1)
142
142
if [ -z " $OPENSEARCH_VERSION " ] || [ " $OPENSEARCH_VERSION " == " null" ]; then
143
143
log " ERROR: Could not extract pluginPlatform.version from $PACKAGE_JSON for changelog"
144
144
exit 1
@@ -157,7 +157,14 @@ update_changelog() {
157
157
if [ -n " $STAGE " ]; then
158
158
log " Changelog entry for this version and OpenSearch Dashboards version exists. Updating revision only."
159
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 " &&
160
+ # sed_inplace -E "s|(${changelog_header_regex})|${changelog_header}${REVISION}|" "$changelog_file" &&
161
+ if [[ " $OSTYPE " == " darwin" * ]]; then
162
+ sed -i ' ' -E " s|(${changelog_header_regex} )|## Wazuh dashboard v${VERSION} - OpenSearch Dashboards ${OPENSEARCH_VERSION} - Revision ${REVISION} |" " $changelog_file "
163
+ else
164
+ # Try -E first, fall back to -r if it fails
165
+ sed -i -E " s|(${changelog_header_regex} )|## Wazuh dashboard v${VERSION} - OpenSearch Dashboards ${OPENSEARCH_VERSION} - Revision ${REVISION} |" " $changelog_file " 2> /dev/null ||
166
+ sed -i -r " s|(${changelog_header_regex} )|## Wazuh dashboard v${VERSION} - OpenSearch Dashboards ${OPENSEARCH_VERSION} - Revision ${REVISION} |" " $changelog_file "
167
+ fi &&
161
168
log " CHANGELOG.md revision updated successfully." || {
162
169
log " ERROR: Failed to update revision in $changelog_file "
163
170
exit 1
@@ -169,7 +176,7 @@ update_changelog() {
169
176
# Create the new entry directly in the changelog using sed
170
177
local temp_file=$( mktemp)
171
178
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 "
179
+ printf " ## Wazuh dashboard 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
180
tail -n +5 " $changelog_file " >> " $temp_file "
174
181
175
182
mv " $temp_file " " $changelog_file " || {
0 commit comments