From 8458a685ed86954e42e63f63bd7657912cf38f77 Mon Sep 17 00:00:00 2001 From: Francis Mwangi Date: Sun, 13 Oct 2019 22:52:16 +0300 Subject: [PATCH] fixing deployments (#7) * fixing deployments * refactoring publish pipeline * refactoring publish pipeline * revert changed version code * pep8 * refactor to do curl in another step --- .circleci/config.yml | 4 ++-- Makefile | 4 ++++ publish.sh | 20 ++++++++++++++++++++ requirements.txt | 1 + ussd/__init__.py | 3 ++- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100755 publish.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index b1f8cde..9109cdb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,11 +24,11 @@ jobs: command: | docker-compose up -d sleep 10 + curl --retry 20 --retry-delay 5 -v http://localhost:8007 - run: name: Running tests command: | - curl --retry 20 --retry-delay 5 -v http://localhost:8007 docker-compose run app bash -c 'coverage run --omit=*test*,*ven* manage.py test && bash <(curl -s https://codecov.io/bash) && python-codacy-coverage -r coverage.xml' deploy: <<: *defaults @@ -38,7 +38,7 @@ jobs: - run: name: deploying command: | - docker-compose run --no-deps -e PYPI_PASSWORD=$PYPI_PASSWORD -e PYPI_USER=$PYPI_USER -e VERSION=$CIRCLE_TAG app bash -c 'printf "[distutils]\nindex-servers = pypi \n[pypi]\nusername:$PYPI_USER\npassword:$PYPI_PASSWORD" > ~/.pypirc && python setup.py sdist upload' + make deploy version=$CIRCLE_TAG diff --git a/Makefile b/Makefile index 77c6def..85db8b1 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ + test: @docker-compose run --service-port app python manage.py test @@ -10,3 +11,6 @@ compile_documentation: create_dynamodb_table: docker-compose run ansible ./create_dynamodb.sh + +deploy: + docker-compose run --no-deps -e VERSION=$(version) -e PYPI_PASSWORD=$(PYPI_PASSWORD) -e PYPI_USER=$(PYPI_USER) app ./publish.sh diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..ec45e8c --- /dev/null +++ b/publish.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e + +if [[ -z "${VERSION}" ]] ; then + echo "Version not defined "; + exit 1 +fi + +echo "version ${VERSION}" + +printf "[distutils]\nindex-servers = pypi \n[pypi]\nusername:${PYPI_USER}\npassword:${PYPI_PASSWORD}\n" > ~/.pypirc + + +sed -i 's/VERSION = .*/'VERSION="'${VERSION}'"'/' ussd/__init__.py + +python setup.py sdist + +git checkout ussd/__init__.py + +twine upload dist/* diff --git a/requirements.txt b/requirements.txt index 4dcec90..b943558 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ django-cors-headers==2.4.0 boto3==1.9.87 awscli==1.16.15 ipdb==0.12.2 +twine==1.15.0 # using mwaaas branch here as we wait for this pull request to be merged # https://github.com/steven-bruce-au/dynamodb-local-cloud-formation/pull/4 git+https://github.com/mwaaas/dynamodb-local-cloud-formation.git@4bc92a0430ec319dc3ce33e9fffadd6ba1c861a8 diff --git a/ussd/__init__.py b/ussd/__init__.py index 1f6518e..1cbeef4 100644 --- a/ussd/__init__.py +++ b/ussd/__init__.py @@ -1 +1,2 @@ -VERSION = '0.1.0' +# Version is filled during publish or deploy +VERSION = 'GENERATED_VERSION'