Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements the honoring of TWINE_* environment variables as per #154 #156

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/_unreleased.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[[entries]]
id = "e04c9886-b841-4ee8-b823-05d1e8dc2b37"
type = "improvement"
description = "Honor `TWINE_USERNAME` and `TWINE_PASSWORD` environment variables"
author = "@ndejong"

[[entries]]
id = "95676706-7b7b-40f3-99ac-b7149e2f81b5"
type = "feature"
Expand Down
26 changes: 21 additions & 5 deletions src/slap/ext/application/publish.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import os
import tempfile
from pathlib import Path
from typing import Iterable
Expand All @@ -25,6 +26,10 @@ class PublishCommandPlugin(Command, ApplicationPlugin):

The command-line options are almost identical to the <code>twine upload</code> command.

Twine environment variables (except TWINE_NON_INTERACTIVE) are pulled through and
assigned in the same way as with the <code>twine</code> command. Options set as CLI
options override environment variable value settings.

Note: You can combine the `-d` and `-b` options to effectively perform a build, storing
the artifacts into the specified directory but not publishing them.
"""
Expand All @@ -39,18 +44,29 @@ class PublishCommandPlugin(Command, ApplicationPlugin):
description="use this Python executable to build the distribution but do not automatically install build "
"requirements into it; if not specified a temporary build environment is created",
),
option("repository", "r", flag=False, default="pypi"),
option("repository-url", flag=False),
option(
"repository",
"r",
flag=False,
default=os.getenv("TWINE_REPOSITORY", "pypi"),
description="[env: TWINE_REPOSITORY]",
),
option(
"repository-url",
flag=False,
default=os.getenv("TWINE_REPOSITORY_URL"),
description="[env: TWINE_REPOSITORY_URL]",
),
option("sign", "s"),
option("sign-with", flag=False),
option("identity", "i", flag=False),
option("username", "u", flag=False),
option("password", "p", flag=False),
option("username", "u", flag=False, default=os.getenv("TWINE_USERNAME"), description="[env: TWINE_USERNAME]"),
option("password", "p", flag=False, default=os.getenv("TWINE_PASSWORD"), description="[env: TWINE_PASSWORD]"),
option("non-interactive"),
option("comment", "c", flag=False),
option("config-file", flag=False, default="~/.pypirc"),
option("skip-existing"),
option("cert", flag=False),
option("cert", flag=False, default=os.getenv("TWINE_CERT"), description="[env: TWINE_CERT]"),
option("client-cert", flag=False),
# option("verbose"),
option("disable-progress-bar"),
Expand Down
Loading