ffffng/publish.sh

55 lines
815 B
Bash
Raw Normal View History

2016-06-11 19:08:46 +02:00
#!/usr/bin/env bash
set -e
2016-06-11 20:13:38 +02:00
function confirm() {
msg="$1 [y/n] "
echo -n $msg
while read -n1 c; do
echo
if [ "$c" == "y" ]; then
return 0
fi
if [ "$c" == "n" ]; then
return 1
fi
echo -n $msg
done
}
2016-06-11 19:08:46 +02:00
cd $(dirname $0)
version=$(grep '^ *"version": *"[^"]*" *, *$' package.json | cut -d '"' -f4)
2016-06-11 20:13:38 +02:00
npm_tag=$1
2016-06-11 19:08:46 +02:00
if [ -z "$version" ]; then
echo "Could not determine current version."
exit 1
fi
2016-06-11 20:13:38 +02:00
if [ -z "$npm_tag" ]; then
npm_tag=latest
fi
echo "Current version: $version#$npm_tag"
2016-06-11 19:08:46 +02:00
if [[ $version =~ 'SNAPSHOT' ]]; then
echo "Will not publish SNAPSHOT version."
exit 1
fi
2016-06-11 20:13:38 +02:00
echo
2016-06-11 19:08:46 +02:00
2016-06-11 20:13:38 +02:00
if confirm "Continue publishing?"; then
./node_modules/.bin/grunt clean build
cd dist
npm publish -t $npm_tag
fi
2016-06-11 19:08:46 +02:00