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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
#!/bin/bash -e
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
if [[ ! -d venv-release ]]; then
virtualenv venv-release
echo '*' >venv-release/.gitignore
venv-release/bin/pip install -U pip setuptools sphinx wheel
fi
. $PWD/venv-release/bin/activate
pip install -e $PWD
version=
version_next=
main() {
branch="${1-$(git symbolic-ref --short HEAD)}"
version="$(python -c 'import eventlet; print(eventlet.__version__)')"
printf "\nbranch: %s eventlet.__version__: '%s'\n" $branch $version >&2
if [[ "$branch" != "master" ]]; then
echo "Must be on master" >&2
exit 1
fi
if [[ -n "$(git status --short -uall)" ]]; then
echo "Tree must be clean. git status:" >&2
echo "" >&2
git status --short -uall
echo "" >&2
exit 1
fi
last_commit_message=$(git show --format="%s" --no-patch HEAD)
expect_commit_message="v$version release"
if [[ "$last_commit_message" != "$expect_commit_message" ]]; then
printf "Last commit message: '%s' expected: '%s'\n" "$last_commit_message" "$expect_commit_message" >&2
if confirm "Create release commit? [yN] "; then
create_commit
elif ! confirm "Continue without proper release commit? [yN] "; then
exit 1
fi
fi
confirm "Continue? [yN] " || exit 1
echo "Creating tag v$version" >&2
if ! git tag "v$version"; then
echo "git tag failed " >&2
confirm "Continue still? [yN] " || exit 1
fi
if confirm "Build documentation (website)? [Yn] " >&2; then
bin/build-website.bash || exit 1
fi
if confirm "Upload to PyPi? [Yn] "; then
rm -rf build dist
python setup.py sdist bdist_wheel register upload || exit 1
fi
git push --verbose origin master gh-pages || exit 1
git push --tags
}
create_commit() {
echo "" >&2
echo "Plan:" >&2
echo "1. bump version" >&2
echo "2. update NEWS, AUTHORS" >&2
echo "3. commit" >&2
echo "4. run bin/release again" >&2
echo "" >&2
bump_version
edit_news
git diff
confirm "Ready to commit? [Yn] " || exit 1
git commit -a -m "v$version_next release"
echo "Re-exec $0 to continue" >&2
exec $0
}
bump_version() {
local current=$version
echo "Current version: '$current'" >&2
echo -n "Enter next version (empty to abort): " >&2
read version_next
if [[ -z "$version_next" ]]; then
exit 1
fi
echo "Next version: '$version_next'" >&2
local current_tuple="${current//./, }"
local next_tuple="${version_next//./, }"
local version_path="eventlet/__init__.py"
echo "Updating file '$version_path'" >&2
if ! sed -i '' -e "s/($current_tuple)/($next_tuple)/" "$version_path"; then
echo "sed error $?" >&2
exit 1
fi
if git diff --exit-code "$version_path"; then
echo "File '$version_path' is not modified" >&2
exit 1
fi
echo "" >&2
local doc_path="doc/real_index.html"
echo "Updating file '$doc_path'" >&2
if ! sed -i '' -e "s/$current/$version_next/g" "$doc_path"; then
echo "sed error $?" >&2
exit 1
fi
if git diff --exit-code "$doc_path"; then
echo "File '$doc_path' is not modified" >&2
exit 1
fi
echo "" >&2
confirm "Confirm changes? [yN] " || exit 1
}
edit_news() {
echo "Changes since last release:" >&2
git log --format='%h %an %s' "v$version"^.. -- || exit 1
echo "" >&2
local editor=$(which edit 2>/dev/null)
[[ -z "$editor" ]] && editor="$EDITOR"
if [[ -n "$editor" ]]; then
if confirm "Open default editor for NEWS and AUTHORS? [Yn] "; then
$editor NEWS
$editor AUTHORS
else
confirm "Change files NEWS and AUTHORS manually and press any key"
fi
else
echo "Unable to determine default text editor." >&2
confirm "Change files NEWS and AUTHORS manually and press any key"
fi
echo "" >&2
if git diff --exit-code NEWS AUTHORS; then
echo "Files NEWS and AUTHORS are not modified" >&2
exit 1
fi
echo "" >&2
confirm "Confirm changes? [yN] " || exit 1
}
confirm() {
local reply
local prompt="$1"
read -n1 -p "$prompt" reply >&2
echo "" >&2
rc=0
local default_y=" \[Yn\] $"
if [[ -z "$reply" ]] && [[ "$prompt" =~ $default_y ]]; then
reply="y"
fi
[[ "$reply" != "y" ]] && rc=1
return $rc
}
main "$@"
|