build: automate release commit
This commit is contained in:
@@ -53,8 +53,7 @@ rm -f "doc/changelog.rst"
|
||||
|
||||
if [ $commit -eq 1 ]; then
|
||||
echo "3. Updating git branch gh-pages"
|
||||
source_name=`git rev-parse --abbrev-ref HEAD`
|
||||
source_id=`git rev-parse --short HEAD`
|
||||
source_name=`git describe --dirty --tags HEAD`
|
||||
git branch --track gh-pages origin/gh-pages || true
|
||||
git checkout gh-pages
|
||||
git ls-files |grep -Ev '^.gitignore$' |xargs rm -f
|
||||
@@ -70,5 +69,5 @@ if [ $commit -eq 1 ]; then
|
||||
git status
|
||||
|
||||
read -p "Carefully read git status output above, press Enter to continue or Ctrl+C to abort"
|
||||
git commit --edit -m "Website built from $source_name $source_id"
|
||||
git commit --edit -m "Website built from $source_name"
|
||||
fi
|
||||
|
||||
134
bin/release
134
bin/release
@@ -3,7 +3,7 @@ cd "$( dirname "${BASH_SOURCE[0]}" )/.."
|
||||
if [[ ! -d venv-release ]]; then
|
||||
virtualenv venv-release
|
||||
echo '*' >venv-release/.gitignore
|
||||
venv-release/bin/pip install wheel sphinx
|
||||
venv-release/bin/pip install -U pip setuptools sphinx wheel
|
||||
fi
|
||||
. $PWD/venv-release/bin/activate
|
||||
pip install -e $PWD
|
||||
@@ -11,38 +11,150 @@ pip install -e $PWD
|
||||
main() {
|
||||
branch="${1-$(git symbolic-ref --short HEAD)}"
|
||||
version="$(python -c 'import eventlet; print(eventlet.__version__)')"
|
||||
printf "branch: %s version: '%s'\n" $branch $version >&2
|
||||
printf "\nbranch: %s eventlet.__version__: '%s'\n" $branch $version >&2
|
||||
if [[ "$branch" != "master" ]]; then
|
||||
echo "Must be on master" >&2
|
||||
exit 1
|
||||
fi
|
||||
create_commit
|
||||
exit 1
|
||||
if [[ -n "$(git status --short -uall)" ]]; then
|
||||
echo "Tree must be clean" >&2
|
||||
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 "tag failed" >&2
|
||||
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
|
||||
python setup.py sdist bdist_wheel register upload || exit 1
|
||||
fi
|
||||
|
||||
bin/build-website.bash
|
||||
|
||||
git push origin master
|
||||
git push --verbose origin master gh-pages || exit 1
|
||||
git push --tags
|
||||
git push origin gh-pages
|
||||
}
|
||||
|
||||
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 release"
|
||||
|
||||
echo "Re-exec $0 to continue" >&2
|
||||
exec $0
|
||||
}
|
||||
|
||||
bump_version() {
|
||||
local current=$version
|
||||
local next
|
||||
echo "Current version: '$current'" >&2
|
||||
echo -n "Enter next version (empty to abort): " >&2
|
||||
read next
|
||||
if [[ -z "$next" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
echo "Next version: '$next'" >&2
|
||||
|
||||
local current_tuple="${current//./, }"
|
||||
local next_tuple="${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/$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() {
|
||||
read -n1 -p "$1" reply
|
||||
echo ""
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user