diff --git a/.CI/format-recent-changes.py b/.CI/format-recent-changes.py new file mode 100644 index 000000000..630cfb85c --- /dev/null +++ b/.CI/format-recent-changes.py @@ -0,0 +1,61 @@ +from datetime import datetime, timezone +import os +import subprocess +import re + +LINE_REGEX = re.compile( + r"""(?x) +^(?P[A-Fa-f0-9]+)\s+ +\( + <(?P[^>]+)>\s+ + (?P[^\s]+\s[^\s]+\s[^\s]+)\s+ + (?P\d+) +\)\s +(?P.*)$ +""" +) +VERSION_REGEX = re.compile(r"^#+\s*v?\d") + +# contains lines in the form of +# {commit-sha} (<{email}>\s+{date}\s+{line-no}) {line} +p = subprocess.run( + ["git", "blame", "-e", "--date=iso", "../CHANGELOG.md"], + cwd=os.path.dirname(os.path.realpath(__file__)), + text=True, + check=True, + capture_output=True, +) + +unreleased_lines: list[tuple[datetime, str]] = [] +for line in p.stdout.splitlines(): + if not line: + continue + m = LINE_REGEX.match(line) + assert m, f"Failed to match '{line}'" + content = m.group("content") + + if not content: + continue + if content.startswith("#"): + if VERSION_REGEX.match(content): + break + continue # ignore lines with '#' + + d = datetime.fromisoformat(m.group("date")) + d = d.astimezone(tz=timezone.utc) + content = content.replace("- ", f"- [{d.strftime('%Y-%m-%d')}] ", 1) + unreleased_lines.append((d, content)) + +unreleased_lines.sort(key=lambda it: it[0], reverse=True) + +if len(unreleased_lines) == 0: + print("No changes since last release.") + +for _, line in unreleased_lines[:5]: + print(line) + +if len(unreleased_lines) > 5: + print("
More Changes\n") + for _, line in unreleased_lines[5:]: + print(line) + print("
") diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6ee06708..5975b94c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -389,6 +389,17 @@ jobs: working-directory: release-artifacts shell: bash + - name: Format changes + id: format-changes + run: | + delimiter=$(openssl rand -hex 32) + { + echo "changelog<<$delimiter" + python3 ./.CI/format-recent-changes.py + echo $delimiter + } >> "$GITHUB_OUTPUT" + shell: bash + - name: Create release uses: ncipollo/release-action@v1.14.0 with: @@ -396,7 +407,7 @@ jobs: allowUpdates: true artifactErrorsFailBuild: true artifacts: "release-artifacts/*" - body: ${{ github.event.head_commit.message }} + body: ${{ steps.format-changes.outputs.changelog }} prerelease: true name: Nightly Release tag: nightly-build diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a7c0744..5a2af1cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ - Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527) - Dev: Added `FlagsEnum::isEmpty`. (#5550) - Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529) +- Dev: Recent changes are now shown in the nightly release description. (#5553) ## 2.5.1