55 # Building and testing the project
66 # Useful when a PR is open, for example
77 build-and-test :
8- # Our environment, Python 3.6.8
8+ # Our environment, Python 3.7
99 docker :
10- - image : circleci/python:3.6.8
10+ - image : circleci/python:3.7
1111
1212 # The steps for our build-and-test
1313 steps :
2626 - run :
2727 name : Install Dependencies
2828 command : |
29+ pip install --upgrade poetry
2930 python -m poetry install
3031
3132 # Save's the specified path as a cache. This is the path Poetry uses to install the dependencies
4142 name : Run Pytest, report coverage
4243 command : |
4344 python -m poetry run coverage run --omit="/home/circleci/.cache/pypoetry/virtualenvs" -m pytest
45+ python -m poetry run coverage report
46+
47+ # This is the definition of another job, the one we use to publish the package to PyPI
48+ deployment :
49+
50+ # Same environment
51+ docker :
52+ - image : circleci/python:3.7
53+
54+ steps :
55+
56+ # Gets the code
57+ - checkout
58+
59+ # Use `poetry publish` to Publish the package using username and password from CircleCI environment variables
60+ # Which can be configured inside CircleCI's interface
61+ - run :
62+ name : Push to PyPI
63+ command : |
64+ poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction
4465
4566# In the workflows section, we specify when we want to run the jobs defined
4667workflows :
@@ -49,4 +70,26 @@ workflows:
4970 # The build-and-test we will run EVERYTIME a piece of code changes
5071 build-and-test-workflow :
5172 jobs :
52- - build-and-test
73+ - build-and-test
74+
75+ # The deployment workflow publishes the package
76+ deployment-workflow :
77+ jobs :
78+
79+ # Runs build and test, but now just on Git tags (created from a GitHub release)
80+ - build-and-test :
81+ filters :
82+ tags :
83+ only : /v[0-9]+(\.[0-9]+)*/
84+ branches :
85+ ignore : /.*/
86+
87+ # Runs the deployment job, just with the tags as well
88+ - deployment :
89+ requires :
90+ - build-and-test
91+ filters :
92+ tags :
93+ only : /v[0-9]+(\.[0-9]+)*/
94+ branches :
95+ ignore : /.*/
0 commit comments