-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgenver.py
More file actions
29 lines (23 loc) · 883 Bytes
/
Copy pathgenver.py
File metadata and controls
29 lines (23 loc) · 883 Bytes
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
###
### Generate a version label
###
import re
from datetime import date
build = 0
version_raw = "0.0.0"
with open("src/version.s", "r") as version_file:
version_raw = version_file.readline()
match = re.search('v(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?P<tag>\-\w+){0,1}(\+(?P<build>\d+)){0,1}', version_raw)
with open("src/version.s", "w") as version_file:
if match:
major = int(match.group('major'))
minor = int(match.group('minor'))
patch = int(match.group('patch'))
tag = ""
if match.group('tag'):
tag = match.group('tag')
if match.group('build'):
build = int(match.group('build'))
version_file.write(".text \"v{}.{}.{}{}+{}\"".format(major, minor, patch, tag, build+1))
else:
version_file.write(".text \"v{}.{}.{}{}\"".format(major, minor, patch, tag))