forked from Squalr/Squalr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRelease.py
46 lines (35 loc) · 1.47 KB
/
Release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
####################################################################################
# This script will generate all cpp/h files from data in the Data directory. #
# Run this script every time data files are updated in the Squally/Data directory. #
###################################################################################$
from os import listdir
from os import path
from os.path import isfile, join, splitext, abspath, realpath, basename, relpath
import json
import os
import re
import sys
import importlib.util
def main():
currentPath = os.path.dirname(__file__)
for root, dirnames, filenames in os.walk(currentPath):
for filename in filenames:
if filename.lower().endswith(".csproj"):
replaceVersionInFile(join(root, filename), "3.0.2")
continue
def replaceVersionInFile(filename, newVersion):
fin = open(filename, "r")
lines = []
for line in fin:
line = re.sub("<Version>.+</Version>", "<Version>" + newVersion + "</Version>", line)
line = re.sub("<AssemblyVersion>.+</AssemblyVersion>", "<AssemblyVersion>" + newVersion + "</AssemblyVersion>", line)
line = re.sub("<FileVersion>.+</FileVersion>", "<FileVersion>" + newVersion + "</FileVersion>", line)
lines.append(line)
fin.close()
fout = open(filename, "w")
for line in lines:
fout.write(line)
fout.close()
if __name__ == '__main__':
main()