-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtasks.py
More file actions
54 lines (40 loc) · 1.26 KB
/
tasks.py
File metadata and controls
54 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Pyinvoke tasks.py file for automating releases and admin stuff.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from pathlib import Path
from invoke import task
import glob
if TYPE_CHECKING:
from invoke import Context
@task
def generate_workflows(ctx: Context) -> None:
with open("ci_workflow_template.yml", "rt") as f:
template = f.read()
for path in glob.glob("docker/Dockerfile.*"):
toks = Path(path).name.split(".")
name = toks[1]
tag = f"latest"
if len(toks) == 3:
tag = f"latest-{toks[2]}"
with open(f".github/workflows/dockerhub-{name}-{tag}.yml", "wt") as f:
f.write(template.format(name=name, tag=tag, path=path))
@task
def publish(ctx: Context, fname) -> None:
toks = Path(fname).name.split(".")
name = toks[1]
tag = "latest"
if len(toks) == 3:
tag = f"latest-{toks[2]}"
ctx.run(f"docker build -t materialyzeai/{name}:{tag} -f {fname} .")
ctx.run(f"docker push materialyzeai/{name}:{tag}")
@task
def publish_all(ctx: Context) -> None:
"""
Publish all.
Args:
ctx (Context): The context.
"""
for fname in glob.glob("docker/Dockerfile.*"):
publish(ctx, fname)