Skip to content

Commit

Permalink
Store tagged version once installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Bladrak committed May 28, 2018
1 parent a4ed805 commit 5b86a83
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@

def version():
"""retrieve version from tag name"""
tag = os.getenv('CIRCLE_TAG', '1')
ci_tag = os.getenv('CIRCLE_TAG')

if re.match('\d+(\.\d+)*', tag):
return tag
# Try to parse tag from CI variable, if set write version.txt file with current version
if ci_tag is not None:
if re.match('\d+(\.\d+)*', ci_tag):
with open('version.txt', 'w+') as f:
f.write(ci_tag)
return ci_tag
# Variable is set but format is incorrect, error
info = "Git tag: `{0}` is not set or does not match the version pattern of this app".format(
ci_tag
)
sys.exit(info)

info = "Git tag: {0} does not match the version pattern of this app".format(
tag
)
sys.exit(info)
# Read version from file
with open('version.txt') as f:
return f.read()

def readme():
"""print long description"""
with open('Readme.md') as f:
return f.read()

setup(
name='tc_aws',
version=version(),
Expand Down

0 comments on commit 5b86a83

Please sign in to comment.