bump-version.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. set -e
  3. if [ $# -eq 0 ]; then
  4. echo "Usage $0 VERSION"
  5. exit 1
  6. fi
  7. old_version=$(cat VERSION)
  8. version=$1
  9. echo "Bumping versions to $version"
  10. # GNU/BSD compat
  11. sedi=(-i)
  12. case "$(uname)" in
  13. # For macOS, use two parameters
  14. Darwin*) sedi=(-i "")
  15. esac
  16. # Only replace version with the following globs
  17. allow_globs=":**/Cargo.toml **/Makefile client/src/lib.rs lang/attribute/program/src/lib.rs"
  18. git grep -l $old_version -- $allow_globs |
  19. xargs sed "${sedi[@]}" \
  20. -e "s/$old_version/$version/g"
  21. # Separately handle docs because blindly replacing the old version with the new
  22. # might break certain examples/links
  23. pushd docs/content/docs
  24. git grep -l $old_version -- "./*.md*" | \
  25. xargs sed "${sedi[@]}" \
  26. -e "s/\"$old_version\"/\"$version\"/g"
  27. allow_globs="installation.mdx quickstart/local.mdx references/verifiable-builds.mdx"
  28. git grep -l $old_version -- $allow_globs |
  29. xargs sed "${sedi[@]}" \
  30. -e "s/$old_version/$version/g"
  31. # Replace `solana_version` with the current version
  32. solana_version=$(solana --version | awk '{print $2;}')
  33. sed $sedi "s/solana_version.*\"/solana_version = \"$solana_version\"/g" references/anchor-toml.mdx
  34. # Keep release notes and changelog the same
  35. git restore updates
  36. popd
  37. # Potential for collisions in `package.json` files, handle those separately
  38. # Replace only matching "version": "x.xx.x" and "@coral-xyz/anchor": "x.xx.x"
  39. git grep -l $old_version -- "**/package.json" | \
  40. xargs sed "${sedi[@]}" \
  41. -e "s/@coral-xyz\/anchor\": \"$old_version\"/@coral-xyz\/anchor\": \"$version\"/g" \
  42. -e "s/\"version\": \"$old_version\"/\"version\": \"$version\"/g"
  43. # Insert version number into CHANGELOG
  44. sed "${sedi[@]}" -e \
  45. "s/## \[Unreleased\]/## [Unreleased]\n\n### Features\n\n### Fixes\n\n### Breaking\n\n## [$version] - $(date '+%Y-%m-%d')/g" \
  46. CHANGELOG.md
  47. # Update lock files
  48. pushd ts && yarn && popd
  49. pushd tests && yarn && popd
  50. pushd examples && yarn && pushd tutorial && yarn && popd && popd
  51. # Bump benchmark files
  52. pushd tests/bench && anchor run bump-version -- --anchor-version $version && popd
  53. echo $version > VERSION
  54. echo "$(git diff --stat | tail -n1) files modified"
  55. echo "$version changeset generated, commit and tag"