diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..bdcf159 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,90 @@ +# 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.6.1 + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "setup.py" }} + + - run: + name: install dependencies + command: | + python3 -m venv venv + . venv/bin/activate + make dev + + - save_cache: + paths: + - ./venv + key: v1-dependencies-{{ checksum "setup.py" }} + + deploy: + docker: + - image: circleci/python:3.6 + steps: + - checkout + + - restore_cache: + key: v1-dependency-cache-{{ checksum "setup.py" }} + + - run: + name: install python dependencies + command: | + python3 -m venv venv + . venv/bin/activate + make dev + - save_cache: + key: v1-dependency-cache-{{ checksum "setup.py" }} + paths: + - "venv" + + - 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 = io_exception" >> ~/.pypirc + echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc + - run: + name: create packages + command: | + make package + - run: + name: upload to pypi + command: | + . venv/bin/activate + twine upload dist/* + +workflows: + version: 2 + build_and_deploy: + jobs: + - build: + filters: + tags: + only: /.*/ + - deploy: + requires: + - build + filters: + tags: + only: /[0-9]+(\.[0-9]+)*/ + branches: + ignore: /.*/ \ No newline at end of file diff --git a/Makefile b/Makefile index 6cbb3bc..3d19ce9 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,16 @@ -run: install - jupyter notebook -install: clean - pip install -e . - jupyter serverextension enable --py jupygit --sys-prefix - jupyter nbextension install --py jupygit --sys-prefix - jupyter nbextension enable --py jupygit --sys-prefix +.PHONY: help clean dev docs package test + +help: + @echo "This project assumes that an active Python virtualenv is present." + @echo "The following make targets are available:" + @echo " dev install all deps for dev env" + clean: - find . -type d -name "__pycache__" -exec rm -rf {} + \ No newline at end of file + rm -rf dist/* + +dev: + pip install -r requirements.txt + +package: + python setup.py sdist + python setup.py bdist_wheel \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c9133d6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +twine \ No newline at end of file diff --git a/setup.py b/setup.py index 9e7babf..2f4455e 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,39 @@ -from setuptools import setup, find_packages +import os +import sys -try: - long_desc = open('README.md').read() -except: - long_desc = '' +from setuptools import setup +from setuptools.command.install import install + +with open("README.md", "r") as fh: + long_description = fh.read() + +# Package version +VERSION = "0.1.0" + +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 library: {1}".format( + tag, VERSION + ) + sys.exit(info) setup( name="jupygit", url="https://github.com/fferegrino/jupygit", author="Antonio Feregrino", author_email="antonio.feregrino@gmail.com", - version="0.0.26", - packages=find_packages(), - install_requires=[ - "jupyter==1" - ], - include_package_data=True, + version=VERSION, description="Prepare your Notebooks to be pushed to GitHub", - long_description=long_desc, + long_description=long_description, + long_description_content_type="text/markdown", + include_package_data=True, + cmdclass={ + 'verify': VerifyVersionCommand, + } ) \ No newline at end of file