Skip to content

Instantly share code, notes, and snippets.

@jeremyfix
Last active November 29, 2020 21:17
Show Gist options
  • Save jeremyfix/2524fc83e3633f697af493168319a1c6 to your computer and use it in GitHub Desktop.
Save jeremyfix/2524fc83e3633f697af493168319a1c6 to your computer and use it in GitHub Desktop.
Accessing your pypi credentials within a gpg encrypted file to push to PyPi with your ssh key
# We suppose the PyPi username and password are stored as the last 2 lines of the file pypi.gpg given below
# then from within your python package directory, you would do :
# login@machine:~$ python3 setup.py sdist
# login@machine:~$ pypi-push
# File pypi-push (with +x permissions)
#!/bin/bash
TWINE_USERNAME=`gpg --decrypt --no-comments ~/.password-store/pypi.gpg 2> /dev/null | tail -n +2 | head -1`
TWINE_PASSWORD=`gpg --decrypt --no-comments ~/.password-store/pypi.gpg 2> /dev/null | tail -n +2 | tail -1`
TWINE_USERNAME=$TWINE_USERNAME TWINE_PASSWORD=$TWINE_PASSWORD twine upload dist/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment