taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit 7d17036797515db23661d670b40acd0ea792216f
parent f51def942b32a9df024071ace8813077cc5114e3
Author: Antoine A <>
Date:   Fri, 28 Nov 2025 11:56:35 +0100

common: add bump-version

Diffstat:
Acontrib/bump-version | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+), 0 deletions(-)

diff --git a/contrib/bump-version b/contrib/bump-version @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 + +import argparse +import re +import subprocess +import sys +import textwrap + + +def shget(cmd): + return subprocess.run( + cmd, shell=True, encoding="utf-8", capture_output=True + ).stdout.strip() + + +parser = argparse.ArgumentParser(description="Bump the libeufin version.") + +parser.add_argument("new_version") +parser.add_argument("--dry", action="store_true") + +args = parser.parse_args() + +new_version = args.new_version +dry = args.dry + +version = sys.argv[1] + +# Bump version of "debian/changelog" + +with open("debian/changelog") as deb_changelog: + while True: + line = deb_changelog.readline() + if line == "": + break + if line.strip() == "": + continue + m = re.match(r".*\((.*)\).*", line) + break + +deb_current_version = m.group(1) +deb_bump = " [!]" if deb_current_version != version else "" + +print(f"debian/control: {deb_current_version} -> {version}{deb_bump}") + +if not dry and deb_current_version != version: + name = shget("git config user.name") + email = shget("git config user.email") + date = shget("date -R") + entry_r = f"""\ + libeufin ({new_version}) unstable; urgency=low + + * Release version {new_version} + + -- {name} <{email}> {date} + """ + entry = textwrap.dedent(entry_r) + with open("debian/changelog") as f: + old_changelog = f.read() + new_changelog = entry + "\n" + old_changelog + with open("debian/changelog", "w") as f: + f.write(new_changelog) + +# Bump version in Cargo.toml + +with open("Cargo.toml") as f: + contents = f.read() +cargo_pat = r'version.*=.*"(.*)"' +m = re.search(cargo_pat, contents) +cargo_current_version = m.group(1) + +new_contents = re.sub(cargo_pat, f'version = "{new_version}"', contents, count=1) +cargo_bump = " [!]" if cargo_current_version != version else "" +print(f"Cargo.toml: {cargo_current_version} -> {version}{cargo_bump}") + +if not dry: + with open("Cargo.toml", "w") as f: + f.write(new_contents)