Fix release script.

This commit is contained in:
Artem Sapegin 2013-03-17 10:03:24 +04:00
parent ea0bbf4d23
commit 7c336e56b6

View File

@ -36,22 +36,25 @@ cmpnt_ver=$(find . -maxdepth 1 -name "component.json" | xargs cat | jq -r ".vers
pkg_ver=$(find . -maxdepth 1 -name "package.json" | xargs cat | jq -r ".version")
# Non npm package
[ "$pkg_ver" == "0.0.0" ] && pkg=
[ "$pkg_ver" == "0.0.0" ] && pkg_ver=
# Verify current versions
current_ver=$jq_ver||$cmpnt_ver||$pck_ver
[ "$current_ver" == "" ] && current_ver="0.0.1"
current_ver=
[ -n "$jq_ver" ] && current_ver="$jq_ver"
[ -n "$cmpnt_ver" ] && current_ver="$cmpnt_ver"
[ -n "$pkg_ver" ] && current_ver="$pkg_ver"
[ -z "$current_ver" ] && current_ver="0.0.0"
# Validate current versions and determine new version
if [ "$1" == "major" ] || [ "$1" == "minor" ] || [ "$1" == "patch" ]; then
dont_match="Versions in *.jquery.json, component.json and package.json dont match."
if [ "$jq_ver" != "" ] && [ "$current_ver" != "$jq_ver" ]; then error dont_match; fi
if [ "$cmpnt_ver" != "" ] && [ "$current_ver" != "$cmpnt_ver" ]; then error dont_match; fi
if [ "$pck_ver" != "" ] && [ "$current_ver" != "$pck_ver" ]; then error dont_match; fi
if [ -n "$jq_ver" ] && [ "$current_ver" != "$jq_ver" ]; then error $dont_match; fi
if [ -n "$cmpnt_ver" ] && [ "$current_ver" != "$cmpnt_ver" ]; then error $dont_match; fi
if [ -n "$pkg_ver" ] && [ "$current_ver" != "$pkg_ver" ]; then error $dont_match; fi
else
new_ver="$1"
fi
if [ "$new_ver" == "" ]; then
if [ -z "$new_ver" ]; then
[ "$1" == "patch" ] && new_ver=$(semver -p $current_ver)
[ "$1" == "minor" ] && new_ver=$(semver -n $current_ver)
[ "$1" == "major" ] && new_ver=$(semver -m $current_ver)
@ -60,18 +63,18 @@ fi
header "Releasing v$new_ver..."
# Update component.json
if [ "$cmpnt_ver" != "" ]; then
if [ -n "$cmpnt_ver" ]; then
sed -i '' "s^$current_ver^$new_ver^" component.json
fi
# Update package.json
if [ "$pck_ver" != "" ]; then
sed -i '' "s^$current_ver^$pck_ver^" package.json
if [ -n "$pkg_ver" ]; then
sed -i '' "s^$current_ver^$new_ver^" package.json
fi
# Update *.jquery.json
if [ "$jq_ver" != "" ]; then
find . -maxdepth 1 -name "*.jquery.json" | xargs sed -i '' "s^$current_ver^$jq_ver^"
if [ -n "$jq_ver" ]; then
find . -maxdepth 1 -name "*.jquery.json" | xargs sed -i '' "s^$current_ver^$new_ver^"
fi
# Build files
@ -91,7 +94,7 @@ git tag "v$new_ver"
git push origin --tags
# Publish npm package
if [ "$pck_ver" != "" ]; then
if [ -n "$pkg_ver" ]; then
npm publish
fi