Skip to content

Commit

Permalink
Adding a publish command
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Myers committed May 13, 2019
1 parent 626a982 commit 7c790e4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
59 changes: 46 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
version: 2.1

executors:
default:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.8-jessie

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4

working_directory: ~/repo

jobs:
build:
executor: default

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
- v1-dependencies-{{ checksum "requirements-test.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

Expand All @@ -34,7 +31,7 @@ jobs:
- save_cache:
paths:
- ./.venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
key: v1-dependencies-{{ checksum "requirements-test.txt" }}

- run:
name: run tests
Expand All @@ -43,3 +40,39 @@ jobs:
- store_artifacts:
path: test-reports
destination: test-reports

deploy:
executor: default

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements-test.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: make setup

- save_cache:
paths:
- ./.venv
key: v1-dependencies-{{ checksum "requirements-test.txt" }}

- run: make publish

workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DOCKER_COMPOSE := $(shell which docker-compose)
.SILENT: help
.PHONY: setup docs clean
.PHONY: test flake8 unit
.PHONY: publish publish-test
.PHONY: help

default: help
Expand Down Expand Up @@ -77,6 +78,26 @@ watch: ## Watch for changes to python modules and re-run the tests
docs: setup ## Build the documentation
$(VIRTUAL_ENV)/bin/sphinx-build -a docs docs/_build

publish-test: setup ## Publish the library to test pypi
ifndef TWINE_USERNAME
$(error "You must set the TWINE_USERNAME env variable 'export TWINE_USERNAME=theusername'")
endif
ifndef TWINE_PASSWORD
$(error "You must set the TWINE_PASSWORD env variable 'export TWINE_PASSWORD=thevalueofthepassword'")
endif
$(VIRTUAL_ENV)/bin/python setup.py sdist bdist_wheel
$(VIRTUAL_ENV)/bin/python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

publish: setup ## Publish the library to pypi
ifndef TWINE_USERNAME
$(error "You must set the TWINE_USERNAME env variable 'export TWINE_USERNAME=theusername'")
endif
ifndef TWINE_PASSWORD
$(error "You must set the TWINE_PASSWORD env variable 'export TWINE_PASSWORD=thevalueofthepassword'")
endif
$(VIRTUAL_ENV)/bin/python setup.py sdist bdist_wheel
$(VIRTUAL_ENV)/bin/python -m twine upload dist/*

#% Available Commands:
help: ## Help is on the way
grep '^#%' $(MAKEFILE_LIST) | sed -e 's/#%//'
Expand Down
6 changes: 5 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ pycodestyle==2.5.0
pyflakes==2.1.0
entrypoints==0.3

# Sphinx
# Sphinx Documentation
Sphinx==2.0.1
sphinx-autodoc-typehints==1.6.0

# twine PYPI Publish
twine==1.13.0
wheel

0 comments on commit 7c790e4

Please sign in to comment.