Skip to content

Commit

Permalink
Add script to bump version (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners authored Feb 10, 2023
1 parent 0504a4f commit ba5ab33
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions inc-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -e

PATH=./node_modules/.bin:${PATH}
CURRENT_VERSION=$(jq -r .version package.json)

case ${1} in
Major | MAJOR | major)
LEVEL=major
;;

Minor | MINOR | minor)
LEVEL=minor
;;

Patch | PATCH | patch)
LEVEL=patch
;;

*)
LEVEL=patch
;;
esac

NEW_VERSION=$(semver -i ${LEVEL} ${CURRENT_VERSION})
echo "${CURRENT_VERSION} => ${NEW_VERSION}"
read -n 1 -s -r -p "Press any key to continue (ctrl+c to abort)..."
echo ""

echo "Patching package.json..."
cat package.json | \
jq --arg vers "${NEW_VERSION}" '.version = $vers' | \
tee package.json 1>/dev/null

echo "Patching lib/meta.js ..."
SED_SCRIPT=$(printf 's/%s/%s/' ${CURRENT_VERSION//\./\\.} ${NEW_VERSION//\./\\.})
cat ./lib/meta.js | \
sed -e ${SED_SCRIPT} | \
tee ./lib/meta.js 1>/dev/null

echo "Done."

0 comments on commit ba5ab33

Please sign in to comment.