Skip to content

Commit

Permalink
bump2version
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Oct 10, 2023
1 parent 0efdb50 commit b81f6f7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True

[bumpversion:file:just_psf/__init__.py]
47 changes: 47 additions & 0 deletions release_it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# check parameters
if [ "$#" -ne 1 ]; then
>&2 echo "Illegal number of parameters"
>&2 echo "usage: ./release_it.sh [major|minor|patch]"
exit 1
fi


# get variables
MAIN_BRANCH="main"
RELEASE_PART=$1
CURRENT_BRANCH=$(git branch --show-current)
INFO=$(bump2version --list --dry-run "$RELEASE_PART")
if [ "$?" -ne 0 ]; then
>&2 echo "Error while running bump2version, exiting"
exit 1
fi

CURRENT_VERSION=$(echo "$INFO" | grep "current_version" | sed -r s,"^.*=",,)
NEW_VERSION=$(echo "$INFO" | grep "new_version" | sed -r s,"^.*=",,)

# ask
while true; do
read -p "Do you wish to upgrade from $CURRENT_VERSION to $NEW_VERSION? [y/n] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
* ) echo "Please answer yes or no.";;
esac
done


# go to $MAIN_BRANCH
if [[ $CURRENT_BRANCH != "$MAIN_BRANCH" ]]; then
git checkout master
fi

git pull

# bump version
bump2version "$RELEASE_PART" --verbose
git push --follow-tags origin $MAIN_BRANCH

# switch back to current branch
if [[ $CURRENT_BRANCH != "$MAIN_BRANCH" ]]; then
git checkout "$CURRENT_BRANCH"
fi

0 comments on commit b81f6f7

Please sign in to comment.