1
1
# mypy: disallow-untyped-defs
2
2
"""
3
- Script used to publish GitHub release notes extracted from CHANGELOG.rst.
3
+ Script used to generate a Markdown file containing only the changelog entries of a specific pytest release, which
4
+ is then published as a GitHub Release during deploy (see workflows/deploy.yml).
4
5
5
- This script is meant to be executed after a successful deployment in GitHub actions.
6
-
7
- Uses the following environment variables:
8
-
9
- * GIT_TAG: the name of the tag of the current commit.
10
- * GH_RELEASE_NOTES_TOKEN: a personal access token with 'repo' permissions.
11
-
12
- Create one at:
13
-
14
- https://github.com/settings/tokens
15
-
16
- This token should be set in a secret in the repository, which is exposed as an
17
- environment variable in the main.yml workflow file.
18
-
19
- The script also requires ``pandoc`` to be previously installed in the system.
6
+ The script requires ``pandoc`` to be previously installed in the system -- we need to convert from RST (the format of
7
+ our CHANGELOG) into Markdown (which is required by GitHub Releases).
20
8
21
9
Requires Python3.6+.
22
10
"""
28
16
import pypandoc
29
17
30
18
31
- def parse_changelog ( tag_name : str ) -> str :
19
+ def extract_changelog_entries_for ( version : str ) -> str :
32
20
p = Path (__file__ ).parent .parent / "doc/en/changelog.rst"
33
21
changelog_lines = p .read_text (encoding = "UTF-8" ).splitlines ()
34
22
@@ -38,10 +26,10 @@ def parse_changelog(tag_name: str) -> str:
38
26
for line in changelog_lines :
39
27
m = title_regex .match (line )
40
28
if m :
41
- # found the version we want: start to consume lines until we find the next version title
42
- if m .group (1 ) == tag_name :
29
+ # Found the version we want: start to consume lines until we find the next version title.
30
+ if m .group (1 ) == version :
43
31
consuming_version = True
44
- # found a new version title while parsing the version we want: break out
32
+ # Found a new version title while parsing the version we want: break out.
45
33
elif consuming_version :
46
34
break
47
35
if consuming_version :
@@ -65,7 +53,7 @@ def main(argv: Sequence[str]) -> int:
65
53
66
54
version , filename = argv [1 :3 ]
67
55
print (f"Generating GitHub release notes for version { version } " )
68
- rst_body = parse_changelog (version )
56
+ rst_body = extract_changelog_entries_for (version )
69
57
md_body = convert_rst_to_md (rst_body )
70
58
Path (filename ).write_text (md_body , encoding = "UTF-8" )
71
59
print ()
0 commit comments