Skip to content

Instantly share code, notes, and snippets.

@esseti

esseti/tag.py Secret

Created Jun 27, 2018
Embed
What would you like to do?
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