Skip to content

Commit 4d0ac15

Browse files
authored
ci: show recent changes in nightly release (#5553)
1 parent 998920d commit 4d0ac15

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

.CI/format-recent-changes.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from datetime import datetime, timezone
2+
import os
3+
import subprocess
4+
import re
5+
6+
LINE_REGEX = re.compile(
7+
r"""(?x)
8+
^(?P<commit>[A-Fa-f0-9]+)\s+
9+
\(
10+
<(?P<email>[^>]+)>\s+
11+
(?P<date>[^\s]+\s[^\s]+\s[^\s]+)\s+
12+
(?P<line>\d+)
13+
\)\s
14+
(?P<content>.*)$
15+
"""
16+
)
17+
VERSION_REGEX = re.compile(r"^#+\s*v?\d")
18+
19+
# contains lines in the form of
20+
# {commit-sha} (<{email}>\s+{date}\s+{line-no}) {line}
21+
p = subprocess.run(
22+
["git", "blame", "-e", "--date=iso", "../CHANGELOG.md"],
23+
cwd=os.path.dirname(os.path.realpath(__file__)),
24+
text=True,
25+
check=True,
26+
capture_output=True,
27+
)
28+
29+
unreleased_lines: list[tuple[datetime, str]] = []
30+
for line in p.stdout.splitlines():
31+
if not line:
32+
continue
33+
m = LINE_REGEX.match(line)
34+
assert m, f"Failed to match '{line}'"
35+
content = m.group("content")
36+
37+
if not content:
38+
continue
39+
if content.startswith("#"):
40+
if VERSION_REGEX.match(content):
41+
break
42+
continue # ignore lines with '#'
43+
44+
d = datetime.fromisoformat(m.group("date"))
45+
d = d.astimezone(tz=timezone.utc)
46+
content = content.replace("- ", f"- [{d.strftime('%Y-%m-%d')}] ", 1)
47+
unreleased_lines.append((d, content))
48+
49+
unreleased_lines.sort(key=lambda it: it[0], reverse=True)
50+
51+
if len(unreleased_lines) == 0:
52+
print("No changes since last release.")
53+
54+
for _, line in unreleased_lines[:5]:
55+
print(line)
56+
57+
if len(unreleased_lines) > 5:
58+
print("<details><summary>More Changes</summary>\n")
59+
for _, line in unreleased_lines[5:]:
60+
print(line)
61+
print("</details>")

.github/workflows/build.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -389,14 +389,25 @@ jobs:
389389
working-directory: release-artifacts
390390
shell: bash
391391

392+
- name: Format changes
393+
id: format-changes
394+
run: |
395+
delimiter=$(openssl rand -hex 32)
396+
{
397+
echo "changelog<<$delimiter"
398+
python3 ./.CI/format-recent-changes.py
399+
echo $delimiter
400+
} >> "$GITHUB_OUTPUT"
401+
shell: bash
402+
392403
- name: Create release
393404
uses: ncipollo/[email protected]
394405
with:
395406
replacesArtifacts: true
396407
allowUpdates: true
397408
artifactErrorsFailBuild: true
398409
artifacts: "release-artifacts/*"
399-
body: ${{ github.event.head_commit.message }}
410+
body: ${{ steps.format-changes.outputs.changelog }}
400411
prerelease: true
401412
name: Nightly Release
402413
tag: nightly-build

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
6969
- Dev: Added `FlagsEnum::isEmpty`. (#5550)
7070
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)
71+
- Dev: Recent changes are now shown in the nightly release description. (#5553)
7172

7273
## 2.5.1
7374

0 commit comments

Comments
 (0)