-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathversion.py
91 lines (71 loc) · 2 KB
/
version.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
def version_file():
file = os.path.dirname(os.path.realpath(__file__))
file = os.path.join(file, 'src', 'mgcli', 'version.h')
return file
def write_file(path, cnt):
with open(path, 'w') as f:
f.write(cnt)
def get_file_content(path, linex):
i = 1
ctx = ''
with open(path, 'r') as f:
for line in f:
if i != 3:
ctx += line
else:
ctx += linex
ctx += '\n' #os.linesep
i += 1
return ctx
line='#define XVERSION _T("'
v=version_file()
appv=os.environ.get('APPVEYOR_REPO_TAG')
appbuild=os.getenv('APPVEYOR_BUILD_VERSION', 'nn.nn.nn')
appm=os.getenv('APPVEYOR_REPO_COMMIT_MESSAGE', '===')
appb=os.getenv('APPVEYOR_REPO_BRANCH', '---')
apptag=os.getenv('APPVEYOR_REPO_TAG_NAME', 'no tag')
trevistag=os.environ.get('TRAVIS_TAG')
trbn=os.getenv('TRAVIS_BUILD_NUMBER', 'xx')
trc='TRAVIS'
trb=os.environ.get('TRAVIS_BRANCH')
trevis=False
if trb != None:
trevis=True
print '---------***'
print appv
print os.getenv('TRAVIS_BUILD_NUMBER')
print trbn
print '---------***'
lversion=os.environ.get('VERSION')
if None == lversion:
lversion='0.0.x'
if None == appv:
#not in appveyor
if trevis:
if trevistag != '':
line += trevistag
else:
line += trbn
line += ' ['
line += trc
line += ' on: '
line += trb
line += ']'
else:
line += lversion
line += ' [local] '
else:
if('false' == appv):
line += appbuild
else:
line += apptag
line += ' ['
line += appm
line += ' '
line += appb
line += ']'
line += '")'
cnt = get_file_content(v, line)
print cnt
write_file(v, cnt)