From 9e37cf7b2fe02e215231fdba3750216bcca902b4 Mon Sep 17 00:00:00 2001 From: Jeff Parr Date: Wed, 28 Feb 2018 21:38:48 -0800 Subject: [PATCH] Consolidate versioning and autodeploy to PyPI - Add build # to versions when not a tagged release and deploy to test.pypi --- .travis.yml | 36 ++++++++++++++++++++++++++++-------- CHANGELOG.md | 7 +++++++ aws_ir/__init__.py | 6 ++++-- aws_ir/_version.py | 1 + setup.py | 11 +++++++++-- 5 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 aws_ir/_version.py diff --git a/.travis.yml b/.travis.yml index 03cae71..8531f52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "3.6" +cache: pip before_install: - "mkdir -p /home/travis/.aws/" - "echo [default] > /home/travis/.aws/credentials" @@ -9,15 +10,34 @@ before_install: - "echo [default] > /home/travis/.aws/config" - "echo region = us-west-2 >> /home/travis/.aws/config" - "echo output = json >> /home/travis/.aws/config" + - if [[ -z $TRAVIS_TAG ]]; then sed -i "s/['\"]\([^\"]*\)['\"]/\"\1b$TRAVIS_BUILD_NUMBER\"/g" aws_ir/_version.py; fi - - "pip install flake8" - - "flake8 aws_ir" - - "flake8 tests" install: - - "pip install -r requirements.txt" - - "pytest tests/" - - "python setup.py build" - - "python setup.py install" + - pip install -r requirements.txt + - pip install flake8 + - python setup.py install + script: - - "pytest tests/" + - cat aws_ir/_version.py + - flake8 aws_ir + - flake8 tests + - pytest tests/ + +deploy: + - provider: pypi + distributions: sdist bdist_wheel + user: threatresponse + password: + secure: 0j3uJew5G/+06gQnKRYDdWfwKYfWuXBFSQXob1T6Q8aFsY7Ats+4HjQE1gC1igU/6XwPCBPUBHVuVC1YCfXQFLbqTAJng8F28Z+ULZLkO78+0qTUbqWXqclKT7ES2VaMRhAyNuxPg76WJ0W5cDq+q9nJ05jJjxdfmPhlEgJNHKpc0W1l5RtXKwTyHawAdxZxhBcuNtopMBuSgB7EN/jy4S5xyKAdNNITLUoVD9HwS9pMWIv5t2crvFZXxyoIDR4ga4bCGCAz1NSdFsSguTQb/EeClItw/BEUuFyv6KkMbkfiCcLJZBdEXEUyshrMIo2smenblK4iYFNS7c25BqMuXsdxe39fgkRFkC41W/JB2WtBvMpMESi7+b18KKR9Y+8Hh+3i+BjiNl2RN8Um8vMaRh6B9jt8+dI7zc6QIohviPeDLif1L7jkU8NpCIGgYDWOy2rGfeWnOz07scoObiZbozlbZw15nWIAIzo4pELt5Ga0voBQ179KJdH88dso25mF9cAKhRezqTzJY1YS7GUKavdugfnL5Cpthyal4ajVrVw5J66cJZmyT2Qmj/uzfTrXxXfFfDALQOiFWea3EbV8qSnf0MkVV4pEixdlnD1jobFZNZLFg1VCNJionSbqZbUccSCLjjKkv05XTjUktJV37V5m41xBm7mRH9PvPgGHCOo= + on: + tags: true + - provider: pypi + server: https://test.pypi.org/legacy/ + distributions: sdist bdist_wheel + user: threatresponse + password: + secure: 3WT5LhsCxkkJReN2Tg2wHwlzFIQ9cVQagIxekf7b/iPDy2M+CGhGC94sct5Rx5J6JSy2yiQfMRAjdvFQMFewM52s1H9iojsOx5uHxAzulEMdMkI7FehKD49d9k0wnBkkIu9cS9/0nvaFCQIiaV/J/5F7U7WXqC0JgZOoJCAIBWrUSjwnbeMlyRsJwfy4jQQY8AqzqewJFlcpfzW0tJKyNMsgRyi+pxT60ihuNrT3oCwzjV/g7CajmD1fq41FwRgSzmFzF3qyCSxEhQ0KOYtUNZ8FzkpxoN8s8CKOBT20B2tUJhMp2wv5f16r4zsFPemA7mpPuZMWlCghJId8ad61reWPs7sxjGgxHXOm0hvBGGrM17vOAM176pahjLlTSN9Bl0A2QyL7fKmQhxnBWT6ZnbVo3jW9cEx2qee1dyR/ybPbMZTatrx9eb9Jdl381/10YMeqkfCm0rrEfLluVVI3Oq0yGvzIRCOgCskzIKwj2bDbor5H2Tu45ht5OUB5inQpFQapRkZ3pc6W4o9c7ONcrhoQVoazEWUAm8hNn7oaR9rd+yY7F0+ojjLZxnOaIYsk11eSeTnVyIesexmHdL0iltuteWZ3wxEIsB8Revx3KxlhudwCvINlD8Jj8L1WdiyIPcEa4QeQF/bNTht6SWFPGC/EbM+jaOAGaagVkdBGQwk= + skip_cleanup: true + on: + all_branches: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c203fd..5777ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,5 +27,12 @@ All notable changes to this project will be documented in this file. * Flake8 in CI Pipeline * Moto Mocking for Outside-In Test Coverage +## [0.3.1] - 2018-03-10 +### CI/CD + +* Consolidate Versioning +* Deploy to PyPI from CI for all tagged releases +* Deploy to PyPI test from all untagged releases (adds build # to version) + diff --git a/aws_ir/__init__.py b/aws_ir/__init__.py index 92e00c2..b307a35 100644 --- a/aws_ir/__init__.py +++ b/aws_ir/__init__.py @@ -1,10 +1,12 @@ -__version__ = '0.3.1' - from datetime import datetime import logging import os import time +from aws_ir import _version + +__version__ = _version.__version__ + def set_stream_logger(name="aws_ir", level=logging.INFO, format_string=None): diff --git a/aws_ir/_version.py b/aws_ir/_version.py new file mode 100644 index 0000000..e1424ed --- /dev/null +++ b/aws_ir/_version.py @@ -0,0 +1 @@ +__version__ = '0.3.1' diff --git a/setup.py b/setup.py index dc960c9..974411d 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,14 @@ +import re from distutils.command.build import build from setuptools import setup from setuptools.command.install import install as _install +VERSION = re.search( + r"^__version__ = ['\"]([^'\"]*)['\"]", + open('aws_ir/_version.py', 'r').read(), + re.MULTILINE +).group(1) + class install(_install): def run(self): self.run_command('build') @@ -9,8 +16,8 @@ def run(self): setup(name="aws_ir", - version="0.3.1", - author="Andrew Krug, Alex McCormack, Joel Ferrier", + version=VERSION, + author="Andrew Krug, Alex McCormack, Joel Ferrier, Jeff Parr", author_email="andrewkrug@gmail.com,developer@amccormack.net,joel@ferrier.io", packages=["aws_ir", "aws_ir/libs", "aws_ir/plans"], license="MIT",