Skip to content

Commit

Permalink
Merge pull request #2 from Team-Kujira/oracle
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
starsquidnodes authored Mar 6, 2024
2 parents c4f9e29 + fa5a091 commit 70e7a56
Show file tree
Hide file tree
Showing 22 changed files with 945 additions and 552 deletions.
83 changes: 42 additions & 41 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,39 @@
import platform
import subprocess
import sys

GO_VERSIONS = {
"kujira": {
"v0.9.0": "1.20.2",
"v0.9.1": "1.20.2",
"v0.9.2": "1.20.2",
"v0.9.3-1": "1.20.2",
"sdk-50": "1.21.3",
},
"feeder": {
"v0.8.3": "1.20.2",
"v0.11.0": "1.20.2",
},
"relayer": {
"v2.5.0": "1.21.7",
}
}

VERSIONS = {
"v0.1.0": {
"kujira": "v0.9.3-1",
"feeder": "v0.11.0",
"relayer": "v2.5.0"
}
}
import yaml
import datetime as dt


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-n", "--namespace", default="teamkujira")
parser.add_argument("-a", "--app")
parser.add_argument("-t", "--tag", default="v0.1.0")
parser.add_argument("-t", "--tag")
parser.add_argument("--push", action="store_true")
parser.add_argument("--podman", action="store_true")
parser.add_argument("--manifest", action="store_true")
parser.add_argument("--archs", default=platform.machine())
parser.add_argument("--archs")
return parser.parse_args()


def build_arg(s):
return ["--build-arg", s]


def build(command, namespace, app, tag, push=False):
def get_version(versions, name, tag):
versions = versions["pond"]
version = versions.get(tag, {}).get(name)
if not version:
version = versions["latest"].get(name)

if not version:
raise f"no version found for {name}"

return version


def build(command, namespace, app, tag, versions, push=False):
arch = platform.machine()

if arch == "x86_64":
Expand All @@ -58,7 +47,7 @@ def build(command, namespace, app, tag, push=False):
cmd = [command, "build", "--tag", fulltag]

if app in ["feeder", "kujira", "relayer"]:
go_version = GO_VERSIONS.get(app, {}).get(tag)
go_version = versions["go"].get(app, {}).get(tag)
if not go_version:
print(f"no go version defined for {app}:{tag}")
sys.exit(1)
Expand All @@ -67,13 +56,14 @@ def build(command, namespace, app, tag, push=False):
cmd += build_arg(f"go_version={go_version}")

if app == "prepare":
kujira_version = VERSIONS[tag]["kujira"]
feeder_version = VERSIONS[tag]["feeder"]
relayer_version = VERSIONS[tag]["relayer"]
kujira_version = get_version(versions, "kujira", tag)
feeder_version = get_version(versions, "feeder", tag)
relayer_version = get_version(versions, "relayer", tag)

cmd += build_arg(f"kujira_version={kujira_version}")
cmd += build_arg(f"feeder_version={feeder_version}")
cmd += build_arg(f"relayer_version={relayer_version}")
cmd += build_arg(f"prepare_version={tag}")
cmd += build_arg(f"namespace={namespace}")
cmd += build_arg(f"arch={arch}")

Expand All @@ -98,9 +88,6 @@ def manifest(command, namespace, app, tag, archs, push=False):
fulltag = f"{namespace}/{app}:{tag}"
commands = []

print("------------------")
print(fulltag)

tags = [f"{fulltag}-{x}" for x in archs.split(",")]
commands.append([command, "manifest", "create", f"{fulltag}"] + tags)

Expand All @@ -115,6 +102,13 @@ def manifest(command, namespace, app, tag, archs, push=False):
def main():
args = parse_args()

versions = yaml.safe_load(open("versions.yml", "r"))

pond_version = args.tag
if not pond_version:
pond_version = dt.datetime.utcnow().strftime("%Y%m%d%H%M%S")
versions["pond"][pond_version] = versions["pond"]["latest"]

command = "docker"
if args.podman:
command = "podman"
Expand All @@ -124,20 +118,27 @@ def main():
apps = [args.app]

for app in apps:
tag = VERSIONS[args.tag].get(app)
tag = versions["pond"][pond_version].get(app)
if app == "prepare":
tag = args.tag
tag = pond_version

if not tag:
print(f"no tag defined for {app} ({args.tag})")
print(f"no tag defined for {app} ({pond_version})")
sys.exit(1)

build(command, args.namespace, app, tag, args.push)
build(command, args.namespace, app, tag, versions, args.push)

if not args.manifest:
return
continue

archs = args.archs
if not archs:
archs = platform.machine()

if archs == "x86_64":
archs = "amd64"

manifest(command, args.namespace, app, tag, args.archs, args.push)
manifest(command, args.namespace, app, tag, archs, args.push)


if __name__ == "__main__":
Expand Down
16 changes: 0 additions & 16 deletions contracts/Dockerfile

This file was deleted.

Loading

0 comments on commit 70e7a56

Please sign in to comment.