Skip to content

Commit eeabce4

Browse files
authored
Merge pull request #138 from fyntex/feature/upload-to-pypi-from-ci
config: Add PyPI package uploading to CI
2 parents 73ccd65 + a0500a5 commit eeabce4

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.circleci/config.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
#
1212
version: "2.1"
1313

14+
# -----BEGIN Environment Variables-----
15+
16+
# Environment variables required for deployment:
17+
#
18+
# - PYPI_PASSWORD := PyPI password or API token.
19+
# - PYPI_USERNAME := PyPI username. For API tokens, use "__token__".
20+
# - TWINE_NON_INTERACTIVE := Do not interactively prompt for credentials if they are missing.
21+
# - TWINE_REPOSITORY_URL := The repository (package index) URL to register the package to.
22+
23+
# x-deploy-environment := Deployment environment variables
24+
x-deploy-environment: &x-deploy-environment
25+
TWINE_NON_INTERACTIVE: "true"
26+
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/
27+
28+
# -----END Environment Variables-----
29+
1430
jobs:
1531
test:
1632
parameters:
@@ -95,6 +111,35 @@ jobs:
95111
path: dist
96112
destination: dist
97113

114+
- persist_to_workspace:
115+
root: ~/repo
116+
paths:
117+
- dist
118+
- venv
119+
120+
deploy:
121+
docker:
122+
- image: python:3.7.2
123+
environment:
124+
<<: *x-deploy-environment
125+
126+
working_directory: ~/repo
127+
128+
steps:
129+
- checkout
130+
131+
- attach_workspace:
132+
at: ~/repo
133+
134+
- deploy:
135+
name: Upload Artifacts to Repository
136+
command: |
137+
. venv/bin/activate
138+
139+
make upload-release \
140+
TWINE_USERNAME="${PYPI_USERNAME:?}" \
141+
TWINE_PASSWORD="${PYPI_PASSWORD:?}"
142+
98143
workflows:
99144
version: 2
100145
ci:
@@ -107,3 +152,10 @@ workflows:
107152
- "3.7.6"
108153
- "3.8.3"
109154
- dist
155+
- deploy:
156+
requires:
157+
- dist
158+
filters:
159+
branches:
160+
only:
161+
- master

docs/project-maintenance.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ Push commit ``abcd1234`` and tag ``vX.Y.Z`` automatically created by ``bumpversi
9595
4) Publish to PyPI
9696
+++++++++++++++++++
9797

98+
.. warning::
99+
Only perform this step if the CI system failed to upload the package.
100+
98101
(local workstation)
99102

100103
Run::

0 commit comments

Comments
 (0)