cyberark/cyberark-conjur-cli

View on GitHub
bin/publish_package

Summary

Maintainability
Test Coverage
#!/bin/bash -e
 
CURRENT_DIR=$(pwd)
 
$CURRENT_DIR/bin/build_publish_container
 
REQUIRED_VARS=( "TWINE_REPOSITORY_URL"
"TWINE_USERNAME"
"TWINE_PASSWORD" )
 
# Sanity check
for required_var in "${REQUIRED_VARS[@]}"; do
if [[ "${!required_var}" == "" ]]; then
echo "ERROR: '$required_var' not set!"
exit 1
fi
done
 
echo "Publishing to PyPI..."
rm -rf $CURRENT_DIR/dist/
docker run --rm \
-t \
-e TWINE_REPOSITORY_URL \
-e TWINE_USERNAME \
-e TWINE_PASSWORD \
-v "$(pwd):/opt/cyberark-conjur-cli" \
cyberark-conjur-cli-publish bash -exc "
echo 'Installing new versions of pip and wheel...'
/usr/bin/env pip3 install --upgrade pip wheel
 
if ! ./bin/needs_publishing \$TWINE_REPOSITORY_URL; then
echo 'WARN: Publishing skipped!'
exit 1
fi
 
echo 'Building distributable package...'
/usr/bin/env python3 setup.py sdist bdist_wheel
 
echo 'Testing artifacts in dist/*'
/usr/bin/env twine check dist/*
 
echo 'Publishing package to \$TWINE_REPOSITORY_URL using account '\$TWINE_USERNAME'...'
/usr/bin/env twine upload dist/*
"