bump_patch_version.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright 2021-2025 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. # --------------------------------------------------------------------------------------------------
  12. # Increments the patch version number in all the packages' version.json file.
  13. #
  14. # Invoked from the workflow in build-and-release.yml when releasing production packages.
  15. # --------------------------------------------------------------------------------------------------
  16. import argparse
  17. from common import Package, Version
  18. def main():
  19. parser = argparse.ArgumentParser(description="Increments the patch version number of a package.",
  20. formatter_class=argparse.RawTextHelpFormatter)
  21. # <package> argument
  22. def _check_package(value: str) -> str:
  23. n_value = value.lower()
  24. if n_value in Package.names(True) or value == "all":
  25. return n_value
  26. raise argparse.ArgumentTypeError(f"'{value}' is not a valid Taipy package name.")
  27. parser.add_argument("package",
  28. type=_check_package,
  29. action="store", help="""The name of the package to increment the patch version number.
  30. This should be the short name of a Taipy package (common, core...) or 'taipy'.
  31. If can also be set to 'ALL' then all packages are impacted.
  32. """)
  33. args = parser.parse_args()
  34. for package_name in [args.package] if args.package != "all" else Package.names(True):
  35. package = Package(package_name)
  36. version = package.load_version()
  37. if version.ext:
  38. raise ValueError(f"Package version for '{package.name}' has an extension ({version.full_name}).")
  39. package.save_version(Version(version.major, version.minor, version.patch + 1))
  40. if __name__ == "__main__":
  41. main()