-
-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: show recent changes in nightly release (#5553)
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from datetime import datetime, timezone | ||
import os | ||
import subprocess | ||
import re | ||
|
||
LINE_REGEX = re.compile( | ||
r"""(?x) | ||
^(?P<commit>[A-Fa-f0-9]+)\s+ | ||
\( | ||
<(?P<email>[^>]+)>\s+ | ||
(?P<date>[^\s]+\s[^\s]+\s[^\s]+)\s+ | ||
(?P<line>\d+) | ||
\)\s | ||
(?P<content>.*)$ | ||
""" | ||
) | ||
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("<details><summary>More Changes</summary>\n") | ||
for _, line in unreleased_lines[5:]: | ||
print(line) | ||
print("</details>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,14 +389,25 @@ 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/[email protected] | ||
with: | ||
replacesArtifacts: true | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters