Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions ci/deploy/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import os
from pathlib import Path

from materialize import ci_util, git, mzbuild, ui
from materialize import ci_util, git, mzbuild, spawn, ui
from materialize.mz_version import MzVersion
from materialize.rustc_flags import Sanitizer
from materialize.version_list import get_all_mz_versions
from materialize.version_list import get_all_mz_versions, get_self_managed_versions
from materialize.xcompile import Arch


Expand All @@ -22,6 +22,12 @@ def main() -> None:
bazel_remote_cache = os.getenv("CI_BAZEL_REMOTE_CACHE")
bazel_lto = ui.env_is_truthy("CI_BAZEL_LTO")

ci_helm_chart_version = os.getenv("CI_HELM_CHART_VERSION")
ci_mz_version = os.getenv("CI_MZ_VERSION")

if ci_helm_chart_version and ci_mz_version:
spawn.runv(["git", "checkout", ci_mz_version])

repos = [
mzbuild.Repository(
Path("."),
Expand Down Expand Up @@ -56,7 +62,19 @@ def include_image(image: mzbuild.Image) -> bool:
for repo in repos
]

if buildkite_tag:
if ci_helm_chart_version and ci_mz_version:
# On tag builds, always tag the images as such.
mzbuild.tag_multiarch_images(
f"self-managed-{ci_helm_chart_version}", ci_mz_version, deps
)

version = MzVersion.parse_mz(ci_mz_version)
latest_version = max(
t for t in get_self_managed_versions() if t.prerelease is None
)
if version == latest_version:
mzbuild.tag_multiarch_images("latest-self-managed", ci_mz_version, deps)
elif buildkite_tag:
# On tag builds, always tag the images as such.
mzbuild.publish_multiarch_images(buildkite_tag, deps)

Expand Down
11 changes: 11 additions & 0 deletions ci/publish-helm-charts/pipeline.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,14 @@ steps:
timeout_in_minutes: 30
agents:
queue: linux-aarch64-small

- wait: ~

- id: docker-tag
label: Tag Versions on DockerHub
command: bin/ci-builder run stable bin/pyactivate -m ci.deploy.docker
timeout_in_minutes: 30
agents:
queue: linux-x86_64-small
concurrency: 1
concurrency_group: deploy/linux
30 changes: 30 additions & 0 deletions misc/python/materialize/mzbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,3 +1589,33 @@ def publish_multiarch_images(
],
stdin=markdown.encode(),
)


def tag_multiarch_images(
new_tag: str, previous_tag: str, dependency_sets: Iterable[Iterable[ResolvedImage]]
) -> None:
"""Publishes a set of docker images under a given tag."""
for images in zip(*dependency_sets):
names = set(image.image.name for image in images)
assert len(names) == 1, "dependency sets did not contain identical images"
new_name = images[0].image.docker_name(new_tag)

# Doesn't have tagged images
if images[0].image.name == "mz":
continue

previous_name = images[0].image.docker_name(previous_tag)
spawn.runv(["docker", "pull", previous_name])
spawn.runv(["docker", "tag", previous_name, new_name])
spawn.runv(["docker", "push", new_name])
print(f"--- Nofifying for tag {new_tag}")
markdown = f"""Pushed images with Docker tag `{new_tag}`"""
spawn.runv(
[
"buildkite-agent",
"annotate",
"--style=info",
f"--context=build-tags-{new_tag}",
],
stdin=markdown.encode(),
)