Skip to content

Instantly share code, notes, and snippets.

@birkholz
Last active May 22, 2017 23:18
Show Gist options
  • Save birkholz/ce1dd5ceaa66eb73038726e4bb40f844 to your computer and use it in GitHub Desktop.
Save birkholz/ce1dd5ceaa66eb73038726e4bb40f844 to your computer and use it in GitHub Desktop.
PyPi release script
#!/usr/bin/env bash
echo "WARNING: This will reset your working directory!"
echo "Please make sure all your changes are committed and merged into master."
read -p "Are you sure you want to continue? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Preparing to build..."
{
rm -r build & rm -r dist
git reset --hard
git checkout master
git pull --ff
} &> /dev/null
echo "Building new release..."
{
python setup.py bdist_wheel
WHEEL="$(ls -t1 dist/ | head -n 1)"
} &> /dev/null
echo "New release created:" $WHEEL
read -p "Would you like to upload to PyPi? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
{
twine upload dist/$WHEEL
} &> /dev/null
echo "Upload complete."
fi
{
rm -r build & rm -r dist
} &> /dev/null
fi
@birkholz
Copy link
Author

This script can be used to build and release new versions of packages uploaded to PyPi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment