-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.py
50 lines (42 loc) · 1.27 KB
/
update.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
PACKAGE_NAME = "grappelli_extras"
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.join(BASE_DIR, PACKAGE_NAME)
TO = os.path.join(PROJECT_DIR, PACKAGE_NAME)
VERSION_FILE = os.path.join(TO, '__init__.py')
version_text = open(VERSION_FILE, "rt").read()
print(version_text)
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, version_text, re.M)
x, y, z = 0, 0, 0
x = int(mo.group(1).split(".")[2])
y = int(mo.group(1).split(".")[1])
z = int(mo.group(1).split(".")[0])
print (x,y,z)
if x < 9:
x += 1
elif x == 9 and y < 9:
x = 0
y += 1
elif x == 9 and y == 9:
x = 0
y = 0
z += 1
else:
print ("Formato de version anterior invalido por favor use __version__ = 'x.y.z'")
NEW_VERSION = "__version__ = '%s.%s.%s'" % (z, y , x)
open(VERSION_FILE, "w").write(NEW_VERSION)
import os
# os.system(RM)
# os.system(CP)
os.system("git add . --all")
os.system('git commit -am "%s"' % NEW_VERSION)
os.system("git tag %s.%s.%s" % (z, y, x))
os.system("git push origin master")
os.system("git push --tags origin master")
os.system("python setup.py sdist bdist_wheel")
os.system("twine upload dist/django-grappelli-extras-%s.%s.%s*" % (z, y, x))
print (NEW_VERSION)