From a3fa7a2d1a8412112f453abfc54346cc947de57f Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Thu, 8 Aug 2013 13:30:55 +0400 Subject: [PATCH] Release: force flag and check deps. 1. Require force flag for custom version. 2. Check installed semver and jq. --- bin/release | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/release b/bin/release index c3cbcdd..f94154d 100755 --- a/bin/release +++ b/bin/release @@ -1,7 +1,9 @@ #!/bin/bash -# Release next version of product -# Usage: release +# Release next version of the product +# Usage: +# release +# release --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` " + echo " `basename $0` --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` " + 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 don’t match." + dont_match="Versions in *.jquery.json, bower.json and package.json don’t 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