| 1 |
# Simple tool to help for release |
| 2 |
# when releasing with bash, simple source it to get asked questions. |
| 3 |
|
| 4 |
# misc check before starting |
| 5 |
BLACK=$(tput setaf 1) |
| 6 |
RED=$(tput setaf 1) |
| 7 |
GREEN=$(tput setaf 2) |
| 8 |
YELLOW=$(tput setaf 3) |
| 9 |
BLUE=$(tput setaf 4) |
| 10 |
MAGENTA=$(tput setaf 5) |
| 11 |
CYAN=$(tput setaf 6) |
| 12 |
WHITE=$(tput setaf 7) |
| 13 |
NOR=$(tput sgr0) |
| 14 |
|
| 15 |
|
| 16 |
echo "Checking all tools are installed..." |
| 17 |
|
| 18 |
python -c 'import keyring' |
| 19 |
python -c 'import twine' |
| 20 |
python -c 'import sphinx' |
| 21 |
python -c 'import sphinx_rtd_theme' |
| 22 |
python -c 'import pytest' |
| 23 |
python -c 'import build' |
| 24 |
# those are necessary fo building the docs |
| 25 |
echo "Checking imports for docs" |
| 26 |
python -c 'import numpy' |
| 27 |
python -c 'import matplotlib' |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
echo "Will use $BLUE'$EDITOR'$NOR to edit files when necessary" |
| 33 |
# echo -n "PREV_RELEASE (X.y.z) [$PREV_RELEASE]: " |
| 34 |
# read input |
| 35 |
# PREV_RELEASE=${input:-$PREV_RELEASE} |
| 36 |
# echo -n "MILESTONE (X.y) [$MILESTONE]: " |
| 37 |
# read input |
| 38 |
# MILESTONE=${input:-$MILESTONE} |
| 39 |
echo -n "VERSION (X.y.z) [$VERSION]:" |
| 40 |
read input |
| 41 |
VERSION=${input:-$VERSION} |
| 42 |
echo -n "BRANCH (main|X.y) [$BRANCH]:" |
| 43 |
read input |
| 44 |
BRANCH=${input:-$BRANCH} |
| 45 |
|
| 46 |
ask_section(){ |
| 47 |
echo |
| 48 |
echo $BLUE"$1"$NOR |
| 49 |
echo -n $GREEN"Press Enter to continue, S to skip: "$NOR |
| 50 |
if [ "$ZSH_NAME" = "zsh" ] ; then |
| 51 |
read -k1 value |
| 52 |
value=${value%$'\n'} |
| 53 |
else |
| 54 |
read -n1 value |
| 55 |
fi |
| 56 |
if [ -z "$value" ] || [ $value = 'y' ]; then |
| 57 |
return 0 |
| 58 |
fi |
| 59 |
return 1 |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
maybe_edit(){ |
| 64 |
echo |
| 65 |
echo $BLUE"$1"$NOR |
| 66 |
echo -n $GREEN"Press ${BLUE}e$GREEN to Edit ${BLUE}$1$GREEN, any other keys to skip: "$NOR |
| 67 |
if [ "$ZSH_NAME" = "zsh" ] ; then |
| 68 |
read -k1 value |
| 69 |
value=${value%$'\n'} |
| 70 |
else |
| 71 |
read -n1 value |
| 72 |
fi |
| 73 |
|
| 74 |
echo |
| 75 |
if [ "$value" = 'e' ] ; then |
| 76 |
$EDITOR $1 |
| 77 |
fi |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
echo |
| 83 |
if ask_section "Updating what's new with information from docs/source/whatsnew/pr" |
| 84 |
then |
| 85 |
python tools/update_whatsnew.py |
| 86 |
|
| 87 |
echo |
| 88 |
echo $BLUE"please move the contents of "docs/source/whatsnew/development.rst" to version-X.rst"$NOR |
| 89 |
echo $GREEN"Press enter to continue"$NOR |
| 90 |
read |
| 91 |
fi |
| 92 |
|
| 93 |
# if ask_section "Generate API difference (using frapuccino)" |
| 94 |
# then |
| 95 |
# echo $BLUE"Checking out $PREV_RELEASE"$NOR |
| 96 |
# git checkout tags/$PREV_RELEASE |
| 97 |
# sleep 1 |
| 98 |
# echo $BLUE"Saving API to file $PREV_RELEASE"$NOR |
| 99 |
# frappuccino IPython IPython.kernel IPython.lib IPython.qt IPython.lib.kernel IPython.html IPython.frontend IPython.external --save IPython-$PREV_RELEASE.json |
| 100 |
# echo $BLUE"coming back to $BRANCH"$NOR |
| 101 |
# git switch $BRANCH |
| 102 |
# sleep 1 |
| 103 |
# echo $BLUE"comparing ..."$NOR |
| 104 |
# frappuccino IPython IPython.kernel IPython.lib --compare IPython-$PREV_RELEASE.json |
| 105 |
# echo $GREEN"Use the above guideline to write an API changelog ..."$NOR |
| 106 |
# echo $GREEN"Press any keys to continue"$NOR |
| 107 |
# read |
| 108 |
# fi |
| 109 |
|
| 110 |
echo "Cleaning repository" |
| 111 |
git clean -xfdi |
| 112 |
|
| 113 |
echo $GREEN"please update version number in ${RED}IPython/core/release.py${NOR} , Do not commit yet – we'll do it later."$NOR |
| 114 |
echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py${NOR}" |
| 115 |
sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py |
| 116 |
rm IPython/core/release.pybkp |
| 117 |
git diff | cat |
| 118 |
maybe_edit IPython/core/release.py |
| 119 |
|
| 120 |
echo $GREEN"Press enter to continue"$NOR |
| 121 |
read |
| 122 |
|
| 123 |
if ask_section "Build the documentation ?" |
| 124 |
then |
| 125 |
make html -C docs |
| 126 |
echo |
| 127 |
echo $GREEN"Check the docs, press enter to continue"$NOR |
| 128 |
read |
| 129 |
|
| 130 |
fi |
| 131 |
|
| 132 |
if ask_section "Should we commit, tag, push... etc ? " |
| 133 |
then |
| 134 |
echo |
| 135 |
echo $BLUE"Let's commit : git commit -am \"release $VERSION\" -S" |
| 136 |
echo $GREEN"Press enter to commit"$NOR |
| 137 |
read |
| 138 |
git commit -am "release $VERSION" -S |
| 139 |
|
| 140 |
echo |
| 141 |
echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR |
| 142 |
echo $GREEN"Make sure you can push"$NOR |
| 143 |
echo $GREEN"Press enter to continue"$NOR |
| 144 |
read |
| 145 |
git push origin $BRANCH |
| 146 |
|
| 147 |
echo |
| 148 |
echo "Let's tag : git tag -am \"release $VERSION\" \"$VERSION\" -s" |
| 149 |
echo $GREEN"Press enter to tag commit"$NOR |
| 150 |
read |
| 151 |
git tag -am "release $VERSION" "$VERSION" -s |
| 152 |
|
| 153 |
echo |
| 154 |
echo $BLUE"And push the tag: git push origin \$VERSION ?"$NOR |
| 155 |
echo $GREEN"Press enter to continue"$NOR |
| 156 |
read |
| 157 |
git push origin $VERSION |
| 158 |
|
| 159 |
|
| 160 |
echo $GREEN"please update version number and back to .dev in ${RED}IPython/core/release.py" |
| 161 |
echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py${NOR}" |
| 162 |
sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py |
| 163 |
rm IPython/core/release.pybkp |
| 164 |
git diff | cat |
| 165 |
echo $GREEN"Please bump ${RED}the minor version number${NOR}" |
| 166 |
maybe_edit IPython/core/release.py |
| 167 |
echo ${BLUE}"Do not commit yet – we'll do it later."$NOR |
| 168 |
|
| 169 |
|
| 170 |
echo $GREEN"Press enter to continue"$NOR |
| 171 |
read |
| 172 |
|
| 173 |
echo |
| 174 |
echo "Let's commit : "$BLUE"git commit -am \"back to dev\""$NOR |
| 175 |
echo $GREEN"Press enter to commit"$NOR |
| 176 |
read |
| 177 |
git commit -am "back to dev" |
| 178 |
|
| 179 |
echo |
| 180 |
echo $BLUE"git push origin \$BRANCH ($BRANCH)?"$NOR |
| 181 |
echo $GREEN"Press enter to continue"$NOR |
| 182 |
read |
| 183 |
git push origin $BRANCH |
| 184 |
|
| 185 |
|
| 186 |
echo |
| 187 |
echo $BLUE"let's : git checkout tags/$VERSION"$NOR |
| 188 |
echo $GREEN"Press enter to continue"$NOR |
| 189 |
read |
| 190 |
git checkout tags/$VERSION |
| 191 |
fi |
| 192 |
|
| 193 |
if ask_section "Should we build and release ?" |
| 194 |
then |
| 195 |
|
| 196 |
echo $BLUE"going to set SOURCE_DATE_EPOCH"$NOR |
| 197 |
echo $BLUE'export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)'$NOR |
| 198 |
echo $GREEN"Press enter to continue"$NOR |
| 199 |
read |
| 200 |
|
| 201 |
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) |
| 202 |
|
| 203 |
echo $BLUE"SOURCE_DATE_EPOCH set to $SOURCE_DATE_EPOCH"$NOR |
| 204 |
echo $GREEN"Press enter to continue"$NOR |
| 205 |
read |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
echo |
| 210 |
echo $BLUE"Attempting to build package..."$NOR |
| 211 |
|
| 212 |
tools/build_release |
| 213 |
|
| 214 |
|
| 215 |
echo $RED'$ shasum -a 256 dist/*' |
| 216 |
shasum -a 256 dist/* |
| 217 |
echo $NOR |
| 218 |
|
| 219 |
echo $BLUE"We are going to rebuild, node the hash above, and compare them to the rebuild"$NOR |
| 220 |
echo $GREEN"Press enter to continue"$NOR |
| 221 |
read |
| 222 |
|
| 223 |
echo |
| 224 |
echo $BLUE"Attempting to build package..."$NOR |
| 225 |
|
| 226 |
tools/build_release |
| 227 |
|
| 228 |
echo $RED"Check the shasum for SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" |
| 229 |
echo $RED'$ shasum -a 256 dist/*' |
| 230 |
shasum -a 256 dist/* |
| 231 |
echo $NOR |
| 232 |
|
| 233 |
if ask_section "upload packages ?" |
| 234 |
then |
| 235 |
twine upload --verbose dist/*.tar.gz dist/*.whl |
| 236 |
fi |
| 237 |
fi |