ffffng/publish.sh

49 lines
753 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
}
cd "$(dirname "${BASH_SOURCE[0]}")"
2016-06-11 19:08:46 +02:00
version=$(grep '^ *"version": *"[^"]*" *, *$' package.json | cut -d '"' -f4)
if [ -z "$version" ]; then
echo "Could not determine current version."
exit 1
fi
2016-06-20 22:49:03 +02:00
echo "Current version: $version"
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
2022-05-19 11:12:07 +02:00
yarn run dist
2016-06-11 20:13:38 +02:00
cd dist
yarn publish --new-version "$version"
2016-06-11 20:13:38 +02:00
fi