release_helper.sh
259 lines
| 6.7 KiB
| application/x-sh
|
BashLexer
/ tools / release_helper.sh
|
r24981 | # Simple tool to help for release | ||
|
r28436 | # when releasing with bash, simple source it to get asked questions. | ||
|
r24981 | |||
|
r25157 | # misc check before starting | ||
|
r25179 | BLACK=$(tput setaf 1) | ||
|
r25128 | RED=$(tput setaf 1) | ||
|
r25179 | GREEN=$(tput setaf 2) | ||
YELLOW=$(tput setaf 3) | ||||
BLUE=$(tput setaf 4) | ||||
MAGENTA=$(tput setaf 5) | ||||
CYAN=$(tput setaf 6) | ||||
WHITE=$(tput setaf 7) | ||||
|
r25128 | NOR=$(tput sgr0) | ||
|
r24981 | |||
|
r28004 | echo "Checking all tools are installed..." | ||
python -c 'import keyring' | ||||
python -c 'import twine' | ||||
python -c 'import sphinx' | ||||
python -c 'import sphinx_rtd_theme' | ||||
python -c 'import pytest' | ||||
python -c 'import build' | ||||
# those are necessary fo building the docs | ||||
echo "Checking imports for docs" | ||||
python -c 'import numpy' | ||||
python -c 'import matplotlib' | ||||
|
r27183 | echo "Will use $BLUE'$EDITOR'$NOR to edit files when necessary" | ||
|
r25282 | echo -n "PREV_RELEASE (X.y.z) [$PREV_RELEASE]: " | ||
read input | ||||
PREV_RELEASE=${input:-$PREV_RELEASE} | ||||
echo -n "MILESTONE (X.y) [$MILESTONE]: " | ||||
read input | ||||
MILESTONE=${input:-$MILESTONE} | ||||
echo -n "VERSION (X.y.z) [$VERSION]:" | ||||
read input | ||||
VERSION=${input:-$VERSION} | ||||
|
r27712 | echo -n "BRANCH (main|X.y) [$BRANCH]:" | ||
|
r25282 | read input | ||
|
r25300 | BRANCH=${input:-$BRANCH} | ||
|
r25282 | |||
ask_section(){ | ||||
echo | ||||
|
r27183 | echo $BLUE"$1"$NOR | ||
|
r25411 | echo -n $GREEN"Press Enter to continue, S to skip: "$NOR | ||
|
r27183 | if [ "$ZSH_NAME" = "zsh" ] ; then | ||
read -k1 value | ||||
value=${value%$'\n'} | ||||
else | ||||
read -n1 value | ||||
fi | ||||
if [ -z "$value" ] || [ $value = 'y' ]; then | ||||
|
r25282 | return 0 | ||
fi | ||||
return 1 | ||||
} | ||||
|
r24982 | |||
|
r26558 | maybe_edit(){ | ||
echo | ||||
|
r28436 | echo $BLUE"$1"$NOR | ||
|
r27183 | echo -n $GREEN"Press ${BLUE}e$GREEN to Edit ${BLUE}$1$GREEN, any other keys to skip: "$NOR | ||
if [ "$ZSH_NAME" = "zsh" ] ; then | ||||
read -k1 value | ||||
value=${value%$'\n'} | ||||
else | ||||
read -n1 value | ||||
fi | ||||
|
r28436 | echo | ||
|
r26558 | if [ $value = 'e' ] ; then | ||
|
r27183 | $=EDITOR $1 | ||
|
r26558 | fi | ||
} | ||||
|
r24981 | |||
|
r28436 | echo | ||
|
r26875 | if ask_section "Updating what's new with information from docs/source/whatsnew/pr" | ||
|
r25282 | then | ||
python tools/update_whatsnew.py | ||||
echo | ||||
echo $BLUE"please move the contents of "docs/source/whatsnew/development.rst" to version-X.rst"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
fi | ||||
if ask_section "Gen Stats, and authors" | ||||
then | ||||
|
r28436 | echo | ||
|
r25282 | echo $BLUE"here are all the authors that contributed to this release:"$NOR | ||
git log --format="%aN <%aE>" $PREV_RELEASE... | sort -u -f | ||||
|
r28436 | echo | ||
|
r25298 | echo $BLUE"If you see any duplicates cancel (Ctrl-C), then edit .mailmap." | ||
echo $GREEN"Press enter to continue:"$NOR | ||||
|
r25282 | read | ||
echo $BLUE"generating stats"$NOR | ||||
python tools/github_stats.py --milestone $MILESTONE > stats.rst | ||||
|
r24981 | |||
|
r25282 | echo $BLUE"stats.rst files generated."$NOR | ||
echo $GREEN"Please merge it with the right file (github-stats-X.rst) and commit."$NOR | ||||
echo $GREEN"press enter to continue."$NOR | ||||
read | ||||
|
r24981 | |||
|
r25282 | fi | ||
|
r24981 | |||
|
r25776 | if ask_section "Generate API difference (using frapuccino)" | ||
then | ||||
echo $BLUE"Checking out $PREV_RELEASE"$NOR | ||||
|
r28493 | git checkout tags/$PREV_RELEASE | ||
|
r27311 | sleep 1 | ||
|
r25776 | echo $BLUE"Saving API to file $PREV_RELEASE"$NOR | ||
|
r27311 | frappuccino IPython IPython.kernel IPython.lib IPython.qt IPython.lib.kernel IPython.html IPython.frontend IPython.external --save IPython-$PREV_RELEASE.json | ||
|
r27520 | echo $BLUE"coming back to $BRANCH"$NOR | ||
|
r28436 | git switch $BRANCH | ||
|
r27311 | sleep 1 | ||
|
r25776 | echo $BLUE"comparing ..."$NOR | ||
|
r27311 | frappuccino IPython IPython.kernel IPython.lib --compare IPython-$PREV_RELEASE.json | ||
|
r25776 | echo $GREEN"Use the above guideline to write an API changelog ..."$NOR | ||
echo $GREEN"Press any keys to continue"$NOR | ||||
read | ||||
fi | ||||
|
r24981 | echo "Cleaning repository" | ||
git clean -xfdi | ||||
|
r25182 | echo $GREEN"please update version number in ${RED}IPython/core/release.py${NOR} , Do not commit yet – we'll do it later."$NOR | ||
|
r25946 | echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py${NOR}" | ||
sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py | ||||
rm IPython/core/release.pybkp | ||||
|
r27183 | git diff | cat | ||
|
r26558 | maybe_edit IPython/core/release.py | ||
|
r24981 | |||
|
r25182 | echo $GREEN"Press enter to continue"$NOR | ||
|
r24981 | read | ||
|
r24982 | |||
|
r25314 | if ask_section "Build the documentation ?" | ||
then | ||||
make html -C docs | ||||
|
r28436 | echo | ||
|
r25314 | echo $GREEN"Check the docs, press enter to continue"$NOR | ||
read | ||||
|
r24982 | |||
|
r25314 | fi | ||
|
r24982 | |||
|
r25315 | if ask_section "Should we commit, tag, push... etc ? " | ||
|
r25314 | then | ||
echo | ||||
|
r25406 | echo $BLUE"Let's commit : git commit -am \"release $VERSION\" -S" | ||
|
r25314 | echo $GREEN"Press enter to commit"$NOR | ||
read | ||||
git commit -am "release $VERSION" -S | ||||
|
r28436 | |||
|
r25314 | echo | ||
echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR | ||||
echo $GREEN"Make sure you can push"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
git push origin $BRANCH | ||||
|
r28436 | |||
|
r25314 | echo | ||
echo "Let's tag : git tag -am \"release $VERSION\" \"$VERSION\" -s" | ||||
echo $GREEN"Press enter to tag commit"$NOR | ||||
read | ||||
git tag -am "release $VERSION" "$VERSION" -s | ||||
|
r28436 | |||
|
r25314 | echo | ||
echo $BLUE"And push the tag: git push origin \$VERSION ?"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
git push origin $VERSION | ||||
|
r28436 | |||
|
r25314 | echo $GREEN"please update version number and back to .dev in ${RED}IPython/core/release.py" | ||
|
r25946 | echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py${NOR}" | ||
sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py | ||||
rm IPython/core/release.pybkp | ||||
|
r27183 | git diff | cat | ||
|
r25946 | echo $GREEN"Please bump ${RED}the minor version number${NOR}" | ||
|
r26558 | maybe_edit IPython/core/release.py | ||
|
r25314 | echo ${BLUE}"Do not commit yet – we'll do it later."$NOR | ||
|
r25946 | |||
|
r28436 | |||
|
r25314 | echo $GREEN"Press enter to continue"$NOR | ||
read | ||||
|
r28436 | |||
|
r25314 | echo | ||
|
r25404 | echo "Let's commit : "$BLUE"git commit -am \"back to dev\""$NOR | ||
|
r25314 | echo $GREEN"Press enter to commit"$NOR | ||
read | ||||
|
r25404 | git commit -am "back to dev" | ||
|
r25412 | |||
echo | ||||
echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
git push origin $BRANCH | ||||
|
r28436 | |||
|
r25314 | echo | ||
|
r28493 | echo $BLUE"let's : git checkout tags/$VERSION"$NOR | ||
|
r25314 | echo $GREEN"Press enter to continue"$NOR | ||
read | ||||
|
r28493 | git checkout tags/$VERSION | ||
|
r25314 | fi | ||
|
r25300 | |||
|
r25314 | if ask_section "Should we build and release ?" | ||
then | ||||
|
r28436 | |||
|
r25769 | echo $BLUE"going to set SOURCE_DATE_EPOCH"$NOR | ||
echo $BLUE'export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)'$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) | ||||
echo $BLUE"SOURCE_DATE_EPOCH set to $SOURCE_DATE_EPOCH"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
echo | ||||
echo $BLUE"Attempting to build package..."$NOR | ||||
|
r28817 | tools/build_release | ||
|
r25769 | |||
echo $RED'$ shasum -a 256 dist/*' | ||||
shasum -a 256 dist/* | ||||
echo $NOR | ||||
echo $BLUE"We are going to rebuild, node the hash above, and compare them to the rebuild"$NOR | ||||
echo $GREEN"Press enter to continue"$NOR | ||||
read | ||||
|
r25300 | |||
|
r25314 | echo | ||
echo $BLUE"Attempting to build package..."$NOR | ||||
|
r25275 | |||
|
r28817 | tools/build_release | ||
|
r25284 | |||
|
r25769 | echo $RED"Check the shasum for SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" | ||
echo $RED'$ shasum -a 256 dist/*' | ||||
|
r25314 | shasum -a 256 dist/* | ||
|
r25404 | echo $NOR | ||
|
r25128 | |||
|
r25314 | if ask_section "upload packages ?" | ||
|
r28436 | then | ||
|
r28817 | twine upload --verbose dist/*.tar.gz dist/*.whl | ||
|
r25314 | fi | ||
fi | ||||