64
64
docker :
65
65
- image : circleci/python:3.6
66
66
67
-
68
67
steps :
69
68
- checkout
70
69
- run :
@@ -91,6 +90,107 @@ jobs:
91
90
- dist
92
91
- version.txt
93
92
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
+ deploy_pypi :
121
+ # Job to deploy on public PyPI
122
+ # Requires dist files under workspace/dist
123
+ docker :
124
+ - image : circleci/python:3.6
125
+
126
+ steps :
127
+
128
+ - attach_workspace :
129
+ at : workspace
130
+
131
+ - run :
132
+ name : Create VEnv with tools
133
+ command : |
134
+ python3 -m venv venv
135
+ . venv/bin/activate
136
+ pip install -U pip setuptools twine
137
+
138
+ - run :
139
+ name : Upload to PyPI
140
+ command : |
141
+ . venv/bin/activate
142
+ export TWINE_USERNAME="${PYPI_USERNAME}"
143
+ export TWINE_PASSWORD="${PYPI_PASSWORD}"
144
+ echo "Uploading to pypi.org"
145
+ ./venv/bin/twine upload workspace/dist/*`cat workspace/version.txt`*
146
+
147
+
148
+ install_from_test_pypi :
149
+ # Try to install from test-pypi
150
+ docker :
151
+ - image : circleci/python:3.6
152
+
153
+ steps :
154
+ - attach_workspace :
155
+ at : workspace
156
+
157
+ - run :
158
+ name : Create virtual-environment
159
+ command : |
160
+ python3 -m venv venv
161
+ . venv/bin/activate
162
+
163
+ - run :
164
+ name : Install from pip
165
+ # Try to install the same version from PyPI
166
+ command : |
167
+ . venv/bin/activate
168
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple flask-log-request-id==`cat workspace/version.txt`
169
+ pip freeze | grep -i flask-log-request-id
170
+
171
+ install_from_pypi :
172
+ # Try to install from public pypi
173
+ docker :
174
+ - image : circleci/python:3.6
175
+
176
+ steps :
177
+ - attach_workspace :
178
+ at : workspace
179
+
180
+ - run :
181
+ name : Create virtual-environment
182
+ command : |
183
+ python3 -m venv venv
184
+ . venv/bin/activate
185
+
186
+ - run :
187
+ name : Install from pip
188
+ # Try to install the same version from PyPI
189
+ command : |
190
+ . venv/bin/activate
191
+ pip install flask-log-request-id==`cat workspace/version.txt`
192
+ pip freeze | grep -i flask-log-request-id
193
+
94
194
workflows :
95
195
version : 2
96
196
test_build_deploy :
@@ -101,3 +201,34 @@ workflows:
101
201
requires :
102
202
- test-3.6
103
203
- test-3.5
204
+
205
+ - deploy_test_pypi :
206
+ filters :
207
+ branches :
208
+ only :
209
+ - staging
210
+ requires :
211
+ - build
212
+
213
+ - install_from_test_pypi :
214
+ requires :
215
+ - deploy_test_pypi
216
+
217
+ - request_permission_for_public_pypi :
218
+ type : approval
219
+ requires :
220
+ - build
221
+ filters :
222
+ tags :
223
+ only :
224
+ - /^v[\d\.]+$/
225
+ branches :
226
+ only : master
227
+
228
+ - deploy_pypi :
229
+ requires :
230
+ - request_permission_for_public_pypi
231
+
232
+ - install_from_pypi :
233
+ requires :
234
+ - deploy_pypi
0 commit comments