Skip to content

Commit 3475047

Browse files
committed
Fix repository bumper
1 parent e6f79b1 commit 3475047

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tools/repository_bumper.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ update_changelog() {
136136
# It looks for the block starting with "pluginPlatform": { and ending with }
137137
# Within that block, it finds the line starting with "version": "..." and extracts the value.
138138
# 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)"
140140
# 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)
142142
if [ -z "$OPENSEARCH_VERSION" ] || [ "$OPENSEARCH_VERSION" == "null" ]; then
143143
log "ERROR: Could not extract pluginPlatform.version from $PACKAGE_JSON for changelog"
144144
exit 1
@@ -157,7 +157,14 @@ update_changelog() {
157157
if [ -n "$STAGE" ]; then
158158
log "Changelog entry for this version and OpenSearch Dashboards version exists. Updating revision only."
159159
# 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 &&
161168
log "CHANGELOG.md revision updated successfully." || {
162169
log "ERROR: Failed to update revision in $changelog_file"
163170
exit 1
@@ -169,7 +176,7 @@ update_changelog() {
169176
# Create the new entry directly in the changelog using sed
170177
local temp_file=$(mktemp)
171178
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"
173180
tail -n +5 "$changelog_file" >>"$temp_file"
174181

175182
mv "$temp_file" "$changelog_file" || {

0 commit comments

Comments
 (0)