Created
October 5, 2021 23:10
-
-
Save hsteinshiromoto/078f059f782a0b0896f12a1803687569 to your computer and use it in GitHub Desktop.
Git hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This file automatically updates the versions of files setup.py and __init__.py | |
# based on the latest git tag and the release branch name | |
# Copy this file to .git/hooks/ | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | |
BRANCH_TYPE=$(echo ${BRANCH_NAME}| cut -d/ -f1) | |
NEXT_VERSION=$(echo ${BRANCH_NAME} | cut -d "v" -f2- | cut -d "v" -f2-) | |
PREVIOUS_VERSION=$(git tag -l --sort=-creatordate | head -n 1 | cut -d "v" -f2-) | |
if [ "$BRANCH_TYPE" == "release" ]; then | |
echo "Running post-checkout git hook on branch $BRANCH_NAME" | |
echo "Updating version $PREVIOUS_VERSION to $NEXT_VERSION" | |
sed -i -e "s/$PREVIOUS_VERSION/$NEXT_VERSION/g" /workspaces/datatoolkit/setup.py | |
sed -i -e "s/$PREVIOUS_VERSION/$NEXT_VERSION/g" /workspaces/datatoolkit/datatoolkit/__init__.py | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment