Skip to content

Commit a00751f

Browse files
committed
Let CircleCI publish the package to PyPi
1 parent f071c84 commit a00751f

File tree

4 files changed

+105
-12
lines changed

4 files changed

+105
-12
lines changed

.circleci/config.yml

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ executors:
66
version:
77
type: string
88
docker:
9-
- image: python:<< parameters.version >>-alpine
9+
- image: python:<< parameters.version >>-buster
1010
- image: postgres:11.0
1111
environment:
1212
POSTGRES_DB: 'psqlextra'
@@ -22,11 +22,11 @@ commands:
2222
steps:
2323
- run:
2424
name: Install packages
25-
command: apk add postgresql-libs gcc musl-dev postgresql-dev git
25+
command: apt-get update && apt-get install -y --no-install-recommends postgresql-client-11 libpq-dev build-essential git
2626

2727
- run:
2828
name: Install Python packages
29-
command: pip install --progress-bar off .[<< parameters.extra >>]
29+
command: pip install --progress-bar off '.[<< parameters.extra >>]'
3030

3131
run-tests:
3232
parameters:
@@ -121,14 +121,80 @@ jobs:
121121
name: Verify
122122
command: python setup.py verify
123123

124+
publish:
125+
executor:
126+
name: python
127+
version: "3.9"
128+
steps:
129+
- checkout
130+
- install-dependencies:
131+
extra: publish
132+
- run:
133+
name: Set version number
134+
command: echo "__version__ = \"${CIRCLE_TAG:1}\"" > psqlextra/_version.py
135+
- run:
136+
name: Build package
137+
command: python -m build
138+
- run:
139+
name: Publish package
140+
command: >
141+
python -m twine upload
142+
--username "${PYPI_REPO_USERNAME}"
143+
--password "${PYPI_REPO_PASSWORD}"
144+
--verbose
145+
--non-interactive
146+
--disable-progress-bar
147+
dist/*
124148
125149
workflows:
126-
version: 2
127150
build:
128151
jobs:
129-
- test-python36
130-
- test-python37
131-
- test-python38
132-
- test-python39
133-
- test-python310
134-
- analysis
152+
- test-python36:
153+
filters:
154+
tags:
155+
only: /.*/
156+
branches:
157+
only: /.*/
158+
- test-python37:
159+
filters:
160+
tags:
161+
only: /.*/
162+
branches:
163+
only: /.*/
164+
- test-python38:
165+
filters:
166+
tags:
167+
only: /.*/
168+
branches:
169+
only: /.*/
170+
- test-python39:
171+
filters:
172+
tags:
173+
only: /.*/
174+
branches:
175+
only: /.*/
176+
- test-python310:
177+
filters:
178+
tags:
179+
only: /.*/
180+
branches:
181+
only: /.*/
182+
- analysis:
183+
filters:
184+
tags:
185+
only: /.*/
186+
branches:
187+
only: /.*/
188+
- publish:
189+
requires:
190+
- test-python36
191+
- test-python37
192+
- test-python38
193+
- test-python39
194+
- test-python310
195+
- analysis
196+
filters:
197+
tags:
198+
only: /^v.*/
199+
branches:
200+
ignore: /.*/

psqlextra/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
import django
22

3+
from ._version import __version__
4+
35
if django.VERSION < (3, 2): # pragma: no cover
46
default_app_config = "psqlextra.apps.PostgresExtraAppConfig"
7+
8+
__all__ = [
9+
"default_app_config",
10+
"__version__",
11+
]
12+
else:
13+
__all__ = [
14+
"__version__",
15+
]

psqlextra/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "2.0.4"

setup.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from setuptools import find_packages, setup
66

7+
exec(open("psqlextra/_version.py").read())
8+
79

810
class BaseCommand(distutils.cmd.Command):
911
user_options = []
@@ -36,7 +38,7 @@ def run(self):
3638

3739
setup(
3840
name="django-postgres-extra",
39-
version="2.0.4",
41+
version=__version__,
4042
packages=find_packages(exclude=["tests"]),
4143
include_package_data=True,
4244
license="MIT License",
@@ -90,10 +92,23 @@ def run(self):
9092
"isort==5.10.0",
9193
"docformatter==1.4",
9294
],
95+
"publish": [
96+
"build==0.7.0",
97+
"twine==3.7.1",
98+
],
9399
},
94100
cmdclass={
95101
"lint": create_command(
96-
"Lints the code", [["flake8", "setup.py", "psqlextra", "tests"]]
102+
"Lints the code",
103+
[
104+
[
105+
"flake8",
106+
"--builtin=__version__",
107+
"setup.py",
108+
"psqlextra",
109+
"tests",
110+
]
111+
],
97112
),
98113
"lint_fix": create_command(
99114
"Lints the code",

0 commit comments

Comments
 (0)