Skip to content

Instantly share code, notes, and snippets.

@esseti

esseti/tag.py Secret

Created June 27, 2018 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esseti/d1376219fea70a35e0e38fe9826fd2ff to your computer and use it in GitHub Desktop.
Save esseti/d1376219fea70a35e0e38fe9826fd2ff to your computer and use it in GitHub Desktop.
new tag git
@task
def current_tag():
tag = local('git describe --tags $(git rev-list --tags --max-count=1)', capture=True)
return tag
@task
def new_tag(test):
#create new tag
if type(test) != bool:
test = strtobool(test)
try:
last_tag = current_tag()
except:
last_tag = '0.0'
versions = last_tag.split('.')
if test:
# we change the last number 0.X+1
versions[1] = str(int(versions[1]) + 1)
else:
# if prod we change the first X+1.0
versions[0] = str(int(versions[0]) + 1)
versions[1] = "0"
tag = ".".join(versions)
print(green("new tag %s " % tag))
return tag
@task
def git_tag(tag=None, message='tag version', test=True):
if not tag:
tag = new_tag(test=test)
local('git tag -a "%s" -m "%s"' % (tag, message))
local('git push origin %s' % tag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment