morseman/tools/release.sh

38 lines
852 B
Bash
Raw Normal View History

2021-01-01 17:00:57 +01:00
#!/bin/bash
set -e
cd $(dirname "$0")/..
tools/test.sh
if [ ! -t 0 ] ; then
echo "release.sh should be run with a terminal attached to stdin" >&2
exit 1
fi
git status
echo -n "Previous version: v"
./setup.py --version
read -p "Enter new version: v" version
sed -i 's/version=".*"/version="'"$version"'"/' setup.py
sed -i 's/## \[Unreleased\]/&\n\n## ['"$version"'] - '"$(date --utc +%Y-%m-%d)"'/' CHANGELOG.md
echo; echo "Inspect CHANGELOG..."
${EDITOR:-nano} CHANGELOG.md
git add setup.py CHANGELOG.md
git commit -m "Bump version to $version"
tagid=v"$version"
echo "Creating git tag $tagid"
git tag -s -m "Version $version" "$tagid"
./setup.py sdist bdist_wheel
read -p "Upload to Git and PyPI? (y/N) " confirm
if [ ! "$confirm" = y ]; then "Abort"; exit 1; fi
python3 -m twine upload dist/*-${version}*
git push origin "$tagid" master