version-bump.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. set -e
  3. if [ $# -eq 0 ]; then
  4. echo "Usage $0 VERSION"
  5. exit 1
  6. fi
  7. echo "Bumping versions to $1"
  8. # GNU/BSD compat
  9. sedi=(-i)
  10. case "$(uname)" in
  11. # For macOS, use two parameters
  12. Darwin*) sedi=(-i "")
  13. esac
  14. git grep -l $(cat VERSION) -- ':!**/yarn.lock' ':!CHANGELOG.md' ':!Cargo.lock' ':!package.json' | \
  15. xargs sed "${sedi[@]}" \
  16. -e "s/$(cat VERSION)/$1/g"
  17. # Potential for collisions in package.json files, handle those separately
  18. # Replace only matching "version": "x.xx.x" and "@coral-xyz/anchor": "x.xx.x"
  19. git grep -l $(cat VERSION) -- '**/package.json' | \
  20. xargs sed "${sedi[@]}" \
  21. -e "s/@coral-xyz\/anchor\": \"$(cat VERSION)\"/@coral-xyz\/anchor\": \"$1\"/g" \
  22. -e "s/\"version\": \"$(cat VERSION)\"/\"version\": \"$1\"/g"
  23. # Potential for collisions in Cargo.lock, use cargo update to update it
  24. cargo update --workspace
  25. # Insert version number into CHANGELOG.md
  26. sed "${sedi[@]}" -e "s/## \[Unreleased\]/## [Unreleased]\n\n## [$1] - $(date '+%Y-%m-%d')/g" CHANGELOG.md
  27. pushd ts && yarn && popd
  28. pushd tests && yarn && popd
  29. pushd examples && yarn && pushd tutorial && yarn && popd && popd
  30. echo $1 > VERSION
  31. echo "$(git diff --stat | tail -n1) files modified"
  32. echo " $(cat VERSION) changeset generated, commit and tag"