Repository navigation
Expand file tree
/
Copy pathgit.py
More file actions
89 lines (79 loc) · 2.64 KB
/
Copy pathgit.py
File metadata and controls
89 lines (79 loc) · 2.64 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from faasmctl.util.version import get_version as get_faasmctl_version
from invoke import task
from subprocess import run
from tasks.env import (
EXAMPLES_BUILD_IMAGE_NAME,
PROJ_ROOT,
get_faasm_version,
get_version,
)
VERSIONED_FILES = {
"faasm": [".github/workflows/tests.yml"],
"cpp": [".github/workflows/tests.yml"],
"python": [".github/workflows/tests.yml"],
"faasmctl": ["requirements.txt"],
}
@task
def tag(ctx, force=False):
"""
Creates git tag from the current tree
"""
version = get_version()
tag_name = "v{}".format(version)
run(
"git tag {} {}".format("--force" if force else "", tag_name),
shell=True,
check=True,
cwd=PROJ_ROOT,
)
run(
"git push {} origin {}".format("--force" if force else "", tag_name),
shell=True,
check=True,
cwd=PROJ_ROOT,
)
@task
def bump(ctx, submodule, ver=None):
"""
Bump a submodule's dependency: `faasm`, `cpp`, `python`, or `faasmctl`
"""
allowed_submodules = ["faasm", "cpp", "python", "faasmctl"]
if submodule not in allowed_submodules:
print("Unrecognised submodule: {}".format(allowed_submodules))
print("Submodule must be one in: {}".format(allowed_submodules))
raise RuntimeError("Unrecognised submodule")
if submodule == "faasm":
old_ver = get_faasm_version()
if ver:
new_ver = ver
else:
raise RuntimeError("Must provide a version with --ver flag!")
# Replace version in all files
for f in VERSIONED_FILES["faasm"]:
sed_cmd = "sed -i 's/{}/{}/g' {}".format(old_ver, new_ver, f)
run(sed_cmd, shell=True, check=True)
elif submodule == "faasmctl":
old_ver = get_faasmctl_version()
if ver:
new_ver = ver
else:
raise RuntimeError("Must provide a version with --ver flag!")
# Replace version in all files
for f in VERSIONED_FILES["faasmctl"]:
sed_cmd = "sed -i 's/{}/{}/g' {}".format(old_ver, new_ver, f)
run(sed_cmd, shell=True, check=True)
else:
new_ver = get_version()
grep_cmd = "grep '{}' .github/workflows/tests.yml".format(
EXAMPLES_BUILD_IMAGE_NAME
)
old_ver = (
run(grep_cmd, shell=True, cwd=PROJ_ROOT, capture_output=True)
.stdout.decode("utf-8")
.strip()
.split(":")[-1]
)
# Replace version in all files
for f in VERSIONED_FILES[submodule]:
sed_cmd = "sed -i 's/{}/{}/g' {}".format(old_ver, new_ver, f)
run(sed_cmd, shell=True, check=True)