@@ -59,65 +59,20 @@ jobs:
5959 let categories = {};
6060 let allVersions = [];
6161
62+ // For init mode, just parse UNRELEASED as the initial version
6263 if (initMode) {
63- // Parse all versions for initialization
64- let currentVersion = null;
65- let currentVersionContent = {};
66- let inVersionSection = false;
67-
68- for (let i = 0; i < lines.length; i++) {
69- const line = lines[i].trim();
70-
71- // Look for version headers (## [version] - date or ## version - date or ## version)
72- const versionMatch = line.match(/^##\s*(?:\[([^\]]+)\](?:\s*-\s*(.+))?|([^-\s]+)(?:\s*-\s*(.+))?)/);
73-
74- if (versionMatch && line !== '## UNRELEASED') {
75- // Save previous version if exists
76- if (currentVersion && Object.keys(currentVersionContent).length > 0) {
77- allVersions.push({
78- version: currentVersion,
79- date: currentVersionDate || 'Unknown',
80- categories: currentVersionContent
81- });
82- }
83-
84- currentVersion = versionMatch[1] || versionMatch[3];
85- var currentVersionDate = versionMatch[2] || versionMatch[4];
86- currentVersionContent = {};
87- currentCategory = null;
88- inVersionSection = true;
89- continue;
90- }
91-
92- // Skip UNRELEASED section for init mode
93- if (line === '## UNRELEASED') {
94- inVersionSection = false;
95- continue;
96- }
97-
98- // Look for category headers (### CATEGORY)
99- if (inVersionSection && line.startsWith('### ')) {
100- currentCategory = line.replace('### ', '').trim();
101- currentVersionContent[currentCategory] = [];
102- continue;
103- }
104-
105- // Collect content under each category
106- if (inVersionSection && currentCategory && line && !line.startsWith('#')) {
107- currentVersionContent[currentCategory].push(line);
108- }
64+ const result = parseChangelog(content, releaseTag, false);
65+ if (result.hasContent) {
66+ return {
67+ allVersions: [{
68+ version: releaseTag,
69+ date: new Date().toISOString().split('T')[0],
70+ categories: result.categories
71+ }],
72+ hasContent: true
73+ };
10974 }
110-
111- // Don't forget the last version
112- if (currentVersion && Object.keys(currentVersionContent).length > 0) {
113- allVersions.push({
114- version: currentVersion,
115- date: currentVersionDate || 'Unknown',
116- categories: currentVersionContent
117- });
118- }
119-
120- return { allVersions, hasContent: allVersions.length > 0 };
75+ return { allVersions: [], hasContent: false };
12176 }
12277
12378 // Original single version parsing for regular updates
@@ -321,7 +276,7 @@ jobs:
321276 EOF
322277
323278 # Check if this is initialization mode (changelog file doesn't exist)
324- CHANGELOG_FILE="docs/evm/ changelog.mdx"
279+ CHANGELOG_FILE="docs/changelog/release-notes .mdx"
325280 if [ ! -f "$CHANGELOG_FILE" ]; then
326281 echo "Initializing changelog with all previous versions..."
327282 node parse_changelog.js "${{ steps.fetch-changelog.outputs.release_tag }}" init
@@ -332,7 +287,7 @@ jobs:
332287
333288 - name : Update changelog file
334289 run : |
335- CHANGELOG_FILE="docs/evm/ changelog.mdx"
290+ CHANGELOG_FILE="docs/changelog/release-notes .mdx"
336291 UPDATE_CONTENT=$(cat /tmp/update_component.mdx)
337292
338293 # Check if the changelog file exists
@@ -343,11 +298,11 @@ jobs:
343298
344299 # Create the file with proper YAML front matter using printf
345300 printf '%s\n' '---' > "$CHANGELOG_FILE"
346- printf '%s\n' 'title: "EVM Changelog"' >> "$CHANGELOG_FILE"
347- printf '%s\n' 'description: "Track changes and updates to the Cosmos EVM "' >> "$CHANGELOG_FILE"
301+ printf '%s\n' 'title: "Changelog"' >> "$CHANGELOG_FILE"
302+ printf '%s\n' 'description: "Follows the \`CHANGELOG.md\` for \`cosmos/evm\` "' >> "$CHANGELOG_FILE"
348303 printf '%s\n' '---' >> "$CHANGELOG_FILE"
349304 printf '\n' >> "$CHANGELOG_FILE"
350- printf '%s\n' '# EVM Changelog' >> "$CHANGELOG_FILE"
305+ printf '%s\n' '# Changelog' >> "$CHANGELOG_FILE"
351306 printf '\n' >> "$CHANGELOG_FILE"
352307 printf '%s\n' 'This page tracks all releases and changes to the Cosmos EVM module.' >> "$CHANGELOG_FILE"
353308 printf '\n' >> "$CHANGELOG_FILE"
@@ -359,22 +314,43 @@ jobs:
359314 # Find the insertion point (after the front matter and title)
360315 # Insert the new update at the top of the changelog entries
361316 awk -v update="$UPDATE_CONTENT" '
362- BEGIN { found_title = 0; inserted = 0 }
363- /^# / && found_title == 0 {
364- print $0
365- print ""
366- print update
367- inserted = 1
368- found_title = 1
317+ BEGIN { found_header = 0; found_intro = 0; inserted = 0 }
318+
319+ # Skip frontmatter
320+ /^---$/ && NR == 1 { in_frontmatter = 1; print; next }
321+ /^---$/ && in_frontmatter { in_frontmatter = 0; print; next }
322+ in_frontmatter { print; next }
323+
324+ # Find the main title
325+ /^# / && !found_header {
326+ print
327+ found_header = 1
369328 next
370329 }
371- /^<Update/ && inserted == 0 {
372- print update
373- inserted = 1
330+
331+ # After title, look for intro text or existing Update
332+ found_header && !inserted {
333+ if (/^This page tracks/ || /^$/) {
334+ print
335+ if (/^This page tracks/) found_intro = 1
336+ if (found_intro && /^$/) {
337+ print update
338+ inserted = 1
339+ }
340+ } else if (/^<Update/) {
341+ print update
342+ print
343+ inserted = 1
344+ } else {
345+ print
346+ }
347+ next
374348 }
349+
375350 { print }
351+
376352 END {
377- if (inserted == 0 ) {
353+ if (! inserted) {
378354 print ""
379355 print update
380356 }
@@ -388,7 +364,7 @@ jobs:
388364 git config --local user.email "[email protected] " 389365 git config --local user.name "GitHub Action"
390366
391- git add docs/evm/ changelog.mdx
367+ git add docs/changelog/release-notes .mdx
392368
393369 if git diff --staged --quiet; then
394370 echo "No changes to commit"
0 commit comments