run-cli 0.0.53

A CLI to help you run any command
#!/bin/bash

set -e
cd "$(dirname -- "${BASH_SOURCE[0]}")/.."

# check usage
if [ $# -ne 1 ] || [ "$1" = "" ]; then
	echo "usage: $0 <major|minor|patch>" >&2
	exit 1
fi
bump="$1"

# make sure we are on the master branch
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$SKIP_MASTER_CHECK" != "true" ] && [ "$branch" != master ]; then
	echo "error: not on master branch" >&2
	exit 2
fi

# make sure the repository is clean
if [ "$(git status --porcelain)" != "" ]; then
	echo "error: repository is dirty" >&2
	exit 3
fi

# bump cargo version
cargo set-version --bump "$bump"
version="$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)"
git add Cargo.toml Cargo.lock

# bump node wrapper version
pushd ./wrappers/node
npm version "$version"
git add package.json
popd

# commit, tag, and push
git commit -m "chore: release $version"
git tag -a "$version" -m "Release $version"
git push --atomic origin "$branch" "$version"