5 # Ask a yes or no question
7 local prompt default reply
8 if [ "${2:-}" = "Y" ]; then
11 elif [ "${2:-}" = "N" ]; then
19 echo -ne "$1 [$prompt] "
20 read -n 1 -t 5 reply </dev/tty
21 if [ -z "$reply" ]; then
23 echo "(timeout, assuming $default)"
27 [Yy]* ) echo && return 0 ;;
28 [Nn]* ) echo && return 1 ;;
29 * ) echo && echo "Please answer Yes or No." ;;
35 read -rsp $'Press any key to continue...' -n1 key
40 echo "Usage: $0 <required_version_number>"
45 PREVIOUS_VERSION=$(git tag --sort=-creatordate | head -1)
46 git tag --format='%(creatordate:short)%09%(refname:strip=2)'
48 echo "PREVIOUS_VERSION=${PREVIOUS_VERSION}"
50 if ! ask_y_n "About to cut (build, test, package, give you the command to upload) $VERSION, ok?" "N"; then
51 echo "Ok, exiting instead."
56 echo "Ok, here are the commit message of changes since the last version..."
57 LAST_TAG=$(git tag | tail -1)
58 git log $LAST_TAG..HEAD
63 echo "Ok, running scottutilz tests including test_some_dependencies.py..."
64 cd ../scottutilz/tests
65 ./run_tests.py --all --coverage
71 echo "Creating a git tag for version ${VERSION}"
72 git tag -a "${VERSION}" -m "cut_version.sh ${VERSION}"
73 CHANGES=$(git log --pretty="- %s" $VERSION...$LAST_TAG)
74 printf "# 🎁 Release notes (\`$VERSION\`)\n\n## Changes\n$CHANGES\n\n## Metadata\n\`\`\`\nThis version -------- $VERSION\nPrevious version ---- $PREVIOUS_VERSION\nTotal commits ------- $(echo "$CHANGES" | wc -l)\n\`\`\`\n" >> release_notes.md
76 echo "Updating pyproject.toml with this version number"
77 cat ./pyproject.template | sed s/##VERSION##/$VERSION/g > ./pyproject.toml
78 git commit -a -m "Cut version ${VERSION}" -m "${CHANGES}"
84 echo "Done. To upload, run: \"twine upload --verbose --repository testpypi dist/*\""