forked from alisaifee/flask-limiter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.sh
executable file
·37 lines (35 loc) · 1.4 KB
/
tag.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
dryrun=0
while [ "$1" != "" ]; do
case $1 in
-d | --dryrun ) dryrun=1
;;
esac
shift
done
rm -rf build dist
last_tag=$(git tag | sort -nr | head -n 1)
echo current version:$(python setup.py --version), current tag: $last_tag
read -p "new version:" new_version
last_portion=$(grep -P "^Changelog$" HISTORY.rst -5 | grep -P "^v\d+.\d+")
changelog_file=/var/tmp/flask-limiter.newchangelog
new_changelog_heading="v${new_version}"
new_changelog_heading_sep=$(python -c "print('-'*len('$new_changelog_heading'))")
echo $new_changelog_heading > $changelog_file
echo $new_changelog_heading_sep >> $changelog_file
echo "Release Date: `date +"%Y-%m-%d"`" >> $changelog_file
python -c "print(open('HISTORY.rst').read().replace('$last_portion', open('$changelog_file').read() +'\n' + '$last_portion'))" > HISTORY.rst.new
cp HISTORY.rst.new HISTORY.rst
vim -O HISTORY.rst <(echo \# vim:filetype=git;git log $last_tag..HEAD --format='* %s (%h)%n%b' | sed -E '/^\*/! s/(.*)/ \1/g')
if rst2html.py HISTORY.rst > /dev/null
then
echo "tagging $new_version"
git add HISTORY.rst
git commit -m "updating changelog for ${new_version}"
git tag -s ${new_version} -m "tagging version ${new_version}"
python setup.py build sdist bdist_egg bdist_wheel
test $dryrun != 1 && twine upload dist/*
rm HISTORY.rst.new
else
echo changelog has errors. skipping tag.
fi;