diff --git a/tasks/release b/tasks/release index 4bf2bd2..cba1c83 100755 --- a/tasks/release +++ b/tasks/release @@ -4,7 +4,29 @@ if [ "$1" == "--preview" ] || [ "$1" == "-P" ] || [ "$1" == "-p" ]; then # Preview release $RACKT_PATH/node_modules/rf-release/node_modules/.bin/changelog -t preview -s else + # build task has to be run prior to release module + # the release module is what prompts for next version number + # version is needed in order to update the package.json generated by build task + # we are left prompting for version, and updating build/package.json ourselves + # the version gathered here can then be provided to the release module + + update_version() { + echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1 + echo "Updated ${1} version to ${2}" + } + + current_version=$(node -p "require('./package').version") + + printf "Next version (current is $current_version)? " + read next_version + + if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then + echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1" + exit 1 + fi + # Release to npm $RACKT_PATH/tasks/build - $RACKT_PATH/node_modules/.bin/release -f ./build + update_version 'build/package.json' $next_version + $RACKT_PATH/node_modules/.bin/release -v $next_version -f ./build fi