Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3.  
  4. update_version(){
  5. if [[ "$DONT_BUMP_VERSION" -ne "1" ]]
  6. then
  7. echo " Bumping version.. "
  8. else
  9. echo "Version will not be bumped since variable DONT_BUMP_VERSION is set."
  10. exit 0
  11. fi
  12.  
  13. old_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
  14. version_split=( ${old_version//./ } )
  15.  
  16. #increment the number at the 3rd position ( 0,1,2 )
  17. ((version_split[2]++))
  18.  
  19. new_version="${version_split[0]}.${version_split[1]}.${version_split[2]}"
  20.  
  21. # overwrite it in the package.json file
  22. sed -i -e "0,/$old_version/s/$old_version/$new_version/" package.json
  23. }
  24.  
  25. # show off the old version
  26. npm version | head -1
  27.  
  28. update_version
  29.  
  30. # show off the updated version
  31. npm version | head -1
  32.  
  33. # track the change
  34. git add package.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement