#!/bin/bash
# Build and upload to npm

if [ $# -lt 1 ]; then
    echo "Usage: $0 VERSION"
    exit 1
fi

if ! git diff-index --quiet HEAD --; then
    echo "You have uncommitted changes"
    exit 1
fi

VERSION=$1

# Bump the version number
bin/set_version "$VERSION"

EXPORT_DIR=/tmp/catapult

rm -rf $EXPORT_DIR
mkdir -p $EXPORT_DIR
haxe build.hxml
cp etc/package.json $EXPORT_DIR/
cp catapult.js $EXPORT_DIR/index.js
cp README.md $EXPORT_DIR/
cd $EXPORT_DIR/..
tar czvf /tmp/catapult.tgz catapult
rm -rf $EXPORT_DIR

npm publish catapult.tgz




