Skip to content

Commit 2b450d9

Browse files
committed
Add tag-patch-release.sh script
1 parent 19e9845 commit 2b450d9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scripts/tag-patch-release.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Bump patch version in package.json & examples/parent-child-demo/package.json, commit as "Release X.Y.Z",
4+
# and add git tag "vX.Y.Z" with message "Release X.Y.Z".
5+
6+
set -o nounset -o errexit -o pipefail
7+
gitStatus=$(git status -s)
8+
if [[ -n $gitStatus ]]; then
9+
echo "ERROR: Working tree has modified/untracked files:"
10+
echo "${gitStatus}"
11+
exit 1
12+
fi
13+
14+
if [[ `cat package.json` =~ .*\"version\":\ *\"([0-9]+)\.([0-9]+)\.([0-9]+)\" ]]
15+
then
16+
vMajor=${BASH_REMATCH[1]}
17+
vMinor=${BASH_REMATCH[2]}
18+
vPatch=${BASH_REMATCH[3]}
19+
newVersion=$vMajor.$vMinor.$(( $vPatch + 1 ))
20+
echo "Bumped version from ${vMajor}.${vMinor}.${vPatch} to ${newVersion}"
21+
sed -i '' -e "s/\(\"version\": *\"\).*\(\".*\)$/\1${newVersion}\2/" package.json
22+
sed -i '' -e "s/\(\"react-lifecycle-visualizer\": *\"[\^~]\{0,1\}\).*\(\".*\)$/\1${newVersion}\2/" examples/parent-child-demo/package.json
23+
git add package.json examples/parent-child-demo/package.json
24+
git commit -m "Release ${newVersion}"
25+
git tag -a "v${newVersion}" -m "Release ${newVersion}"
26+
else
27+
echo "ERROR: No \"version\" found in package.json"
28+
exit 1
29+
fi

0 commit comments

Comments
 (0)