Skip to content

Commit bd6aec5

Browse files
committed
Add major/minor/patch parameter + Rename
1 parent 185ff99 commit bd6aec5

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

scripts/tag-patch-release.sh renamed to scripts/tag-release.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
# Bump patch version in package.json & examples/parent-child-demo/package.json, commit as "Release X.Y.Z",
44
# and add git tag "vX.Y.Z" with message "Release X.Y.Z".
55

6-
set -o nounset -o errexit -o pipefail
6+
set -o errexit -o pipefail
7+
8+
if [[ !($1 =~ ^major|minor|patch$) ]]; then
9+
echo "Usage: tag-release.sh [major|minor|patch]"
10+
exit 1
11+
fi
12+
13+
set -o nounset
14+
715
gitStatus=$(git status -s)
816
if [[ -n $gitStatus ]]; then
917
echo "ERROR: Working tree has modified/untracked files:"
@@ -16,8 +24,15 @@ then
1624
vMajor=${BASH_REMATCH[1]}
1725
vMinor=${BASH_REMATCH[2]}
1826
vPatch=${BASH_REMATCH[3]}
19-
newVersion=$vMajor.$vMinor.$(( $vPatch + 1 ))
20-
echo "Bumped version from ${vMajor}.${vMinor}.${vPatch} to ${newVersion}"
27+
vMajorNew=$vMajor
28+
vMinorNew=$vMinor
29+
vPatchNew=$vPatch
30+
if [[ $1 == major ]]; then vMajorNew=$(( $vMajor + 1 )); fi
31+
if [[ $1 == minor ]]; then vMinorNew=$(( $vMinor + 1 )); fi
32+
if [[ $1 == patch ]]; then vPatchNew=$(( $vPatch + 1 )); fi
33+
newVersion=$vMajorNew.$vMinorNew.$vPatchNew
34+
echo "Bumping version from ${vMajor}.${vMinor}.${vPatch} to ${newVersion}"
35+
2136
sed -i '' -e "s/\(\"version\": *\"\).*\(\".*\)$/\1${newVersion}\2/" package.json
2237
sed -i '' -e "s/\(\"react-lifecycle-visualizer\": *\"[\^~]\{0,1\}\).*\(\".*\)$/\1${newVersion}\2/" examples/parent-child-demo/package.json
2338
git add package.json examples/parent-child-demo/package.json

0 commit comments

Comments
 (0)