Created
January 15, 2020 15:11
-
-
Save corentinbettiol/cf29b7a20af7e7eb6757cc3d0ded617b to your computer and use it in GitHub Desktop.
Automatically build & publish package in pypi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# 2019 - Corentin Bettiol | |
# Requires zsh, python3 & twine (python3 -m pip install --user --upgrade twine) | |
# Licenced under WTFPL v2 | |
trap ctrl_c INT | |
function ctrl_c() { | |
echo "Aborting..." | |
clean_dir | |
echo "Done." | |
exit 0 | |
} | |
function clean_dir() { | |
echo "Cleaning directories..." | |
rm -r dist/ | |
rm -r build/ | |
} | |
echo "+----------------------------------------------------------------------------------------+" | |
echo "| #//(((( |" | |
echo "| (////(((((((((( |" | |
echo "| // (((((((((( |" | |
echo "| //((((((((((((( |" | |
echo "| ////((((((((((((((# ,,,,& %###### ####### |" | |
echo "| /////(((((((((((((((## ,,,,,, ### ### ### ### |" | |
echo "| #///(((((((((((((((#### ,,,,,,, ### ### ### ## ## ##% ## |" | |
echo "| ///((((((((((((((##### ,,,,,,,, ### ### ### ## ## ### ## |" | |
echo "| /(((((((( /////////,,,,,,,,,,, ### ### ### ## ## ### ## |" | |
echo "| (((((((( ,,,,,,,,,,,,,,,,,,,,,* ### ### ### ## ## ### ## |" | |
echo "| (((((( ,,,,,,,,,,,,,,,,,,,**** ### ### ### ## ### ### ## |" | |
echo "| ((((( ,,,,,,,,,,,,,,,,****** ########### ########## ## ####### ## |" | |
echo "| ,,,,,,,,&&&&&&& ### ## ## |" | |
echo "| ,,,,,,,,,,,**** ### ## ## |" | |
echo "| ,,,,,,,,*** ** ### ##### ## |" | |
echo "| ,,,********, ## # |" | |
echo "+---------------------------------------------------------- automatic publishing tool ---+" | |
echo "" | |
echo "" | |
echo "" | |
echo "" | |
echo "" | |
if [ "$#" -ne 1 ] || [ "$1" = "--help" ] | |
then | |
if [ "$#" -ne 1 ] | |
then | |
echo "Wrong number of parameters!" | |
echo "" | |
fi | |
echo "Usage:" | |
echo " ./pypi.sh folder" | |
echo " (pypi.sh will cd into folder)" | |
echo " ./pypi.sh --help" | |
echo " (will display current help)" | |
exit 0 | |
fi | |
cd $1 | |
echo "Generating distribution archives..." | |
echo "" | |
echo "" | |
python3 setup.py sdist bdist_wheel | |
[ $? -ne 0 ] && echo "setup.py not found. Is $PWD a correct repo?" && exit 1 | |
echo "Done!" | |
echo "" | |
echo "" | |
echo "Testing if all is good without publishing anything..." | |
python3 -m twine check dist/* | |
[ $? -ne 0 ] && echo "There was a problem during checks, cancelling..." && clean_dir && exit 1 | |
echo "Done!" | |
echo "" | |
echo "" | |
echo "Do you want to publish your package now ?" | |
echo "Press Enter to continue, press CTRL+C to cancel upload." | |
read "?" | |
python3 -m twine upload dist/* | |
[ $? -ne 0 ] && echo "There was a problem during upload, cancelling..." && clean_dir && exit 1 | |
echo "✨🎂✨" | |
echo "" | |
echo "" | |
clean_dir | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment