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
5 changes: 5 additions & 0 deletions release_tools/copy_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import subprocess


def read_file_list(list_path):
"""
Reads a file containing file paths, ignoring empty lines and lines starting with '#'.
Expand All @@ -15,6 +16,7 @@ def read_file_list(list_path):
lines = [line.strip() for line in f]
return [line for line in lines if line and not line.startswith("#")]


def copy_files(file_list, dest_dir):
"""
Copy files listed in file_list to dest_dir, preserving their relative paths.
Expand All @@ -29,6 +31,7 @@ def copy_files(file_list, dest_dir):
shutil.copy2(abs_src, abs_dest)
print(f"Copied {abs_src} -> {abs_dest}")


def ensure_git_repo(dest_dir):
"""
Initializes a git repository in dest_dir if it's not already a git repo.
Expand Down Expand Up @@ -56,6 +59,7 @@ def ensure_git_repo(dest_dir):
print(f"Failed to ensure 'main' branch in {dest_dir}: {e}")
sys.exit(1)


def git_add_files(file_list, dest_dir):
"""
Runs 'git add' on each file in file_list within dest_dir.
Expand All @@ -72,6 +76,7 @@ def git_add_files(file_list, dest_dir):
finally:
os.chdir(cwd)


if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python copy_files.py <file_list.txt> <dest_dir>")
Expand Down
17 changes: 10 additions & 7 deletions release_tools/publish_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,34 @@
import subprocess
import sys


def get_image_digest(image_name, tag):
result = subprocess.run(
["docker", "buildx", "imagetools", "inspect", f"{image_name}:{tag}"],
stdout=subprocess.PIPE, check=True, text=True
stdout=subprocess.PIPE,
check=True,
text=True,
)
for line in result.stdout.splitlines():
if line.strip().startswith("Digest:"):
return line.strip().split(":", 1)[1].strip()
return None


def build_and_push_image(dest_dir, image_name, tag):
# Build
subprocess.run([
"docker", "buildx", "build", "--platform", "linux/amd64", "-t", f"{image_name}:{tag}", dest_dir
], check=True)
subprocess.run(
["docker", "buildx", "build", "--platform", "linux/amd64", "-t", f"{image_name}:{tag}", dest_dir], check=True
)
# Push
subprocess.run([
"docker", "push", f"{image_name}:{tag}"
], check=True)
subprocess.run(["docker", "push", f"{image_name}:{tag}"], check=True)
print(f"Pushed {image_name}:{tag}")
digest = get_image_digest(image_name, tag)
print(f"Image digest: {digest}")
with open("/tmp/digest.txt", "w") as f:
f.write(digest)


if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python build_and_publish_docker.py <ghcr_username/repo> <tag>")
Expand Down
Loading
Loading