Skip to content

Commit f65521e

Browse files
committed
tasks: add release task for publishing Pip
1 parent 2a9906e commit f65521e

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ name = "hpdf"
2323
dynamic = ["version"]
2424
description = "Python client for HTML2PDF JavaScript library."
2525
readme = "README.md"
26-
license = "TBD"
26+
license = { file = "LICENSE" }
2727
requires-python = ">=3.8"
2828
authors = [
2929
{ name = "Stanislav Pankevich", email = "s.pankevich@gmail.com" },

tasks.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,57 @@ def clean_itest_artifacts(context):
191191
# The command sometimes exits with 1 even if the files are deleted.
192192
# warn=True ensures that the execution continues.
193193
run_invoke(context, find_command, warn=True)
194+
195+
196+
@task
197+
def release(context, test_pypi=False, username=None, password=None):
198+
"""
199+
A release can be made to PyPI or test package index (TestPyPI):
200+
https://pypi.org/project/hpdf/
201+
https://test.pypi.org/project/hpdf/
202+
"""
203+
204+
# When a username is provided, we also need password, and then we don't use
205+
# tokens set up on a local machine.
206+
assert username is None or password is not None
207+
208+
repository_argument_or_none = (
209+
""
210+
if username
211+
else (
212+
"--repository hpdf_test"
213+
if test_pypi
214+
else "--repository hpdf_release"
215+
)
216+
)
217+
user_password = f"-u{username} -p{password}" if username is not None else ""
218+
219+
run_invoke(
220+
context,
221+
"""
222+
rm -rfv dist/
223+
""",
224+
)
225+
run_invoke(
226+
context,
227+
"""
228+
python3 -m build
229+
""",
230+
)
231+
run_invoke(
232+
context,
233+
"""
234+
twine check dist/*
235+
""",
236+
)
237+
# The token is in a core developer's .pypirc file.
238+
# https://test.pypi.org/manage/account/token/
239+
# https://packaging.python.org/en/latest/specifications/pypirc/#pypirc
240+
run_invoke(
241+
context,
242+
f"""
243+
twine upload dist/hpdf-*.tar.gz
244+
{repository_argument_or_none}
245+
{user_password}
246+
""",
247+
)

0 commit comments

Comments
 (0)