forked from sampathbms2009/test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.py
executable file
·39 lines (29 loc) · 1022 Bytes
/
3.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
#!/usr/bin/python
import sys, getopt, commands, os
sourceurl=''
username=''
password=''
def err():
print("Usage: %s -s <source url> -u <username> -p password]" % sys.argv[0])
sys.exit(2)
try:
myopts, args = getopt.getopt(sys.argv[1:],"s:u:p:")
except getopt.GetoptError as e:
print (str(e))
err()
for o, a in myopts:
if o == '-s':
sourceurl=a
elif o == '-u':
username=a
elif o == '-p':
password=a
sourceurl=sourceurl.split("https://")[1]
currentversion = commands.getoutput("git ls-remote -t https://"+username+":"+password+"@"+sourceurl+"| awk -F'/' '{print $3}'| tail -n 1")
print "Current Version: "+ currentversion
version = str(int(currentversion.split("-v")[-1])+1)
updatedversion = (currentversion.split("-v")[-2]+"-v"+version)
commands.getoutput("git tag | xargs git tag -d")
commands.getoutput("git tag "+ updatedversion)
command = commands.getoutput("git push https://"+username+":"+password+"@"+sourceurl+" --tags")
print "Updated Version: "+updatedversion