insee_number_translator/tasks.py

48 lines
1.1 KiB
Python
Raw Normal View History

2021-08-18 23:05:48 +02:00
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
2021-08-06 16:07:55 +02:00
from invoke import Context, task
2021-08-18 23:05:48 +02:00
TARGETS = [
"darwin/amd64",
"freebsd/386",
"freebsd/amd64",
"freebsd/arm",
"freebsd/arm64",
"linux/386",
"linux/amd64",
"linux/arm",
"linux/arm64",
"windows/386",
"windows/amd64",
"windows/arm",
]
2021-08-06 16:07:55 +02:00
@task
def tag(context, tag):
"""Create & push a git tag"""
context: Context
context.run(f"git tag -a {tag} -m '{tag}'")
context.run("git push --follow-tags")
2021-08-18 23:05:48 +02:00
@task
2021-08-19 11:09:04 +02:00
def build(context, version_name):
2021-08-18 23:05:48 +02:00
"""Cross-platform build"""
with ThreadPoolExecutor() as pool:
for target in TARGETS:
os, arch = target.split("/")
2021-08-19 11:09:04 +02:00
binary_name = f"insee-{version_name}-{os}-{arch}"
2021-08-18 23:05:48 +02:00
if os == "windows":
binary_name += ".exe"
2021-08-19 11:09:04 +02:00
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,
)