update_version.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. print("New version: {0}".format(newVersion))
  9. # CMakeList
  10. regExp = re.compile('(\\s+)VERSION \\S+')
  11. for line in fileinput.input(['CMakeLists.txt'], inplace = True):
  12. print(regExp.sub('\\1VERSION ' + newVersion, line), end='')
  13. # vnotex.json
  14. regExp = re.compile('(\\s+)"version" : "\\S+"')
  15. for line in fileinput.input(['src/data/core/vnotex.json'], inplace = True):
  16. print(regExp.sub('\\1"version" : "' + newVersion + '"', line), end='')
  17. # ci-xxx.yml
  18. regExp = re.compile('(\\s+)VNOTE_VER: \\S+')
  19. for line in fileinput.input(['.github/workflows/ci-win.yml', '.github/workflows/ci-linux.yml', '.github/workflows/ci-macos.yml'], inplace = True):
  20. print(regExp.sub('\\1VNOTE_VER: ' + newVersion, line), end='')
  21. # Info.plist
  22. regExp = re.compile('(\\s+)<string>\\d+\\.\\d+\\.\\d+</string>')
  23. for line in fileinput.input(['src/data/core/Info.plist'], inplace = True):
  24. print(regExp.sub('\\1<string>' + newVersion + '</string>', line), end='')
  25. regExp = re.compile('(\\s+)<string>\\d+\\.\\d+\\.\\d+\\.\\d+</string>')
  26. for line in fileinput.input(['src/data/core/Info.plist'], inplace = True):
  27. print(regExp.sub('\\1<string>' + newVersion + '.1</string>', line), end='')