X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=cut_version.sh;h=889d7b58ef8375e2d7ecf83b6fc472c6732bd68f;hb=b545d5422255d549d92d354fd0d22eabbadbf724;hp=a3e5e136c396e596b45fff672c0934d41a4da292;hpb=1c60a8d9ae5a162f8d309b48f8a07ee6946f3e25;p=pyutils.git diff --git a/cut_version.sh b/cut_version.sh index a3e5e13..889d7b5 100755 --- a/cut_version.sh +++ b/cut_version.sh @@ -42,20 +42,29 @@ if [ $# -ne 1 ]; then fi VERSION=$1 -if ! ask_y_n "About to cut and upload $VERSION, ok?" "N"; then +PREVIOUS_VERSION=$(git tag --sort=-creatordate | head -1) +git tag --format='%(creatordate:short)%09%(refname:strip=2)' +echo +echo "PREVIOUS_VERSION=${PREVIOUS_VERSION}" +echo +if ! ask_y_n "About to cut (build, test, package, give you the command to upload) $VERSION, ok?" "N"; then echo "Ok, exiting instead." exit 0 fi +LAST_TAG=$(git tag | tail -1) +if [ "${LAST_TAG}" == "${VERSION}" ]; then + echo "Last tag is the same as ${VERSION}?! Aborted." + exit 1 +fi echo -echo "Ok, here's the commit message of changes since the last version..." -LAST_TAG=$(git tag | tail -1) +echo "Ok, here are the commit message of changes since the last version..." git log $LAST_TAG..HEAD pause echo echo -echo "Ok, running scottutilz tests including test_some_dependencies.py..." +echo "Ok, running pyutils and scottutilz tests including test_some_dependencies.py..." cd ../scottutilz/tests ./run_tests.py --all --coverage cd ../../pyutils @@ -63,13 +72,37 @@ pause echo echo +echo "Creating a git tag for version ${VERSION}" git tag -a "${VERSION}" -m "cut_version.sh ${VERSION}" CHANGES=$(git log --pretty="- %s" $VERSION...$LAST_TAG) 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 +echo "Updating pyproject.toml with this version number" cat ./pyproject.template | sed s/##VERSION##/$VERSION/g > ./pyproject.toml + +echo "Building wheel..." +python -m build + +echo "Checking in wheel package under dist/" +cd dist +WHEEL=pyutils-${VERSION}-py3-none-any.whl +if [ ! -f ${WHEEL} ]; then + echo "Can't find ${WHEEL}?!" + exit 1 +fi +LINK=pyutils-latest-py3-none-any.whl +git rm -f ${LINK} +ln -s ${WHEEL} ${LINK} +git add ${WHEEL} +git add ${LINK} +for FILE in *.whl; do + md5 ${FILE} > ${FILE}.md5 +done +git add *.md5 +cd .. git commit -a -m "Cut version ${VERSION}" -m "${CHANGES}" + +echo "Pushing changes to git" git push -python -m build -echo "To upload, run: \"twine upload --verbose --repository testpypi dist/*\"" +echo "Done. To upload, run: \"twine upload --verbose --repository pypi dist/*\""