Skip to content

Commit

Permalink
feat: Add support for environment variables for pypi credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
relekang committed Dec 20, 2015
1 parent ab83167 commit 3b383b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion semantic_release/cli.py
Expand Up @@ -116,7 +116,10 @@ def publish(**kwargs):
)

if config.getboolean('semantic_release', 'upload_to_pypi'):
upload_to_pypi()
upload_to_pypi(
username=os.environ.get('PYPI_USERNAME'),
password=os.environ.get('PYPI_PASSWORD'),
)

if check_token():
click.echo('Updating changelog')
Expand Down
14 changes: 11 additions & 3 deletions semantic_release/pypi.py
Expand Up @@ -2,13 +2,21 @@
from twine.commands import upload as twine_upload


def upload_to_pypi(dists='sdist bdist_wheel'):
def upload_to_pypi(dists='sdist bdist_wheel', username=None, password=None):
"""
Creates the wheel and uploads to pypi with twine.
:param dists: The dists string passed to setup.py. Default: 'bdist_wheel'
"""
run('python setup.py {}'.format(dists))
twine_upload.upload(dists=['dist/*'], repository='pypi', sign=False, identity=None,
username=None, password=None, comment=None, sign_with='gpg')
twine_upload.upload(
dists=['dist/*'],
repository='pypi',
sign=False,
identity=None,
username=username,
password=password,
comment=None,
sign_with='gpg'
)
run('rm -rf build dist')

0 comments on commit 3b383b9

Please sign in to comment.