From eaa03fb11f4ee9110f7793b37f55e5bc054ebfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Wed, 3 Jan 2024 00:10:33 +0100 Subject: [PATCH 1/2] chore: improve release automation --- abrechnung/__init__.py | 2 +- frontend/apps/mobile/android/app/build.gradle | 2 +- pyproject.toml | 6 ++--- tools/make_release.py | 25 ++++++++++++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/abrechnung/__init__.py b/abrechnung/__init__.py index 9d080ff4..db03527c 100644 --- a/abrechnung/__init__.py +++ b/abrechnung/__init__.py @@ -1,6 +1,6 @@ """Abrechnung - feature complete payment management and bookkeeping.""" -__version__ = "0.12.0" +__version__ = "0.11.0" MAJOR_VERSION = __version__.split(".")[0] MINOR_VERSION = __version__.split(".")[1] diff --git a/frontend/apps/mobile/android/app/build.gradle b/frontend/apps/mobile/android/app/build.gradle index 0972bd5b..e76d3a90 100644 --- a/frontend/apps/mobile/android/app/build.gradle +++ b/frontend/apps/mobile/android/app/build.gradle @@ -80,7 +80,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 - versionName "1.0" + versionName "0.11.0" testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' diff --git a/pyproject.toml b/pyproject.toml index 7005f441..55db19d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,8 +81,7 @@ disable = [ "R", "fixme", "logging-fstring-interpolation", - "broad-exception-caught" -] + "broad-exception-caught" ] [tool.black] line-length = 120 @@ -105,8 +104,9 @@ source = [ ] [tool.bumpversion] -current_version = "0.12.0" +current_version = "0.11.0" commit = false files = [ { filename = "abrechnung/__init__.py" }, + { filename = "frontend/apps/mobile/android/app/build.gradle" }, ] diff --git a/tools/make_release.py b/tools/make_release.py index 043b962a..321b6da9 100755 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -1,5 +1,10 @@ import argparse +import json +import re import subprocess +from pathlib import Path + +repo_root = Path(__file__).parent.parent def parse_args(): @@ -10,13 +15,31 @@ def parse_args(): return parser.parse_args() +def _get_next_version(part: str) -> tuple[str, str]: + ret = subprocess.run(["bump-my-version", "show", "--format", "json", "--increment", part], capture_output=True) + result = json.loads(ret.stdout) + return result["current_version"], result["new_version"] + + def main(part: str, dry_run: bool): # print current then prompt for new API compatibility version ranges # call bumpversion - bump_my_version_args = ["bump-my-version", "bump", part, "--dry-run"] + current_version, next_version = _get_next_version(part) + print(f"Current Version: {current_version}, Upgrading to version {next_version}") + + bump_my_version_args = ["bump-my-version", "bump", part, "--dry-run", "--no-commit", "--no-tag"] if dry_run: bump_my_version_args.append("--dry-run") subprocess.run(bump_my_version_args, check=True) + + app_build_gradle = repo_root / "frontend" / "apps" / "mobile" / "android" / "app" / "build.gradle" + gradle_content = app_build_gradle.read_text() + if not dry_run: + version_code_match = re.match(".*versionCode (?P\d+)\n.*", gradle_content) + code = int(version_code_match.group("version")) + gradle_content.replace(f"versionCode {code}", f"versionCode {code + 1}") + app_build_gradle.write_text(gradle_content) + # generated changelog from commits / merges / whatever # print current changelog # prompt for additional changelog entries From d662abbda421ba7c27744bd4679c86ff64e18c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Wed, 3 Jan 2024 00:13:17 +0100 Subject: [PATCH 2/2] --amend --- tools/make_release.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/make_release.py b/tools/make_release.py index 321b6da9..dad84c96 100755 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -16,18 +16,21 @@ def parse_args(): def _get_next_version(part: str) -> tuple[str, str]: - ret = subprocess.run(["bump-my-version", "show", "--format", "json", "--increment", part], capture_output=True) + ret = subprocess.run( + ["bump-my-version", "show", "--format", "json", "--increment", part], capture_output=True, check=True + ) result = json.loads(ret.stdout) return result["current_version"], result["new_version"] def main(part: str, dry_run: bool): + if dry_run: + print("Performing a dry run ...") # print current then prompt for new API compatibility version ranges - # call bumpversion current_version, next_version = _get_next_version(part) print(f"Current Version: {current_version}, Upgrading to version {next_version}") - bump_my_version_args = ["bump-my-version", "bump", part, "--dry-run", "--no-commit", "--no-tag"] + bump_my_version_args = ["bump-my-version", "bump", part, "--no-commit", "--no-tag"] if dry_run: bump_my_version_args.append("--dry-run") subprocess.run(bump_my_version_args, check=True) @@ -35,10 +38,14 @@ def main(part: str, dry_run: bool): app_build_gradle = repo_root / "frontend" / "apps" / "mobile" / "android" / "app" / "build.gradle" gradle_content = app_build_gradle.read_text() if not dry_run: - version_code_match = re.match(".*versionCode (?P\d+)\n.*", gradle_content) - code = int(version_code_match.group("version")) - gradle_content.replace(f"versionCode {code}", f"versionCode {code + 1}") - app_build_gradle.write_text(gradle_content) + version_code_matches = re.findall(r"versionCode (?P\d+)", gradle_content) + for match in version_code_matches: + code = int(match) + gradle_content = gradle_content.replace(f"versionCode {code}", f"versionCode {code + 1}") + app_build_gradle.write_text(gradle_content) + + print("Do not forget to update the api version compatibilities") + print("Do not forget to add a debian changelog entry") # generated changelog from commits / merges / whatever # print current changelog