Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(release): preserve original release-note attachment bytes (#7255)

LearningCircuitf86c86439250
diff --git a/.github/scripts/shorten_release_notes.py b/.github/scripts/shorten_release_notes.py
index affa1fac2b..edf1e780ce 100644
--- a/.github/scripts/shorten_release_notes.py
+++ b/.github/scripts/shorten_release_notes.py
@@ -24,7 +24,12 @@ def shorten_release_notes(
Returns whether an asset was written. A body within the limit is untouched.
"""
- body = body_file.read_text(encoding="utf-8")
+ original_bytes = body_file.read_bytes()
+ # Normalize newlines only for the displayed excerpt, retaining the original
+ # bytes for the attachment and the existing character-budget behavior.
+ body = (
+ original_bytes.decode("utf-8").replace("\r\n", "\n").replace("\r", "\n")
+ )
if len(body) <= MAX_BODY_CHARS:
return False
if body_file.resolve() == full_asset_file.resolve():
@@ -54,7 +59,7 @@ def shorten_release_notes(
if len(shortened) > MAX_BODY_CHARS:
raise ValueError("Shortened release body still exceeds its limit")
- full_asset_file.write_text(body, encoding="utf-8")
+ full_asset_file.write_bytes(original_bytes)
body_file.write_text(shortened, encoding="utf-8")
return True
diff --git a/changelog.d/7206.bugfix.md b/changelog.d/7206.bugfix.md
new file mode 100644
index 0000000000..947f17dc2a
--- /dev/null
+++ b/changelog.d/7206.bugfix.md
@@ -0,0 +1 @@
+Full release-note attachments preserve the original line endings, including Windows and mixed-newline files.
diff --git a/tests/ci/test_shorten_release_notes.py b/tests/ci/test_shorten_release_notes.py
index 66f8ef47c5..427358309d 100644
--- a/tests/ci/test_shorten_release_notes.py
+++ b/tests/ci/test_shorten_release_notes.py
@@ -4,6 +4,8 @@ import subprocess
import sys
from pathlib import Path
+import pytest
+
SCRIPT = (
Path(__file__).resolve().parents[2]
@@ -66,3 +68,38 @@ def test_oversized_release_links_exact_complete_body(tmp_path):
assert published.count(ASSET_URL) == 2
assert "The final PR still appears in the asset" not in published
assert published.endswith(f"({ASSET_URL})._\n")
+
+
[email protected]("newline", ["\n", "\r\n", "\r", "\r\n\n"])
[email protected]("oversized", [False, True])
+def test_original_newline_bytes_are_preserved(tmp_path, newline, oversized):
+ body = tmp_path / "body.md"
+ asset = tmp_path / "release-notes-full.md"
+ paragraph = f"# Release notes{newline}{newline}- Migration: café. {newline}"
+ original = (paragraph * (7_000 if oversized else 1)).encode("utf-8")
+ body.write_bytes(original)
+
+ _prepare(body, asset)
+
+ if oversized:
+ assert asset.read_bytes() == original
+ published = body.read_text(encoding="utf-8")
+ assert len(published) <= 124_400
+ assert published.count(ASSET_URL) == 2
+ else:
+ assert body.read_bytes() == original
+ assert not asset.exists()
+
+
+def test_newline_bytes_do_not_change_shortening_threshold(tmp_path):
+ body = tmp_path / "body.md"
+ asset = tmp_path / "release-notes-full.md"
+ # CRLF makes this larger than the limit in bytes, but its normalized body
+ # is below the character budget and must remain untouched.
+ original = b"A line.\r\n" * 15_000
+ body.write_bytes(original)
+
+ _prepare(body, asset)
+
+ assert body.read_bytes() == original
+ assert not asset.exists()