Skip to content

Commit

Permalink
Add automatic dev build version
Browse files Browse the repository at this point in the history
  • Loading branch information
starsquidnodes committed Mar 6, 2024
1 parent 962840f commit b1c280a
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import subprocess
import sys
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", required=True)
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")
Expand All @@ -23,6 +24,18 @@ def build_arg(s):
return ["--build-arg", s]


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()

Expand All @@ -43,13 +56,14 @@ def build(command, namespace, app, tag, versions, push=False):
cmd += build_arg(f"go_version={go_version}")

if app == "prepare":
kujira_version = versions["pond"][tag]["kujira"]
feeder_version = versions["pond"][tag]["feeder"]
relayer_version = versions["pond"][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 Down Expand Up @@ -93,6 +107,11 @@ def main():

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 @@ -102,12 +121,12 @@ def main():
apps = [args.app]

for app in apps:
tag = versions["pond"][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, versions, args.push)
Expand Down

0 comments on commit b1c280a

Please sign in to comment.