Finally get a release out with this script.

This commit is contained in:
Dave Halter
2017-08-31 22:41:28 +02:00
parent 5c3304f7c2
commit 4b32408001

View File

@@ -5,45 +5,48 @@
set -eu -o pipefail set -eu -o pipefail
BASE_DIR=$(dirname $(readlink -f "$0")) BASE_DIR=$(dirname $(readlink -f "$0"))
cd $(BASE_DIR) cd $BASE_DIR
git fetch --tags
PROJECT_NAME=parso PROJECT_NAME=parso
BRANCH=master BRANCH=master
BUILD_FOLDER=build BUILD_FOLDER=build
FOLDER=$BUILD_FOLDER/$PROJECT_NAME
# Test first.
#tox
[ -d $BUILD_FOLDER ] || mkdir $BUILD_FOLDER [ -d $BUILD_FOLDER ] || mkdir $BUILD_FOLDER
# Remove the previous deployment first. # Remove the previous deployment first.
rm -rf $FOLDER
# Checkout the right branch # Checkout the right branch
cd $BUILD_FOLDER cd $BUILD_FOLDER
rm -rf $PROJECT_NAME
git clone .. $PROJECT_NAME git clone .. $PROJECT_NAME
cd $PROJECT_NAME
git checkout $BRANCH git checkout $BRANCH
# Test first.
tox
# Create tag # Create tag
tag=v$(python -c "import $PROJECT_NAME; print($PROJECT_NAME.__version__)") tag=v$(python -c "import $PROJECT_NAME; print($PROJECT_NAME.__version__)")
master_ref=$(git show-ref -s $BRANCH) master_ref=$(git show-ref -s heads/$BRANCH)
tag_ref=$(git show-ref -s $tag | true) tag_ref=$(git show-ref -s $tag || true)
if [ $tag_ref ]; then if [[ $tag_ref ]]; then
if [ $tag_ref != $master_ref ]; then if [[ $tag_ref != $master_ref ]]; then
echo 'Cannot tag something that has already been tagged with another commit.' echo 'Cannot tag something that has already been tagged with another commit.'
exit 1 exit 1
fi fi
else else
git tag $BRANCH git tag $tag
git push --tags git push --tags
fi fi
# Package and upload to PyPI # Package and upload to PyPI
rm -rf dist/ #rm -rf dist/ - Not needed anymore, because the folder is never reused.
echo `pwd`
python setup.py sdist bdist_wheel python setup.py sdist bdist_wheel
# Maybe do a pip install twine before. # Maybe do a pip install twine before.
twine upload dist/* twine upload dist/*
cd $(BASE_DIR) cd $BASE_DIR
# Back in the development directory fetch tags. # Back in the development directory fetch tags.
git fetch --tags git fetch --tags