|
22 | 22 | "~/.github_api_key, see:\nhttps://help.github.com/en/github/" |
23 | 23 | "authenticating-to-github/creating-a-personal-access-token-" |
24 | 24 | "for-the-command-line") |
| 25 | + |
| 26 | +from esmvalcore import __version__ |
| 27 | + |
| 28 | +VERSION = f"v{__version__}" |
25 | 29 | GITHUB_REPO = "ESMValGroup/ESMValCore" |
26 | 30 |
|
| 31 | +TITLES = { |
| 32 | + 'bug': 'Bug fixes', |
| 33 | + 'enhancement': 'Improvements', |
| 34 | +} |
| 35 | + |
27 | 36 |
|
28 | 37 | def draft_notes_since(previous_release_date, labels): |
29 | 38 | """Draft release notes containing the merged pull requests. |
@@ -57,26 +66,34 @@ def draft_notes_since(previous_release_date, labels): |
57 | 66 |
|
58 | 67 | user = pull.user |
59 | 68 | username = user.login if user.name is None else user.name |
60 | | - line = (f"- {pull.title} (#{pull.number}) " |
61 | | - f"[{username}](https://github.com/{user.login})") |
| 69 | + line = ( |
| 70 | + f"- {pull.title} (`#{pull.number} " |
| 71 | + f"<https://github.com/{GITHUB_REPO}/pull/{pull.number}>`__) " |
| 72 | + f"`{username} <https://github.com/{user.login}>`__") |
62 | 73 | if label not in lines: |
63 | 74 | lines[label] = [] |
64 | 75 | lines[label].append((pull.closed_at, line)) |
65 | 76 |
|
66 | 77 | # Create sections |
67 | | - sections = ["This release includes"] |
| 78 | + sections = [ |
| 79 | + VERSION, |
| 80 | + '-' * len(VERSION), |
| 81 | + '', |
| 82 | + "This release includes", |
| 83 | + ] |
68 | 84 | for label in sorted(lines): |
69 | | - sections.append('\n' + label) |
70 | | - lines[label].sort() # sort by merge time |
71 | | - sections.append('\n'.join(line for _, line in lines[label])) |
| 85 | + entries = sorted(lines[label]) # sort by merge time |
| 86 | + label = TITLES.get(label, label) |
| 87 | + sections.append('\n'.join(['', label, '~' * len(label), ''])) |
| 88 | + sections.append('\n'.join(entry for _, entry in entries)) |
72 | 89 | notes = '\n'.join(sections) |
73 | 90 |
|
74 | 91 | print(notes) |
75 | 92 |
|
76 | 93 |
|
77 | 94 | if __name__ == '__main__': |
78 | 95 |
|
79 | | - PREVIOUS_RELEASE = datetime.datetime(2020, 1, 17) |
| 96 | + PREVIOUS_RELEASE = datetime.datetime(2020, 3, 6) |
80 | 97 | LABELS = ('bug', 'fix for dataset') |
81 | 98 |
|
82 | 99 | draft_notes_since(PREVIOUS_RELEASE, LABELS) |
0 commit comments