dev_tag.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env python3
  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. import os
  11. from pathlib import Path
  12. from materialize import ci_util, git, mzbuild, ui
  13. from materialize.rustc_flags import Sanitizer
  14. from materialize.xcompile import Arch
  15. def main() -> None:
  16. bazel = ui.env_is_truthy("CI_BAZEL_BUILD")
  17. bazel_remote_cache = os.getenv("CI_BAZEL_REMOTE_CACHE")
  18. bazel_lto = ui.env_is_truthy("CI_BAZEL_LTO")
  19. mz_version = ci_util.get_mz_version()
  20. sanitizer = Sanitizer[os.getenv("CI_SANITIZER", "none")]
  21. repos = [
  22. mzbuild.Repository(
  23. Path("."),
  24. Arch.X86_64,
  25. coverage=False,
  26. sanitizer=sanitizer,
  27. bazel=bazel,
  28. bazel_remote_cache=bazel_remote_cache,
  29. bazel_lto=bazel_lto,
  30. ),
  31. mzbuild.Repository(
  32. Path("."),
  33. Arch.AARCH64,
  34. coverage=False,
  35. sanitizer=sanitizer,
  36. bazel=bazel,
  37. bazel_remote_cache=bazel_remote_cache,
  38. bazel_lto=bazel_lto,
  39. ),
  40. ]
  41. print("--- Tagging development Docker images")
  42. deps = [
  43. repo.resolve_dependencies(image for image in repo if image.publish)
  44. for repo in repos
  45. ]
  46. # Ideally we'd use SemVer metadata (e.g., `v1.0.0+metadata`), but `+` is not
  47. # a valid character in Docker tags, so we use `--` instead.
  48. suffix = "pr" if sanitizer == Sanitizer.none else f"pr-{sanitizer}"
  49. mzbuild.publish_multiarch_images(
  50. f'v{mz_version}--{suffix}.g{git.rev_parse("HEAD")}', deps
  51. )
  52. if __name__ == "__main__":
  53. main()