From 883658acf32d6a569054c5debd585e86034c75af Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 18 Aug 2021 23:05:48 +0200 Subject: [PATCH] Add cross platform build script --- tasks.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tasks.py b/tasks.py index 524c138..0109782 100644 --- a/tasks.py +++ b/tasks.py @@ -1,5 +1,46 @@ +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + from invoke import Context, task +TARGETS = [ + "aix/ppc64", + "darwin/amd64", + "dragonfly/amd64", + "freebsd/386", + "freebsd/amd64", + "freebsd/arm", + "freebsd/arm64", + "illumos/amd64", + "linux/386", + "linux/amd64", + "linux/arm", + "linux/arm64", + "linux/ppc64", + "linux/ppc64le", + "linux/mips", + "linux/mipsle", + "linux/mips64", + "linux/mips64le", + "linux/riscv64", + "linux/s390x", + "netbsd/386", + "netbsd/amd64", + "netbsd/arm", + "netbsd/arm64", + "openbsd/386", + "openbsd/amd64", + "openbsd/arm", + "openbsd/arm64", + "plan9/386", + "plan9/amd64", + "plan9/arm", + "solaris/amd64", + "windows/386", + "windows/amd64", + "windows/arm", +] + @task def tag(context, tag): @@ -7,3 +48,16 @@ def tag(context, tag): context: Context context.run(f"git tag -a {tag} -m '{tag}'") context.run("git push --follow-tags") + + +@task +def build(context): + """Cross-platform build""" + with ThreadPoolExecutor() as pool: + for target in TARGETS: + os, arch = target.split("/") + binary_name = f"insee-{os}-{arch}" + if os == "windows": + binary_name += ".exe" + binary_path = Path(__file__).resolve(strict=True).parent / "dist" / binary_name + pool.submit(context.run, f"go build -o {binary_path}", env={"GOOS": os, "GOARCH": arch}, echo=True)