diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b770ed5 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,84 @@ +# Python CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-python/ for more details +# +version: 2 +jobs: + build: + docker: + - image: circleci/python:3-stretch + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "requirements.txt" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: + name: install dependencies + command: | + python3 -m venv venv + . venv/bin/activate + pip install -r requirements.txt + + - save_cache: + paths: + - ./venv + key: v1-dependencies-{{ checksum "requirements.txt" }} + + # run tests! + # this example uses Django's built-in test-runner + # other common Python testing frameworks include pytest and nose + # https://pytest.org + # https://nose.readthedocs.io + #- run: + # name: run tests + # command: | + # . venv/bin/activate + # python manage.py test + + #- store_artifacts: + # path: test-reports + # destination: test-reports + + + deploy: + docker: + - image: circleci/python:3-stretch + working_directory: ~/repo + + steps: + - checkout + + - restore_cache: + key: v1-dependencies-{{ checksum "requirements.txt" }} + + - run: + name: verify git tag vs version + command: | + python3 -m venv venv + . venv/bin/activate + python setup.py verify + + - run: + name: init .pypirc + command: | + echo -e "[pypi]" >> ~/.pypirc + echo -e "username = rveach" >> ~/.pypirc + echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc + + - run: + name: make a source distribution + command: | + python setup.py sdist + + - run: + name: upload to pypi + command: | + . venv/bin/activate + twine upload dist/* diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c2fcd29 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +twine>=1.12.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 3f98411..c60b58e 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,63 @@ -from distutils.core import setup +#!/usr/bin/env python + +import os +import sys + +from setuptools import setup +from setuptools.command.install import install + +VERSION = "0.1.5" + +def readme(): + """ print long description """ + with open('README.md') as f: + return r.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): + tag = os.getenv('CIRCLE_TAG') + + if tag != VERSION: + info = "Git tag: {0} does not match the version of this app: {1}".format( + tag, VERSION + ) + sys.exit(info) + + setup( - name = 'pymsteams', - packages = ['pymsteams'], - version = '0.1.5', - description = 'Format messages and post to Microsoft Teams.', - author = 'Ryan Veach', - author_email = 'rveach@gmail.com', - url = 'https://github.com/rveachkc/pymsteams', - download_url = 'https://github.com/rveachkc/pymsteams/archive/0.1.5.tar.gz', - keywords = ['Microsoft', 'Teams'], # arbitrary keywords - classifiers = [], - install_requires=['requests'], + name="pymsteams", + version=VERSION, + description="Format messages and post to Microsoft Teams.", + long_description=readme(), + url="https://github.com/rveachkc/pymsteams", + author="Ryan Veach", + author_email="rveach@gmail.com", + license="Apache", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Internet", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Office/Business", + "Topic :: Office/Business :: Groupware", + ], + keywords=['Microsoft', 'Teams'], + packages=['pymsteams'], + install_requires=[ + 'requests==2.18.4', + ], + python_requires='>=3', + cmdclass={ + 'verify': VerifyVersionCommand, + } )