From 2b9e04cd1993b17b51b4ebb6cb4dd8396387f159 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 24 Sep 2024 17:03:08 +0100 Subject: [PATCH] Allow custom filenames for changelog command (#247) --- docs/tools.md | 8 ++++++++ samples/integration/nox.txt | 2 ++ samples/integration/typeshed.txt | 2 -- src/mk/tools/pre.py | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/tools.md b/docs/tools.md index 0f46288..43f9ae2 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -69,3 +69,11 @@ basic commands: If a [pytest](https://docs.pytest.org/en/stable/) configuration file is found, a `test` command will be exposed that runs `pytest`. + +## changelog (github) + +`changelog` command will produce a `CHANGELOG.md` file based on Github Releases. +You can define `CHANGELOG_FILE` environment variable to make it generate the +file in a different location. + +This command is available only when `gh` command line utility is installed. diff --git a/samples/integration/nox.txt b/samples/integration/nox.txt index 8cb0d4a..fb1d8ce 100644 --- a/samples/integration/nox.txt +++ b/samples/integration/nox.txt @@ -16,6 +16,8 @@ tests(python='3.11', tox_version='<4') tests(python='3.11', tox_version='latest') tests(python='3.12', tox_version='<4') tests(python='3.12', tox_version='latest') +tests(python='3.13', tox_version='<4') +tests(python='3.13', tox_version='latest') tests(python='3.8', tox_version='<4') tests(python='3.8', tox_version='latest') tests(python='3.9', tox_version='<4') diff --git a/samples/integration/typeshed.txt b/samples/integration/typeshed.txt index a4367c6..9a51168 100644 --- a/samples/integration/typeshed.txt +++ b/samples/integration/typeshed.txt @@ -2,7 +2,5 @@ alerts changelog create_baseline_stubs drafts -generate_proto_stubs lint prs -sync_tensorflow_protobuf_stubs diff --git a/src/mk/tools/pre.py b/src/mk/tools/pre.py index 2c2e28a..83c2c25 100644 --- a/src/mk/tools/pre.py +++ b/src/mk/tools/pre.py @@ -55,7 +55,8 @@ def changelog(self) -> None: result = result.rstrip("\r\n") + "\n" result = result.replace("\r\n", "\n") result = re.sub(r"\n{3,}", "\n\n", result, re.MULTILINE) - with open("CHANGELOG.md", "w", encoding="utf-8") as f: + filename = os.environ.get("CHANGELOG_FILE", "CHANGELOG.md") + with open(filename, "w", encoding="utf-8") as f: f.write(result) logging.info("Wrote CHANGELOG.md")