Save extracted changelog in workspace
This commit is contained in:
@@ -2,9 +2,9 @@ import os
|
|||||||
import re
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import mkstemp
|
|
||||||
|
|
||||||
VERSION_HEADER = re.compile(r"\[\d+.\d+.\d+\]")
|
VERSION_HEADER = re.compile(r"\[\d+.\d+.\d+\]")
|
||||||
|
SCRIPT_DIR = Path(__file__).absolute().parent.parent
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -19,8 +19,7 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
def get_changelog(version: str) -> list[str]:
|
def get_changelog(version: str) -> list[str]:
|
||||||
script_dir = Path(__file__).absolute().parent.parent
|
changelog = SCRIPT_DIR / "CHANGELOG.md"
|
||||||
changelog = script_dir / "CHANGELOG.md"
|
|
||||||
|
|
||||||
with changelog.open("r") as infile:
|
with changelog.open("r") as infile:
|
||||||
lines = infile.readlines()
|
lines = infile.readlines()
|
||||||
@@ -47,10 +46,10 @@ def get_changelog(version: str) -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def save_changelog(version: str, lines: list[str]) -> str:
|
def save_changelog(version: str, lines: list[str]) -> str:
|
||||||
fd, name = mkstemp(prefix=f"wapp-changelog-{version}-", text=True)
|
version_changelog = SCRIPT_DIR / f"wapp-changelog-{version}.md"
|
||||||
os.write(fd, "".join(lines).encode("utf-8"))
|
with version_changelog.open("w") as outfile:
|
||||||
os.close(fd)
|
outfile.writelines(lines)
|
||||||
return name
|
return str(version_changelog)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user