Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add script to bump version #1643

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."