update_version.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import fileinput
  2. import sys
  3. import re
  4. if len(sys.argv) < 2:
  5. print("Please provide a new version string!")
  6. exit
  7. newVersion = sys.argv[1]
  8. shortVersion = re.match('^(\\d+\\.\\d+).', newVersion).group(1)
  9. print("New version: {0}".format(newVersion))
  10. # CMakeList
  11. regExp = re.compile('(\\s+)VERSION \\S+')
  12. for line in fileinput.input(['CMakeLists.txt'], inplace = True):
  13. print(regExp.sub('\\1VERSION ' + newVersion, line), end='')
  14. # vnotex.json
  15. regExp = re.compile('(\\s+)"version" : "\\S+"')
  16. for line in fileinput.input(['src/data/core/vnotex.json'], inplace = True):
  17. print(regExp.sub('\\1"version" : "' + newVersion + '"', line), end='')
  18. # ci-xxx.yml
  19. regExp = re.compile('(\\s+)VNOTE_VER: \\S+')
  20. for line in fileinput.input(['.github/workflows/ci-win.yml', '.github/workflows/ci-linux.yml', '.github/workflows/ci-macos.yml'], inplace = True):
  21. print(regExp.sub('\\1VNOTE_VER: ' + newVersion, line), end='')
  22. # Info.plist
  23. regExp = re.compile('(\\s+)<string>(?!10\\.15)\\d+\\.\\d+</string>')
  24. for line in fileinput.input(['src/data/core/Info.plist'], inplace = True):
  25. print(regExp.sub('\\1<string>' + shortVersion + '</string>', line), end='')
  26. regExp = re.compile('(\\s+)<string>\\d+\\.\\d+\\.\\d+</string>')
  27. for line in fileinput.input(['src/data/core/Info.plist'], inplace = True):
  28. print(regExp.sub('\\1<string>' + newVersion + '</string>', line), end='')
  29. regExp = re.compile('(\\s+)<string>\\d+\\.\\d+\\.\\d+\\.\\d+</string>')
  30. for line in fileinput.input(['src/data/core/Info.plist'], inplace = True):
  31. print(regExp.sub('\\1<string>' + newVersion + '.1</string>', line), end='')