Skip to content

Commit f9ea8e9

Browse files
author
Rami Chowdhury
committed
Add Circle build & publish config
1 parent 4adf841 commit f9ea8e9

File tree

4 files changed

+561
-13
lines changed

4 files changed

+561
-13
lines changed

.circleci/config.yml

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,74 @@
1+
# with thanks to https://dev.to/jonatasbaldin/a-recipe-for-poetry-and-circleci-1bj6
12
version: 2.1
23
jobs:
3-
build:
4+
# Building and testing the project
5+
# Useful when a PR is open, for example
6+
build-and-test:
47
docker:
5-
- image: themattrix/tox
8+
- image: circleci/python:3.7.3 # includes `poetry`!
9+
# The steps for our build-and-test
610
steps:
711
- checkout
8-
- run: tox
12+
13+
# Cache can be tricky at first, but this means restore the cache if the text key
14+
# `deps-{{ checksum "poetry.lock" }}` changes (and it WILL change every time poetry.lock
15+
# is updated since we rely on its checksum) and poetry.lock is updated every time we add
16+
# a new dependency to our project
17+
- restore_cache:
18+
keys:
19+
- deps-{{ checksum "poetry.lock" }}
20+
21+
- run:
22+
name: install dependencies
23+
command: |
24+
poetry install
25+
26+
# Save the specified path as a cache. This is the path Poetry uses to install the dependencies
27+
# So if you don't install anything new, this folder won't change and the cache will be effective
28+
- save_cache:
29+
key: deps-{{ checksum "poetry.lock" }}
30+
paths:
31+
- /home/circleci/.cache/pypoetry/virtualenvs
32+
33+
- run:
34+
name: Run all the testing steps
35+
command: |
36+
poetry run tox
37+
38+
deployment:
39+
docker:
40+
- image: circleci/python:3.7.3
41+
steps:
42+
- checkout
43+
- run:
44+
name: publish to PyPI
45+
command: |
46+
poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction
47+
48+
# When to run which job
49+
workflows:
50+
version: 2.1
51+
52+
build-and-test-workflow:
53+
jobs:
54+
- build-and-test
55+
56+
# The deployment workflow publishes the package, and is only run on a Git tag matching a
57+
# version regex
58+
deployment-workflow:
59+
jobs:
60+
- build-and-test:
61+
filters:
62+
tags:
63+
only: /v[0-9]+(\.[0-9]+)*/
64+
branches:
65+
ignore: /.*/
66+
67+
- deployment:
68+
requires:
69+
- build-and-test
70+
filters:
71+
tags:
72+
only: /v[0-9]+(\.[0-9]+)*/
73+
branches:
74+
ignore: /.*/

0 commit comments

Comments
 (0)