version-bump.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # Only replace version with the following globs
  16. allow_globs=":**/Cargo.toml **/Makefile docs/src/pages/docs/*.md client/src/lib.rs"
  17. git grep -l $(cat VERSION) -- $allow_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. # Insert version number into CHANGELOG
  27. sed "${sedi[@]}" -e \
  28. "s/## \[Unreleased\]/## [Unreleased]\n\n### Features\n\n### Fixes\n\n### Breaking\n\n## [$version] - $(date '+%Y-%m-%d')/g" \
  29. 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 -- --anchor-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"