libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

bump-version (1607B)


      1 #!/usr/bin/env python3
      2 
      3 import sys
      4 import re
      5 import argparse
      6 import subprocess
      7 import textwrap
      8 
      9 def shget(cmd):
     10     return subprocess.run(cmd, shell=True, encoding="utf-8", capture_output=True).stdout.strip()
     11 
     12 
     13 parser = argparse.ArgumentParser(
     14                     description="Bump the libeufin version.")
     15 
     16 parser.add_argument("new_version")
     17 parser.add_argument("--dry", action="store_true")
     18 
     19 args = parser.parse_args()
     20 
     21 new_version = args.new_version
     22 dry = args.dry
     23 
     24 version = sys.argv[1]
     25 
     26 # Bump version of "debian/changelog"
     27 
     28 with open("debian/changelog") as deb_changelog:
     29     while True:
     30         line = deb_changelog.readline()
     31         if line == "":
     32             break
     33         if line.strip() == "":
     34             continue
     35         m = re.match(r".*\((.*)\).*", line)
     36         break
     37 
     38 deb_current_version = m.group(1)
     39 deb_bump = " [!]" if deb_current_version != version else ""
     40 
     41 print(f"debian/control: {deb_current_version} -> {version}{deb_bump}")
     42 
     43 if not dry and deb_current_version != version:
     44     name = shget("git config user.name")
     45     email = shget("git config user.email")
     46     date = shget("date -R")
     47     entry_r = f"""\
     48     libeufin ({new_version}) unstable; urgency=low
     49 
     50       * Release version {new_version}
     51 
     52      -- {name} <{email}>  {date}
     53     """
     54     entry = textwrap.dedent(entry_r)
     55     with open("debian/changelog") as f:
     56         old_changelog = f.read()
     57     new_changelog = entry + "\n" + old_changelog
     58     with open("debian/changelog", "w") as f:
     59         f.write(new_changelog)
     60 
     61 # The program version is derived from Git tags at build time; there is no
     62 # Gradle version literal to bump.