-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for bumping the version (#7)
* Ignore backup copies of package.json in Git * Add script for bumping the version
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
coverage/ | ||
planitar-rnfs-untar-*.tgz | ||
package.json.* | ||
.*.sw[a-z]* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <major|minor|patch>" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f package.json ]; then | ||
echo 'Error: package.json not found' | ||
echo '' | ||
echo 'Run this script from the root of the repository' | ||
exit 1 | ||
fi | ||
|
||
if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then | ||
echo 'Error: Working directory is not clean' | ||
echo '' | ||
echo 'Commit or stash your changes before running this script' | ||
exit 1 | ||
fi | ||
|
||
case "$1" in | ||
major) | ||
jqExpr='.version |= ((split(".") | .[0] | tonumber + 1 | tostring) + ".0.0")' | ||
;; | ||
|
||
minor) | ||
jqExpr='.version |= ((split(".") | .[0] + "." + (.[1] | tonumber + 1 | tostring) + ".0"))' | ||
;; | ||
|
||
patch) | ||
jqExpr='.version |= ((split(".") | .[0] + "." + .[1] + "." + (.[2] | tonumber + 1 | tostring)))' | ||
;; | ||
|
||
*) | ||
echo "Usage: $0 <major|minor|patch>" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
jq --indent 2 "${jqExpr}" package.json >package.json.tmp | ||
mv package.json package.json.bak | ||
mv package.json.tmp package.json | ||
|
||
npm i | ||
|
||
|
||
gitTag="v$(jq -r .version package.json)" | ||
|
||
echo '' | ||
echo 'Done' | ||
echo '' | ||
echo '1. Review and commit the changes:' | ||
git status -s | ||
git diff package.json | ||
echo '' | ||
echo '2. Tag the release:' | ||
echo " git tag -a ${gitTag} -m '${gitTag}'" | ||
echo '' | ||
echo '3. Publish the release:' | ||
echo " git push origin ${gitTag}" | ||
echo ' npm publish' |