Created
January 15, 2022 00:33
Versioning a React app in a monorepo with no tags
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
#!/bin/sh | |
cd $(git rev-parse --show-toplevel)/ui | |
previous=$(npm version | grep rating-ui | awk -F"'" '{ print $4 }') | |
tickets=$(git log --oneline ./ | awk '{ print tolower($2) }' | sort | uniq | grep -i -E -o 'MX-[0-9]+' | wc | awk '{ print $1 }') | |
patch=$(($tickets % 10)) | |
minor=$(($tickets % 100)) | |
minor=${minor:0:1} | |
major=$(($tickets % 1000)) | |
major=${major:0:1} | |
version="$major.$minor.$patch" | |
echo "$previous -> $version" | |
if [ "$previous" != "$version" ]; then | |
echo "Version $version" | |
npm version $version | |
echo "Please commit the new version number and push again." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment