Skip to content

Commit 0cb571e

Browse files
committed
fix changelogs
1 parent 6fba79f commit 0cb571e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

.github/scripts/update_chart_files.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ def update_chart_yaml(chart_folder, new_version, old_version):
123123
)
124124

125125
if "artifacthub.io/changes:" in chart_content:
126-
# Append to existing changes - add after the annotation line
126+
# Replace the entire artifacthub.io/changes section with just the new entry
127+
# This removes old comments and replaces with the current update
127128
chart_content = re.sub(
128-
r"(artifacthub\.io/changes:\s*\|)",
129+
r"(artifacthub\.io/changes:\s*\|)\s*\n\s*-.*?(?=\n\s{2}[a-z]|\n\s{0,1}$|\Z)",
129130
rf"\1\n {changes_entry}",
130131
chart_content,
132+
flags=re.MULTILINE | re.DOTALL,
131133
)
132134
else:
133135
# Add new annotation if it doesn't exist
@@ -155,17 +157,18 @@ def update_changelog(
155157
return
156158

157159
current_date = datetime.utcnow().strftime("%Y-%m-%d")
158-
changelog_entry = f"## [{new_chart_version}] - {current_date}\n\n### Updated\n- Updated application from {old_version} to {new_version}\n\n"
160+
changelog_entry = f"## [{new_chart_version}] - {current_date}\n\n### Updated\n- Updated application from {old_version} to {new_version}\n"
159161

160162
changelog_path = f"charts/{chart_folder}/CHANGELOG.md"
161163
if os.path.exists(changelog_path):
162164
with open(changelog_path, "r") as f:
163165
changelog_content = f.read()
164166

165-
# Insert new entry after the main heading
167+
# Insert new entry right after the header section (after the format/versioning explanation)
168+
# Find the first ## (version header) and insert before it
166169
changelog_content = re.sub(
167-
r"(# Changelog\n\n.*?\n\n)",
168-
rf"\1{changelog_entry}",
170+
r"(# Changelog\n\nAll notable.*?\n\nThe format.*?\n\n)(## \[)",
171+
rf"\1{changelog_entry}\2",
169172
changelog_content,
170173
count=1,
171174
flags=re.DOTALL,

0 commit comments

Comments
 (0)