diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..51d3e0c --- /dev/null +++ b/tools/README.md @@ -0,0 +1,15 @@ +Publishing New Releases +======================= + +First, update the version number throughout the repo and push the change: + + ./tools/makever.py --version X.Y.Z + git commit -a -m "Update version" + git push + +Then tag it + + git tag X.Y.Z + git push origin X.Y.Z + +Then on the GH web interface make a new release from that tag. diff --git a/tools/makever.py b/tools/makever.py new file mode 100755 index 0000000..7ae3f47 --- /dev/null +++ b/tools/makever.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import sys +import struct +import subprocess +import re +import os +import os.path +import argparse +import time +import shutil +import json + +def main(): + parser = argparse.ArgumentParser(description='Version updater') + parser.add_argument('-v', '--version', action='store', required=True, help='Version in X.Y.Z form') + args = parser.parse_args() + + major, minor, sub = args.version.split(".") + # Silly way to check for integer x.y.z + major = int(major) + minor = int(minor) + sub = int(sub) + + # library.properties + with open("library.properties", "r") as fin: + with open("library.properties.new", "w") as fout: + for l in fin: + if l.startswith("version="): + l = "version=" + str(args.version) + "\n" + fout.write(l); + shutil.move("library.properties.new", "library.properties") + + # package.json + with open("library.json", "r") as fin: + library = json.load(fin); + library["version"] = str(args.version); + with open("library.json.new", "w") as fout: + json.dump(library, fout, indent = 4); + shutil.move("library.json.new", "library.json") + +main()