diff --git a/.circleci/config.yml b/.circleci/config.yml index c53599b..f052d8b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,18 @@ workflows: version: 2 test: jobs: - - py27 + - py27: + filters: + tags: + only: /^v.*/ + - publish: + requires: + - py27 + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ # TODO: - py37 jobs: @@ -30,12 +41,34 @@ jobs: - save_cache: paths: ./venv/ - key: v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }} + key: v1-{{ arch }}-{{ .Environment.CIRCLE_PROJECT }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }} - run: name: Pytest command: | ./venv/bin/pytest -v tests/ - + publish: + docker: + - image: circleci/python:2.7 + steps: + - checkout + - restore_cache: + keys: + - v1-{{ arch }}-{{ .Environment.CIRCLE_PROJECT }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }} + - run: + name: verify git tag vs. version + command: | + python -m venv venv || virtualenv venv + . venv/bin/activate + python setup.py verify + - run: + name: create packages + command: | + python setup.py sdist + python setup.py bdist_wheel + - run: + name: upload to pypi + command: | + ./venv/bin/twine upload --config .pypirc -r pypi dist/* --password $PYPI_PASSWORD_PROD # TODO: # py37: # <<: *template diff --git a/.gitignore b/.gitignore index b635f6a..ff78b3c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ src/indy/specs/build/vendored/* # build directories /build/ /docs/_build/ - +/dist/ +/venv/ # compiled files *.o *.a diff --git a/.pypirc b/.pypirc new file mode 100644 index 0000000..d96869a --- /dev/null +++ b/.pypirc @@ -0,0 +1,11 @@ +[distutils] +index-servers= + pypi + testpypi + +[pypi] +username: nerdwallet + +[testpypi] +repository: https://test.pypi.org/legacy/ +username: nerdwallet \ No newline at end of file diff --git a/README.rst b/README.rst index 9d36030..52777f7 100644 --- a/README.rst +++ b/README.rst @@ -315,3 +315,11 @@ When creating ``aws_security_group_rule`` ``Resource`` objects you cannot pass ` vpc_id=vpc.id, ... ) + +Release Steps +================= +1. Create an issue, check out a branch, and make your code changes. +2. Push to run CircleCI tests. +3. Create Pull Request to Master including VERSION bump. +4. Merge PR after Approval. +5. Add tag like v1.0.0 that matches new version and push. \ No newline at end of file diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/requirements.txt b/requirements.txt index d9b333a..df0018d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ schematics==2.1.0 six==1.12.0 +twine==1.13.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 4330dc4..2202046 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,8 @@ +import os +import sys + from setuptools import find_packages, setup +from setuptools.command.install import install with open('VERSION') as version_fd: VERSION = version_fd.read().strip() @@ -6,6 +10,22 @@ with open('README.rst') as readme_fd: long_description = readme_fd.read() +class VerifyVersionCommand(install): + """Custom command to verify that the git tag matches our version""" + description = 'verify that the git tag matches our version' + + def run(self): + if os.getenv('CIRCLE_TAG') == None: + sys.exit("FAILED: Your CIRCLE_TAG variable appears to be unset. Are you running on CircleCI triggered by tag?") + else: + tag = os.getenv('CIRCLE_TAG') + + if tag != "v" + VERSION: + info = "Git tag: {0} does not match the version of this app: {1}".format( + tag, VERSION + ) + sys.exit(info) + setup( name='terraformpy', version=VERSION, @@ -45,5 +65,8 @@ "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Pre-processors", "Topic :: System :: Systems Administration", - ] + ], + cmdclass={ + 'verify': VerifyVersionCommand, + } )