version-bump.sh 1.5 KB

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