From 0c81db408f0188bc221e1c22e874d865ac90c1f0 Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Fri, 16 Oct 2020 15:16:06 -0700 Subject: [PATCH] add dist script --- misc/dist.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 misc/dist.sh diff --git a/misc/dist.sh b/misc/dist.sh new file mode 100755 index 0000000..4be9101 --- /dev/null +++ b/misc/dist.sh @@ -0,0 +1,59 @@ +#!/bin/bash -e +OUTER_PWD=$PWD +cd "$(dirname "$0")/.." + +PKG_VERSION=$(node -e 'process.stdout.write(require("./package.json").version)') + +BUMP_VERSION= +if [ "$1" == "" ]; then true +elif [ "$1" == "-major" ]; then BUMP_VERSION=major +elif [ "$1" == "-minor" ]; then BUMP_VERSION=minor +elif [ "$1" == "-patch" ]; then BUMP_VERSION=patch +else + cat << _MESSAGE_ >&2 +$0: Unexpected option $1 +Usage: $0 [-major | -minor | -patch] + -major Bump major version. e.g. 1.2.3 => 2.0.0 + -minor Bump minor version. e.g. 1.2.3 => 1.3.0 + -patch Bump patch version. e.g. 1.2.3 => 1.2.4 + (nothing) Leave version in package.json unchanged ($PKG_VERSION) +_MESSAGE_ + exit 1 +fi + +# checkout products so that npm version doesn't fail. These are regenerated anyways. +git checkout -- dist + +# Make sure there are no uncommitted changes +if [ -n "$(git status --untracked-files=no --ignore-submodules=dirty --porcelain)" ]; then + echo "There are uncommitted changes:" >&2 + git status -s --untracked-files=no --ignore-submodules=dirty + exit 1 +fi + +# Bump version in package.js. This will fail and stop the script if git is not clean +if [ "$BUMP_VERSION" != "" ]; then + npm --no-git-tag-version version "$BUMP_VERSION" + PKG_VERSION=$(node -e 'process.stdout.write(require("./package.json").version)') +fi + +# build +echo "" ; echo "wasmc -clean" +./node_modules/.bin/wasmc -clean + +# test +echo "" ; echo "./test/test.sh" +./test/test.sh + +# commit, tag and push git +echo "Ready to commit, publish & push:" +echo "" +if [[ "$PWD" != "$OUTER_PWD" ]]; then + echo " cd '$PWD'" +fi +cat << _MESSAGE_ + git commit -m "v${PKG_VERSION}" . ../jslib.go + npm publish + git push + +_MESSAGE_