See More

#!/bin/sh set -e REPO_PATH="$( dirname "$( cd "$(dirname "$0")" ; pwd -P )" )" if [ -z "$1" ]; then echo "Usage: script/release [patch | minor | major]" exit 1 fi if [ "$(git rev-parse --abbrev-ref HEAD)" != "dev" ]; then echo "Refusing to publish a release from a branch other than dev" exit 1 fi if [ -z "$(command -v poetry)" ]; then echo "Poetry needs to be installed to run this script: pip3 install poetry" exit 1 fi # Temporarily uninstall pre-commit hooks so that we can push to dev and master: pre-commit uninstall old_version="$(poetry version | awk -F' ' '{ print $2 }')" case "$1" in patch) poetry version patch ;; minor) poetry version minor ;; major) poetry version major ;; *) echo "Unknown release action: \"$1\"" exit 1 ;; esac # Update the PyPI package version: new_version="$(poetry version | awk -F' ' '{ print $2 }')" git add pyproject.toml # Update the docs version: sphinx_conf=$(sed "s/$old_version/$new_version/g" "$REPO_PATH/docs/conf.py") echo "$sphinx_conf" > "$REPO_PATH/docs/conf.py" git add docs/conf.py # Commit, tag, and push: git commit -m "Bump version to $new_version" git tag "$new_version" git push && git push --tags # Merge dev into master: git checkout master git merge dev git push git checkout dev # Re-initialize pre-commit: pre-commit install