Skip to content

Commit 796eb02

Browse files
committed
[circle] Add support for deploying on PyPI infrastructure
1 parent 19bbc24 commit 796eb02

File tree

1 file changed

+77
-1
lines changed

1 file changed

+77
-1
lines changed

.circleci/config.yml

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
docker:
6565
- image: circleci/python:3.6
6666

67-
6867
steps:
6968
- checkout
7069
- run:
@@ -91,6 +90,56 @@ jobs:
9190
- dist
9291
- version.txt
9392

93+
deploy_test_pypi: &deploy_template
94+
# Job to deploy on test environment
95+
# Requires dist files under workspace/dist
96+
docker:
97+
- image: circleci/python:3.6
98+
99+
steps:
100+
101+
- attach_workspace:
102+
at: workspace
103+
104+
- run:
105+
name: Create VEnv with tools
106+
command: |
107+
python3 -m venv venv
108+
. venv/bin/activate
109+
pip install -U pip setuptools twine
110+
111+
- run:
112+
name: Upload to PyPI
113+
command: |
114+
. venv/bin/activate
115+
export TWINE_USERNAME="${PYPI_TEST_USERNAME}"
116+
export TWINE_PASSWORD="${PYPI_TEST_PASSWORD}"
117+
echo "Uploading to test.pypi.org"
118+
./venv/bin/twine upload --repository-url https://test.pypi.org/legacy/ workspace/dist/*`cat workspace/version.txt`*
119+
120+
install_test_pypi:
121+
# Try to install from test-pip
122+
docker:
123+
- image: circleci/python:3.6
124+
125+
steps:
126+
- attach_workspace:
127+
at: workspace
128+
129+
- run:
130+
name: Create virtual-environment
131+
command: |
132+
python3 -m venv venv
133+
. venv/bin/activate
134+
135+
- run:
136+
name: Install from pip
137+
# Try to install the same version from PyPI
138+
command: |
139+
. venv/bin/activate
140+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple flask-log-request-id==`cat workspace/version.txt`
141+
pip freeze | grep -i flask-log-request-id
142+
94143
workflows:
95144
version: 2
96145
test_build_deploy:
@@ -101,3 +150,30 @@ workflows:
101150
requires:
102151
- test-3.6
103152
- test-3.5
153+
154+
- deploy_test_pypi:
155+
filters:
156+
branches:
157+
only:
158+
- staging
159+
requires:
160+
- build
161+
- install_test_pypi:
162+
requires:
163+
- deploy_test_pypi
164+
165+
166+
- request_permission_for_public_pypi:
167+
type: approval
168+
requires:
169+
- build
170+
filters:
171+
tags:
172+
only:
173+
- /^v[\d\.]+$/
174+
branches:
175+
only: master
176+
177+
- deploy_pypi:
178+
requires:
179+
- request_permission_for_public_pypi

0 commit comments

Comments
 (0)