bump-version 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # bump-version — sets the Materialize version in appropriate files.
  12. set -euo pipefail
  13. cd "$(dirname "$0")/.."
  14. . misc/shlib/shlib.bash
  15. if [[ $# -ne 1 && $# -ne 2 ]]; then
  16. die "usage: $0 VERSION [--no-commit]"
  17. fi
  18. commit=true
  19. if [[ $# -eq 2 ]]; then
  20. if [[ "$2" == "--no-commit" ]]; then
  21. commit=false
  22. else
  23. die "invalid flag: $2, only --no-commit is supported"
  24. fi
  25. fi
  26. if ! run git diff HEAD --compact-summary --exit-code; then
  27. die "cannot begin bump with uncommitted content"
  28. fi
  29. version=${1#v}
  30. sed -i.bak \
  31. "s/^version = .*/version = \"$version\"/" \
  32. src/{clusterd,environmentd,materialized,persist-client,testdrive,catalog-debug,balancerd,orchestratord}/Cargo.toml
  33. if ! [[ "$version" = *-dev* ]]; then
  34. sed -i.bak \
  35. "s/^Licensed Work:.*/Licensed Work: Materialize Version v$version/" \
  36. LICENSE
  37. else
  38. # Rename all upgrade tests that reference `current_source` to explicitly
  39. # reference the version of the last release.
  40. IFS='.' read -r -a parts <<< "$version"
  41. ((parts[1]--))
  42. last_version="${parts[0]}.${parts[1]}.0"
  43. for file in test/legacy-upgrade/*current_source*; do
  44. if [[ "$file" = *example* ]]; then
  45. continue
  46. fi
  47. git mv "$file" "$(echo "$file" | sed "s/current_source/v$last_version/")"
  48. done
  49. fi
  50. rm -f src/{clusterd,environmentd,materialized,persist-client,testdrive,catalog-debug,balancerd,orchestratord}/Cargo.toml.bak LICENSE.bak
  51. cargo update --workspace
  52. bin/bazel gen
  53. bin/helm-chart-version-bump --bump-orchestratord-version "v$version"
  54. helm_docs_version=1.14.2
  55. if ! helm-docs --help > /dev/null; then
  56. echo "helm-docs is currently not installed"
  57. echo "Install helm-docs $helm_docs_version from https://github.com/norwoodj/helm-docs/releases/tag/v$helm_docs_version"
  58. exit 1
  59. fi
  60. if [ "$(helm-docs --version)" != "helm-docs version $helm_docs_version" ]; then
  61. echo "helm-docs is installed, but has wrong version: $(helm-docs --version)"
  62. echo "Install helm-docs $helm_docs_version from https://github.com/norwoodj/helm-docs/releases/tag/v$helm_docs_version"
  63. exit 1
  64. fi
  65. helm-docs misc/helm-charts
  66. if $commit; then
  67. git commit -am "release: bump to version v$version"
  68. fi