Skip to content

Commit 2fff6ae

Browse files
szhGitHub Enterprise
authored andcommitted
Merge pull request #11 from Conjur-Enterprise/update-pypi-auth
CONJSE-1844: Update package publishing to use PyPi API token
2 parents 3b8696f + eba9d1e commit 2fff6ae

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

ci/publish/publish_package

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ publish_to_pypi
1111
}
1212

1313
check_required_vars() {
14-
REQUIRED_VARS=( "TWINE_USERNAME"
15-
"TWINE_PASSWORD" )
14+
REQUIRED_VARS=( "TWINE_API_KEY" )
1615

1716
for required_var in "${REQUIRED_VARS[@]}"; do
1817
if [[ "${!required_var}" == "" ]]; then
@@ -51,8 +50,7 @@ publish_to_pypi() {
5150
docker run --rm \
5251
-t \
5352
-e TWINE_REPOSITORY_URL \
54-
-e TWINE_USERNAME \
55-
-e TWINE_PASSWORD \
53+
-e TWINE_API_KEY \
5654
conjur-api-python3-publish bash -exc "
5755
echo 'Installing new versions of pip and wheel...'
5856
/venv/bin/pip3 install --upgrade pip wheel
@@ -63,8 +61,14 @@ publish_to_pypi() {
6361
echo 'Testing artifacts in dist/*'
6462
/venv/bin/twine check dist/*
6563
66-
echo 'Publishing package to '\$TWINE_REPOSITORY_URL' using account '\$TWINE_USERNAME'...'
67-
/venv/bin/twine upload --skip-existing --repository-url $TWINE_REPOSITORY_URL dist/*
64+
# See https://pypi.org/help/: 'How can I use API tokens to authenticate with PyPI?'
65+
echo 'Publishing package to '\$TWINE_REPOSITORY_URL' using API token...'
66+
/venv/bin/twine upload \
67+
--skip-existing \
68+
--repository-url $TWINE_REPOSITORY_URL \
69+
--username __token__ \
70+
--password $TWINE_API_KEY \
71+
dist/*
6872
"
6973
}
7074

secrets.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ common:
22
ADMIN_PASSWORD: !var ci/generics/conjur-admin-password
33

44
production:
5-
TWINE_USERNAME: !var ecosystems/pypi/users/conjur/username
6-
TWINE_PASSWORD: !var ecosystems/pypi/users/conjur/password
5+
TWINE_API_KEY: !var ecosystems/pypi/users/conjur/apikey
76

87
# https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
98
# NOTE: Sometimes, test PyPI wipes their DB so re-registration will be needed
109
testing:
11-
TWINE_USERNAME: !var ecosystems/pypi/test-users/conjur/username
12-
TWINE_PASSWORD: !var ecosystems/pypi/test-users/conjur/password
10+
TWINE_API_KEY: !var ecosystems/pypi/test-users/conjur/apikey

0 commit comments

Comments
 (0)