HexManiacAdvance/bump.py
haven1433 4ca642c1c2 build system for faster releases
making a release is less tedious with these new utilities.
* bump can bump the patch, minor, or major version, and returns the new version.
* release can commit the files changed by bump, then tag, build, and zip.
2023-03-10 22:28:21 -06:00

37 lines
1.1 KiB
Python

# python -m bump
# python -m bump minor
# python -m bump major
import sys
def main(arg):
lines = []
new_version = ''
with open('src/SharedAssemblyInfo.cs') as file:
for line in file:
lines.append(line)
with open('src/SharedAssemblyInfo.cs', 'w') as file:
for line in lines:
if not 'AssemblyVersion' in line and not 'AssemblyFileVersion' in line:
file.write(line)
continue
parts = line.split('"')
version = parts[1].split('.')
while len(version) < 4: version.append('0')
i = 3
if arg == 'major': i = 1
if arg == 'minor': i = 2
version[i] = str(int(version[i])+1)
if i < 3: version[3] = '0'
if i < 2: version[2] = '0'
if version[3] == '0': del version[3]
parts[1] = '.'.join(version)
file.write('"'.join(parts))
new_version = '.'.join(version)
return new_version
if __name__ == '__main__':
arg = sys.argv[1] if len(sys.argv) > 1 else ''
print(main(arg))