Skip to content

Commit

Permalink
Allow custom filenames for changelog command
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Sep 24, 2024
1 parent f433383 commit 485660f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion src/mk/tools/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 485660f

Please sign in to comment.