From 7c1d2ae1380bec81bbe97e12343228bc9c38cf2d Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Tue, 19 Jan 2021 12:09:43 +0100 Subject: [PATCH] sg_mbp_release now accepts dev version identifier --- work_helpers/excel2markdown.py | 1 + work_helpers/sg_mbp_release.py | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/work_helpers/excel2markdown.py b/work_helpers/excel2markdown.py index 9b12e70..2a22586 100644 --- a/work_helpers/excel2markdown.py +++ b/work_helpers/excel2markdown.py @@ -2,6 +2,7 @@ import click import pyperclip + def split_table(text): rows = [] for line in text.splitlines(): diff --git a/work_helpers/sg_mbp_release.py b/work_helpers/sg_mbp_release.py index cb30908..dcdea23 100644 --- a/work_helpers/sg_mbp_release.py +++ b/work_helpers/sg_mbp_release.py @@ -102,28 +102,29 @@ def create_changelog_entry(new_version, parent=PATH_ISSUES): fh.write(CRLF.join(content)) -def copy_changelog(destination, latest): +def copy_changelog(destination, release_version): textfiles = _files_in_folder(PATH_ISSUES, ".txt") changelog = next(f for f in textfiles if f.stem.lower().startswith("change")) - new_path = destination / f"CHANGELOG {latest}.txt" + new_path = destination / f"CHANGELOG {release_version}.txt" print(changelog.name, "->", new_path) shutil.copyfile(changelog, new_path) -def copy_workbook_changelogs(destination, latest): +def copy_workbook_changelogs(destination, latest, release_version): source = PATH_ISSUES / latest textfiles = _files_in_folder(source, ".txt") logs = (f for f in textfiles if f.stem.lower().startswith("change")) for log_file in logs: - new_path = destination / log_file.name + new_name = log_file.name.replace(latest, release_version) + new_path = destination / new_name print(log_file.name, "->", new_path) shutil.copyfile(log_file, new_path) -def copy_workbooks(destination, latest): +def copy_workbooks(destination, release_version): for excel_file in _files_in_folder(PATH_WORKBOOKS, ".xlsx"): new_name = WORKBOOKS_MAP[excel_file.name] - new_path = destination / new_name.format(version=latest) + new_path = destination / new_name.format(version=release_version) print(excel_file.name, "->", new_path) shutil.copyfile(excel_file, new_path) @@ -150,7 +151,8 @@ def sg_mbp_new_version(version): @click.command() -def sg_mbp_release(): +@click.option("-d", "--dev_version", prompt=True, required=True, default="") +def sg_mbp_release(dev_version): """ Before running this command: @@ -163,14 +165,15 @@ def sg_mbp_release(): The command will collect all data into one folder on the Desktop to be published """ latest = get_latest_version() + release_version = f"{latest}{dev_version}" - new_folder_name = f"{TODAY} {latest}" + new_folder_name = f"{TODAY} {release_version}" new_folder_path = PATH_WIN_DESKTOP / new_folder_name if new_folder_path.exists(): raise IOError(f"Folder exists on desktop: {new_folder_name}") else: new_folder_path.mkdir() - copy_workbooks(new_folder_path, latest) - copy_workbook_changelogs(new_folder_path, latest) - copy_changelog(new_folder_path, latest) + copy_workbooks(new_folder_path, release_version) + copy_workbook_changelogs(new_folder_path, latest, release_version) + copy_changelog(new_folder_path, release_version)