update_version.py 672 B

123456789101112131415161718192021
  1. #! /usr/bin/env python3
  2. import common, os, re, subprocess, sys
  3. def update_version(major, minor, src):
  4. print(f"update_version: {major}.{minor} in {src}")
  5. with open(src, 'r') as f:
  6. contents = f.read()
  7. contents = re.sub(r"versionMajor\s+=\s+\d+;",
  8. f"versionMajor = {major};",
  9. contents)
  10. contents = re.sub(r"versionMinor\s+=\s+\d+;",
  11. f"versionMinor = {minor};",
  12. contents)
  13. with open(src, 'w') as f:
  14. f.write(contents)
  15. if __name__ == '__main__':
  16. os.chdir(common.root)
  17. (major, minor) = common.version().split(".")
  18. update_version(major, minor, 'FiraCode.glyphs')
  19. sys.exit(0)