Release: force flag and check deps.

1. Require force flag for custom version.
2. Check installed semver and jq.
This commit is contained in:
Artem Sapegin 2013-08-08 13:30:55 +04:00
parent 0d4221c21b
commit a3fa7a2d1a
1 changed files with 24 additions and 7 deletions

View File

@ -1,7 +1,9 @@
#!/bin/bash
# Release next version of product
# Usage: release <VERSION|major|minor|patch>
# Release next version of the product
# Usage:
# release <major|minor|patch>
# release <VERSION> --force
#
# Require:
# - semver - https://github.com/sekati/semver
@ -15,9 +17,18 @@ NOCOLOR="$(tput sgr0)"
function header() { echo -e "$UNDERLINE$CYAN$1$NOCOLOR\n"; }
function error() { echo -e "$UNDERLINE$RED$1$NOCOLOR"; }
function usage() {
echo "Usage:"
echo " `basename $0` <major|minor|patch>"
echo " `basename $0` <VERSION> --force"
echo
}
command -v semver >/dev/null 2>&1 || { error "semver not installed: see comments for instructions."; exit 1; }
command -v jq >/dev/null 2>&1 || { error "jq not installed: see comments for instructions."; exit 1; }
if [ "$1" == "" ]; then
echo "Usage: `basename $0` <VERSION|major|minor|patch>"
usage
exit 1
fi
@ -32,7 +43,7 @@ fi
# Read existing versions
jq_ver=$(find . -maxdepth 1 -name "*.jquery.json" | xargs cat | jq -r ".version")
cmpnt_ver=$(find . -maxdepth 1 -name "component.json" | xargs cat | jq -r ".version")
cmpnt_ver=$(find . -maxdepth 1 -name "bower.json" | xargs cat | jq -r ".version")
pkg_ver=$(find . -maxdepth 1 -name "package.json" | xargs cat | jq -r ".version")
# Non npm package
@ -47,11 +58,17 @@ current_ver=
# 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."
dont_match="Versions in *.jquery.json, bower.json and package.json dont match."
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
if [ "$1" != "--force" ]; then
error "Custom versions possible only with --force key."
echo
usage
exit 1
fi
new_ver="$1"
fi
if [ -z "$new_ver" ]; then
@ -62,9 +79,9 @@ fi
header "Releasing v$new_ver..."
# Update component.json
# Update bower.json
if [ -n "$cmpnt_ver" ]; then
sed -i '' "s^$current_ver^$new_ver^" component.json
sed -i '' "s^$current_ver^$new_ver^" bower.json
fi
# Update package.json