Skip to content

Commit

Permalink
enable deploy of git timestamped build
Browse files Browse the repository at this point in the history
  • Loading branch information
maxandersen committed Feb 10, 2019
1 parent caaf7b1 commit 4b27a65
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -34,7 +34,6 @@ cache:
install: pip install -U tox coveralls
language: python
script: travis_wait 30 tox --develop
before_deploy: script/check_release
deploy:
provider: pypi
user: maxandersen
Expand Down
37 changes: 37 additions & 0 deletions setup.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
"""Setup script for Home Assistant CLI."""
import codecs
import datetime
from datetime import datetime as dt
import os
import re
import subprocess

from setuptools import find_packages, setup

Expand All @@ -29,7 +31,42 @@ def find_version(*file_paths):
raise RuntimeError("Unable to find version string.")


def get_git_commit_datetime() -> str:
"""Return timestamp from last commit"""
try:
commit_hash = (
subprocess.check_output(
"git rev-parse HEAD", shell=True, stderr=subprocess.STDOUT
)
.decode("utf-8")
.strip()
)
commit_datetime = (
subprocess.check_output(
"git show -s --format=%ci " + commit_hash,
shell=True,
stderr=subprocess.STDOUT,
)
.decode("utf-8")
.strip()
)
print(commit_datetime)
datetime_object = datetime.datetime.strptime(
commit_datetime, '%Y-%m-%d %H:%M:%S +%f'
)
print("{:%Y%m%d%H%M%S}".format(datetime_object))
return "{:%Y%m%d%H%M%S}".format(datetime_object)
except subprocess.CalledProcessError as cpe:
print(cpe.output)
return "00000000000000"


__VERSION__ = find_version("homeassistant_cli", "const.py") # type: ignore
# Append a suffix to the version for dev builds
# Append a suffix to the version for dev builds
if 'dev' in __VERSION__:
__VERSION__ = '{v}-{s}'.format(v=__VERSION__, s=get_git_commit_datetime())

REQUIRED_PYTHON_VER = (3, 5, 3)


Expand Down

0 comments on commit 4b27a65

Please sign in to comment.