Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 58 additions & 58 deletions .github/workflows/update-releasenotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,64 +64,64 @@ jobs:
VERSION_HEADER="# NuGet Version ${CURRENT_VERSION}"

python3 - <<'PYEOF'
import os, sys

file_path = os.environ['FILE']
ver_header = os.environ['VERSION_HEADER']
section = os.environ['SECTION']
pr_number = os.environ['PR_NUMBER']
pr_title = os.environ['PR_TITLE']
entry = f"#{pr_number} {pr_title}<br/>"

with open(file_path, 'r') as f:
content = f.read()
lines = content.splitlines(keepends=True)

# Find the version block and insert the entry
result = []
in_version_block = False
section_found = False
inserted = False

for i, line in enumerate(lines):
stripped = line.rstrip('\n')

if stripped == ver_header:
in_version_block = True
result.append(line)
continue

if in_version_block and stripped.startswith('# NuGet Version ') and stripped != ver_header:
# Reached next version block without finding/creating section
if not inserted:
result.append('\n' + section + ':\n\n' + entry + '\n\n')
inserted = True
in_version_block = False
result.append(line)
continue

if in_version_block and not inserted and stripped == section + ':':
section_found = True
result.append(line)
continue

if section_found and not inserted:
# Insert after the blank line following the section heading
if stripped == '':
result.append(line)
result.append(entry + '\n')
inserted = True
continue

result.append(line)

# If we reached EOF still inside the version block
if in_version_block and not inserted:
result.append('\n' + section + ':\n\n' + entry + '\n')

with open(file_path, 'w') as f:
f.writelines(result)
PYEOF
import os, sys

file_path = os.environ['FILE']
ver_header = os.environ['VERSION_HEADER']
section = os.environ['SECTION']
pr_number = os.environ['PR_NUMBER']
pr_title = os.environ['PR_TITLE']
entry = f"#{pr_number} {pr_title}<br/>"

with open(file_path, 'r') as f:
content = f.read()
lines = content.splitlines(keepends=True)

# Find the version block and insert the entry
result = []
in_version_block = False
section_found = False
inserted = False

for i, line in enumerate(lines):
stripped = line.rstrip('\n')

if stripped == ver_header:
in_version_block = True
result.append(line)
continue

if in_version_block and stripped.startswith('# NuGet Version ') and stripped != ver_header:
# Reached next version block without finding/creating section
if not inserted:
result.append('\n' + section + ':\n\n' + entry + '\n\n')
inserted = True
in_version_block = False
result.append(line)
continue

if in_version_block and not inserted and stripped == section + ':':
section_found = True
result.append(line)
continue

if section_found and not inserted:
# Insert after the blank line following the section heading
if stripped == '':
result.append(line)
result.append(entry + '\n')
inserted = True
continue

result.append(line)

# If we reached EOF still inside the version block
if in_version_block and not inserted:
result.append('\n' + section + ':\n\n' + entry + '\n')

with open(file_path, 'w') as f:
f.writelines(result)
PYEOF

- name: Commit and push
shell: bash
Expand Down
Loading