2020-02-12 21:55:44 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import sys
|
2023-03-20 08:45:50 +03:00
|
|
|
import glob
|
2022-06-25 21:40:47 +03:00
|
|
|
from copy import deepcopy
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2023-03-16 07:31:46 +03:00
|
|
|
TRIGGER_PATHS = [
|
|
|
|
"**/*.rs",
|
|
|
|
"**/Cargo.lock",
|
|
|
|
"**/Cargo.toml",
|
|
|
|
"assets/fonts/**/*",
|
|
|
|
"assets/icon/*",
|
|
|
|
"ci/deploy.sh",
|
|
|
|
]
|
|
|
|
|
|
|
|
TRIGGER_PATHS_APPIMAGE = [
|
|
|
|
"ci/appimage.sh",
|
|
|
|
"ci/appstreamcli",
|
|
|
|
"ci/source-archive.sh",
|
|
|
|
]
|
|
|
|
|
|
|
|
TRIGGER_PATHS_UNIX = [
|
|
|
|
"assets/open-wezterm-here",
|
|
|
|
"assets/shell-completion/**/*",
|
|
|
|
"assets/shell-integration/**/*",
|
|
|
|
"assets/wezterm-nautilus.py",
|
|
|
|
"assets/wezterm.appdata.xml",
|
|
|
|
"assets/wezterm.desktop",
|
|
|
|
"get-deps",
|
2023-03-24 16:48:49 +03:00
|
|
|
"ci/tag-name.sh",
|
2023-03-16 07:31:46 +03:00
|
|
|
"termwiz/data/wezterm.terminfo",
|
|
|
|
]
|
|
|
|
|
|
|
|
TRIGGER_PATHS_MAC = [
|
|
|
|
"assets/macos/**/*",
|
|
|
|
"ci/macos-entitlement.plist",
|
|
|
|
"get-deps",
|
2023-03-24 16:48:49 +03:00
|
|
|
"ci/tag-name.sh",
|
2023-03-16 07:31:46 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
TRIGGER_PATHS_WIN = [
|
|
|
|
"assets/windows/**/*",
|
|
|
|
"ci/windows-installer.iss",
|
|
|
|
]
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
def yv(v, depth=0):
|
2020-02-12 21:55:44 +03:00
|
|
|
if v is True:
|
|
|
|
return "true"
|
|
|
|
if v is False:
|
|
|
|
return "false"
|
|
|
|
if v is None:
|
|
|
|
return "nil"
|
|
|
|
|
|
|
|
if isinstance(v, str):
|
|
|
|
if "\n" in v:
|
2021-09-21 16:24:52 +03:00
|
|
|
indent = " " * depth
|
|
|
|
result = ""
|
|
|
|
for l in v.splitlines():
|
|
|
|
result = result + "\n" + (f"{indent}{l}" if l else "")
|
|
|
|
return "|" + result
|
2021-12-06 20:12:25 +03:00
|
|
|
# This is hideous
|
|
|
|
if '"' in v:
|
|
|
|
return "'" + v + "'"
|
2020-02-12 21:55:44 +03:00
|
|
|
return '"' + v + '"'
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
|
|
|
|
class Step(object):
|
2022-02-15 18:58:34 +03:00
|
|
|
def render(self, f, depth=0):
|
2020-02-12 21:55:44 +03:00
|
|
|
raise NotImplementedError(repr(self))
|
|
|
|
|
|
|
|
|
|
|
|
class RunStep(Step):
|
2021-11-22 21:27:14 +03:00
|
|
|
def __init__(self, name, run, shell="bash", env=None):
|
2020-02-12 21:55:44 +03:00
|
|
|
self.name = name
|
|
|
|
self.run = run
|
|
|
|
self.shell = shell
|
2021-11-22 21:27:14 +03:00
|
|
|
self.env = env
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
def render(self, f, depth=0):
|
2021-09-21 16:24:52 +03:00
|
|
|
indent = " " * depth
|
|
|
|
f.write(f"{indent}- name: {yv(self.name)}\n")
|
2021-11-22 21:27:14 +03:00
|
|
|
if self.env:
|
|
|
|
f.write(f"{indent} env:\n")
|
2022-06-25 21:40:47 +03:00
|
|
|
keys = list(self.env.keys())
|
|
|
|
keys.sort()
|
|
|
|
for k in keys:
|
|
|
|
v = self.env[k]
|
2021-11-22 21:27:14 +03:00
|
|
|
f.write(f"{indent} {k}: {v}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.shell:
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} shell: {self.shell}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
run = self.run
|
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} run: {yv(run, depth + 2)}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ActionStep(Step):
|
2021-09-21 16:17:23 +03:00
|
|
|
def __init__(self, name, action, params=None, env=None, condition=None):
|
2020-02-12 21:55:44 +03:00
|
|
|
self.name = name
|
|
|
|
self.action = action
|
|
|
|
self.params = params
|
|
|
|
self.env = env
|
2021-09-21 16:17:23 +03:00
|
|
|
self.condition = condition
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
def render(self, f, depth=0):
|
2021-09-21 16:24:52 +03:00
|
|
|
indent = " " * depth
|
|
|
|
f.write(f"{indent}- name: {yv(self.name)}\n")
|
|
|
|
f.write(f"{indent} uses: {self.action}\n")
|
2021-09-21 16:17:23 +03:00
|
|
|
if self.condition:
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} if: {self.condition}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.params:
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} with:\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
for k, v in self.params.items():
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} {k}: {yv(v, depth + 3)}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.env:
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} env:\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
for k, v in self.env.items():
|
2021-09-21 16:24:52 +03:00
|
|
|
f.write(f"{indent} {k}: {yv(v, depth + 3)}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
class CacheStep(ActionStep):
|
|
|
|
def __init__(self, name, path, key):
|
|
|
|
super().__init__(
|
2022-03-28 05:48:06 +03:00
|
|
|
name, action="actions/cache@v3", params={"path": path, "key": key}
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
2023-03-25 03:55:19 +03:00
|
|
|
|
2023-03-25 03:54:36 +03:00
|
|
|
class CacheRustStep(ActionStep):
|
2023-03-25 03:55:19 +03:00
|
|
|
def __init__(self, name, key):
|
|
|
|
super().__init__(name, action="Swatinem/rust-cache@v2", params={"key": key})
|
2023-03-25 03:54:36 +03:00
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
class CheckoutStep(ActionStep):
|
2023-09-11 06:50:45 +03:00
|
|
|
def __init__(self, name="checkout repo", submodules=True, container=None):
|
2021-12-08 21:19:00 +03:00
|
|
|
params = {}
|
|
|
|
if submodules:
|
|
|
|
params["submodules"] = "recursive"
|
2023-09-11 06:50:45 +03:00
|
|
|
# Newer versions of the checkout action use a binary-incompatible node
|
|
|
|
# binary, so we are pinned back on v3
|
|
|
|
# https://github.com/actions/checkout/issues/1442
|
|
|
|
version = "v3" if container is not None and "centos7" in container else "v4"
|
|
|
|
super().__init__(name, action=f"actions/checkout@{version}", params=params)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
2023-03-25 07:11:22 +03:00
|
|
|
class InstallCrateStep(ActionStep):
|
|
|
|
def __init__(self, crate: str, key: str, version=None):
|
|
|
|
params = {"crate": crate, "cache-key": key}
|
|
|
|
if version is not None:
|
|
|
|
params["version"] = version
|
|
|
|
super().__init__(
|
|
|
|
f"Install {crate} from Cargo",
|
|
|
|
action="baptiste0928/cargo-install@v2",
|
2023-03-26 08:16:22 +03:00
|
|
|
params=params,
|
2023-03-25 07:11:22 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
class Job(object):
|
|
|
|
def __init__(self, runs_on, container=None, steps=None, env=None):
|
|
|
|
self.runs_on = runs_on
|
|
|
|
self.container = container
|
|
|
|
self.steps = steps
|
|
|
|
self.env = env
|
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
def render(self, f, depth=0):
|
2022-02-15 18:58:34 +03:00
|
|
|
f.write("\n steps:\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
for s in self.steps:
|
2022-02-15 18:58:34 +03:00
|
|
|
s.render(f, depth)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Target(object):
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name=None,
|
|
|
|
os="ubuntu-latest",
|
|
|
|
container=None,
|
|
|
|
bootstrap_git=False,
|
|
|
|
rust_target=None,
|
2020-05-03 21:21:58 +03:00
|
|
|
continuous_only=False,
|
|
|
|
app_image=False,
|
2022-02-15 18:58:34 +03:00
|
|
|
is_tag=False,
|
2020-02-12 21:55:44 +03:00
|
|
|
):
|
|
|
|
if not name:
|
|
|
|
if container:
|
|
|
|
name = container
|
|
|
|
else:
|
|
|
|
name = os
|
|
|
|
self.name = name.replace(":", "")
|
|
|
|
self.os = os
|
|
|
|
self.container = container
|
|
|
|
self.bootstrap_git = bootstrap_git
|
|
|
|
self.rust_target = rust_target
|
2020-05-03 21:21:58 +03:00
|
|
|
self.continuous_only = continuous_only
|
|
|
|
self.app_image = app_image
|
2022-02-15 18:58:34 +03:00
|
|
|
self.env = {}
|
|
|
|
self.is_tag = is_tag
|
|
|
|
|
|
|
|
def render_env(self, f, depth=0):
|
|
|
|
self.global_env()
|
|
|
|
if self.env:
|
|
|
|
indent = " "
|
|
|
|
f.write(f"{indent}env:\n")
|
|
|
|
for k, v in self.env.items():
|
|
|
|
f.write(f"{indent} {k}: {yv(v, depth + 3)}\n")
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def uses_yum(self):
|
|
|
|
if "fedora" in self.name:
|
|
|
|
return True
|
|
|
|
if "centos" in self.name:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2020-05-03 21:21:58 +03:00
|
|
|
def uses_apt(self):
|
|
|
|
if "ubuntu" in self.name:
|
|
|
|
return True
|
|
|
|
if "debian" in self.name:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
def uses_apk(self):
|
|
|
|
if "alpine" in self.name:
|
|
|
|
return True
|
|
|
|
return False
|
2022-04-26 07:11:00 +03:00
|
|
|
|
2022-04-25 23:27:56 +03:00
|
|
|
def uses_zypper(self):
|
|
|
|
if "suse" in self.name:
|
|
|
|
return True
|
|
|
|
return False
|
2022-02-15 18:58:34 +03:00
|
|
|
|
2020-05-04 02:16:52 +03:00
|
|
|
def needs_sudo(self):
|
|
|
|
if not self.container and self.uses_apt():
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def install_system_package(self, name):
|
|
|
|
installer = None
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.uses_yum():
|
2020-05-04 02:16:52 +03:00
|
|
|
installer = "yum"
|
|
|
|
elif self.uses_apt():
|
|
|
|
installer = "apt-get"
|
2022-02-15 18:58:34 +03:00
|
|
|
elif self.uses_apk():
|
|
|
|
installer = "apk"
|
2022-04-25 23:27:56 +03:00
|
|
|
elif self.uses_zypper():
|
|
|
|
installer = "zypper"
|
2020-05-04 02:16:52 +03:00
|
|
|
else:
|
|
|
|
return []
|
|
|
|
if self.needs_sudo():
|
|
|
|
installer = f"sudo -n {installer}"
|
2022-02-15 18:58:34 +03:00
|
|
|
if self.uses_apk():
|
|
|
|
return [RunStep(f"Install {name}", f"{installer} add {name}")]
|
|
|
|
else:
|
|
|
|
return [RunStep(f"Install {name}", f"{installer} install -y {name}")]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2020-05-03 21:21:58 +03:00
|
|
|
def install_curl(self):
|
2022-04-26 07:11:00 +03:00
|
|
|
if (
|
|
|
|
self.uses_yum()
|
|
|
|
or self.uses_apk()
|
|
|
|
or self.uses_zypper()
|
|
|
|
or (self.uses_apt() and self.container)
|
|
|
|
):
|
2022-02-02 00:34:21 +03:00
|
|
|
if "centos:stream9" in self.container:
|
|
|
|
return self.install_system_package("curl-minimal")
|
|
|
|
else:
|
|
|
|
return self.install_system_package("curl")
|
2020-05-04 02:16:52 +03:00
|
|
|
return []
|
2020-05-03 21:21:58 +03:00
|
|
|
|
2021-09-27 05:30:50 +03:00
|
|
|
def install_openssh_server(self):
|
2022-02-15 18:58:34 +03:00
|
|
|
steps = []
|
2022-04-26 07:11:00 +03:00
|
|
|
if (
|
|
|
|
self.uses_yum()
|
|
|
|
or self.uses_zypper()
|
|
|
|
or (self.uses_apt() and self.container)
|
|
|
|
):
|
2022-02-15 18:58:34 +03:00
|
|
|
steps += [
|
2021-12-06 19:11:26 +03:00
|
|
|
RunStep("Ensure /run/sshd exists", "mkdir -p /run/sshd")
|
|
|
|
] + self.install_system_package("openssh-server")
|
2022-02-15 18:58:34 +03:00
|
|
|
if self.uses_apk():
|
|
|
|
steps += self.install_system_package("openssh")
|
|
|
|
return steps
|
2021-09-27 05:30:50 +03:00
|
|
|
|
2021-08-20 07:22:36 +03:00
|
|
|
def install_newer_compiler(self):
|
|
|
|
steps = []
|
|
|
|
if self.name == "centos7":
|
2021-08-20 07:31:46 +03:00
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Install SCL",
|
|
|
|
"yum install -y centos-release-scl-rh",
|
|
|
|
)
|
|
|
|
)
|
2021-08-20 07:22:36 +03:00
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Update compiler",
|
|
|
|
"yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return steps
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
def install_git(self):
|
2020-05-03 21:21:58 +03:00
|
|
|
steps = []
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.bootstrap_git:
|
2020-05-30 20:06:56 +03:00
|
|
|
GIT_VERS = "2.26.2"
|
2020-05-03 21:21:58 +03:00
|
|
|
steps.append(
|
2020-02-12 21:55:44 +03:00
|
|
|
CacheStep(
|
|
|
|
"Cache Git installation",
|
|
|
|
path="/usr/local/git",
|
2020-05-03 21:21:58 +03:00
|
|
|
key=f"{self.name}-git-{GIT_VERS}",
|
2020-06-07 22:20:56 +03:00
|
|
|
)
|
|
|
|
)
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
pre_reqs = ""
|
|
|
|
if self.uses_yum():
|
|
|
|
pre_reqs = "yum install -y wget curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker make"
|
|
|
|
elif self.uses_apt():
|
|
|
|
pre_reqs = "apt-get install -y wget libcurl4-openssl-dev libexpat-dev gettext libssl-dev libz-dev gcc libextutils-autoinstall-perl make"
|
2022-04-25 23:27:56 +03:00
|
|
|
elif self.uses_zypper():
|
|
|
|
pre_reqs = "zypper install -y wget libcurl-devel libexpat-devel gettext-tools libopenssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker make"
|
2020-05-03 21:21:58 +03:00
|
|
|
|
2020-06-07 22:20:56 +03:00
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
name="Install Git from source",
|
|
|
|
shell="bash",
|
2021-09-21 16:24:52 +03:00
|
|
|
run=f"""{pre_reqs}
|
2020-02-12 21:55:44 +03:00
|
|
|
if test ! -x /usr/local/git/bin/git ; then
|
|
|
|
cd /tmp
|
2020-05-30 20:06:56 +03:00
|
|
|
wget https://github.com/git/git/archive/v{GIT_VERS}.tar.gz
|
|
|
|
tar xzf v{GIT_VERS}.tar.gz
|
2020-05-03 21:21:58 +03:00
|
|
|
cd git-{GIT_VERS}
|
2020-02-12 21:55:44 +03:00
|
|
|
make prefix=/usr/local/git install
|
|
|
|
fi
|
2021-09-21 16:24:52 +03:00
|
|
|
ln -s /usr/local/git/bin/git /usr/local/bin/git""",
|
2020-06-07 22:20:56 +03:00
|
|
|
)
|
|
|
|
)
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
else:
|
2023-01-01 09:44:04 +03:00
|
|
|
if "tumbleweed" in self.name:
|
|
|
|
# git-core requires /usr/bin/which and that gets satisfied
|
|
|
|
# by busybox-which by default, which blocks installing
|
|
|
|
# rpmbuild, which depends on the which rpm directly,
|
|
|
|
# but that is blocked by the conflicting busybox-which rpm.
|
|
|
|
# So we explicitly install which here now
|
|
|
|
steps += self.install_system_package("which")
|
|
|
|
|
2020-05-04 02:16:52 +03:00
|
|
|
steps += self.install_system_package("git")
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
return steps
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2023-03-24 20:16:09 +03:00
|
|
|
def install_rust(self, cache=True, toolchain="stable"):
|
2020-10-10 19:25:11 +03:00
|
|
|
salt = "2"
|
2023-03-25 03:54:36 +03:00
|
|
|
key_prefix = f"{self.name}-{self.rust_target}-{salt}-${{{{ runner.os }}}}"
|
2023-03-24 20:16:09 +03:00
|
|
|
params = dict()
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.rust_target:
|
|
|
|
params["target"] = self.rust_target
|
2023-03-24 20:16:09 +03:00
|
|
|
steps = []
|
|
|
|
# Manually setup rust toolchain in CentOS7 curl is too old for the action
|
|
|
|
if "centos7" in self.name:
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
name="Install Rustup",
|
2023-03-24 20:16:47 +03:00
|
|
|
run="""
|
2023-03-24 20:16:09 +03:00
|
|
|
if ! command -v rustup &>/dev/null; then
|
|
|
|
curl --proto '=https' --tlsv1.2 --retry 10 -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
|
|
|
|
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
|
|
|
|
fi
|
2023-03-24 20:16:47 +03:00
|
|
|
""",
|
2023-03-24 20:16:09 +03:00
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
name="Setup Toolchain",
|
2023-03-24 20:16:47 +03:00
|
|
|
run=f"""
|
2023-03-24 20:16:09 +03:00
|
|
|
rustup toolchain install {toolchain} --profile minimal --no-self-update
|
|
|
|
rustup default {toolchain}
|
2023-03-24 20:16:47 +03:00
|
|
|
""",
|
2023-03-24 20:16:09 +03:00
|
|
|
),
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
steps += [
|
|
|
|
ActionStep(
|
|
|
|
name="Install Rust",
|
|
|
|
action=f"dtolnay/rust-toolchain@{toolchain}",
|
|
|
|
params=params,
|
|
|
|
),
|
|
|
|
]
|
2021-01-13 08:12:54 +03:00
|
|
|
if "macos" in self.name:
|
|
|
|
steps += [
|
2021-08-20 05:22:22 +03:00
|
|
|
RunStep(
|
|
|
|
name="Install Rust (ARM)",
|
|
|
|
run="rustup target add aarch64-apple-darwin",
|
|
|
|
)
|
2021-01-13 08:12:54 +03:00
|
|
|
]
|
2020-10-10 19:25:11 +03:00
|
|
|
if cache:
|
|
|
|
steps += [
|
2023-03-25 03:54:36 +03:00
|
|
|
CacheRustStep(
|
2020-10-10 19:25:11 +03:00
|
|
|
name="Cache cargo",
|
|
|
|
key=f"{key_prefix}-cargo",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
return steps
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def install_system_deps(self):
|
|
|
|
if "win" in self.name:
|
|
|
|
return []
|
2020-05-04 02:16:52 +03:00
|
|
|
sudo = "sudo -n " if self.needs_sudo() else ""
|
2023-01-01 09:44:04 +03:00
|
|
|
return [
|
2023-03-24 20:16:47 +03:00
|
|
|
RunStep(
|
|
|
|
name="Install System Deps",
|
|
|
|
run=f"{sudo}env CI=yes PATH=$PATH ./get-deps",
|
|
|
|
)
|
2021-08-20 05:22:22 +03:00
|
|
|
]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def build_all_release(self):
|
|
|
|
if "win" in self.name:
|
|
|
|
return [
|
|
|
|
RunStep(
|
|
|
|
name="Build (Release mode)",
|
|
|
|
shell="cmd",
|
|
|
|
run="""
|
|
|
|
PATH C:\\Strawberry\\perl\\bin;%PATH%
|
|
|
|
cargo build --all --release""",
|
|
|
|
)
|
|
|
|
]
|
2021-01-13 08:12:54 +03:00
|
|
|
if "macos" in self.name:
|
|
|
|
return [
|
|
|
|
RunStep(
|
|
|
|
name="Build (Release mode Intel)",
|
2021-08-20 05:22:22 +03:00
|
|
|
run="cargo build --target x86_64-apple-darwin --all --release",
|
|
|
|
),
|
2021-01-13 08:12:54 +03:00
|
|
|
RunStep(
|
|
|
|
name="Build (Release mode ARM)",
|
2021-08-20 05:22:22 +03:00
|
|
|
run="cargo build --target aarch64-apple-darwin --all --release",
|
|
|
|
),
|
2021-01-13 08:12:54 +03:00
|
|
|
]
|
2021-08-20 05:22:22 +03:00
|
|
|
if self.name == "centos7":
|
|
|
|
enable = "source /opt/rh/devtoolset-9/enable && "
|
|
|
|
else:
|
|
|
|
enable = ""
|
|
|
|
return [
|
|
|
|
RunStep(
|
|
|
|
name="Build (Release mode)", run=enable + "cargo build --all --release"
|
|
|
|
)
|
|
|
|
]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def test_all_release(self):
|
2023-07-13 18:14:02 +03:00
|
|
|
run = "cargo nextest run --all --release --no-fail-fast"
|
2021-01-13 08:12:54 +03:00
|
|
|
if "macos" in self.name:
|
2023-03-25 07:11:22 +03:00
|
|
|
run += " --target=x86_64-apple-darwin"
|
2021-08-20 05:22:22 +03:00
|
|
|
if self.name == "centos7":
|
2023-03-25 07:11:22 +03:00
|
|
|
run = "source /opt/rh/devtoolset-9/enable\n" + run
|
2021-08-20 05:22:22 +03:00
|
|
|
return [
|
2023-03-25 07:11:22 +03:00
|
|
|
# Install cargo-nextest
|
|
|
|
InstallCrateStep("cargo-nextest", key=self.name),
|
|
|
|
# Run tests
|
2021-08-20 05:22:22 +03:00
|
|
|
RunStep(
|
2023-07-13 18:14:02 +03:00
|
|
|
name="Test (Release mode)",
|
2023-03-25 07:11:22 +03:00
|
|
|
run=run,
|
|
|
|
),
|
2021-08-20 05:22:22 +03:00
|
|
|
]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-11-22 21:27:14 +03:00
|
|
|
def package(self, trusted=False):
|
|
|
|
steps = []
|
|
|
|
deploy_env = None
|
|
|
|
if trusted and ("mac" in self.name):
|
|
|
|
deploy_env = {
|
|
|
|
"MACOS_CERT": "${{ secrets.MACOS_CERT }}",
|
2021-11-23 06:25:14 +03:00
|
|
|
"MACOS_CERT_PW": "${{ secrets.MACOS_CERT_PW }}",
|
2021-11-22 21:27:14 +03:00
|
|
|
"MACOS_TEAM_ID": "${{ secrets.MACOS_TEAM_ID }}",
|
|
|
|
"MACOS_APPLEID": "${{ secrets.MACOS_APPLEID }}",
|
|
|
|
"MACOS_APP_PW": "${{ secrets.MACOS_APP_PW }}",
|
|
|
|
}
|
|
|
|
steps = [RunStep("Package", "bash ci/deploy.sh", env=deploy_env)]
|
2020-05-03 21:21:58 +03:00
|
|
|
if self.app_image:
|
2023-02-17 21:33:35 +03:00
|
|
|
# AppImage needs fuse
|
2023-02-17 22:13:02 +03:00
|
|
|
steps += self.install_system_package("libfuse2")
|
2020-10-11 03:14:06 +03:00
|
|
|
steps.append(RunStep("Source Tarball", "bash ci/source-archive.sh"))
|
2020-05-03 21:21:58 +03:00
|
|
|
steps.append(RunStep("Build AppImage", "bash ci/appimage.sh"))
|
|
|
|
return steps
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def upload_artifact(self):
|
2021-12-09 05:57:25 +03:00
|
|
|
steps = []
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
if self.uses_yum():
|
2021-12-09 05:57:25 +03:00
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Move RPM",
|
|
|
|
f"mv ~/rpmbuild/RPMS/*/*.rpm .",
|
|
|
|
)
|
|
|
|
)
|
2022-04-19 16:19:59 +03:00
|
|
|
elif self.uses_apk():
|
2022-04-20 07:18:36 +03:00
|
|
|
steps += [
|
|
|
|
# Add the distro name/version into the filename
|
|
|
|
RunStep(
|
|
|
|
"Rename APKs",
|
2022-04-25 17:10:18 +03:00
|
|
|
f"mv ~/packages/wezterm/x86_64/*.apk $(echo ~/packages/wezterm/x86_64/*.apk | sed -e 's/wezterm-/wezterm-{self.name}-/')",
|
2022-04-20 07:18:36 +03:00
|
|
|
),
|
|
|
|
# Move it to the repo dir
|
2022-04-19 08:18:22 +03:00
|
|
|
RunStep(
|
|
|
|
"Move APKs",
|
2022-04-20 07:18:36 +03:00
|
|
|
f"mv ~/packages/wezterm/x86_64/*.apk .",
|
|
|
|
),
|
|
|
|
# Move and rename the keys
|
2022-04-19 08:18:22 +03:00
|
|
|
RunStep(
|
|
|
|
"Move APK keys",
|
2022-04-20 07:18:36 +03:00
|
|
|
f"mv ~/.abuild/*.pub wezterm-{self.name}.pub",
|
2022-04-26 07:11:00 +03:00
|
|
|
),
|
2022-04-20 07:18:36 +03:00
|
|
|
]
|
2022-04-25 23:27:56 +03:00
|
|
|
elif self.uses_zypper():
|
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Move RPM",
|
|
|
|
f"mv /usr/src/packages/RPMS/*/*.rpm .",
|
|
|
|
)
|
|
|
|
)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-12-09 05:57:25 +03:00
|
|
|
patterns = self.asset_patterns()
|
|
|
|
glob = " ".join(patterns)
|
|
|
|
paths = "\n".join(patterns)
|
|
|
|
|
|
|
|
return steps + [
|
2020-02-12 21:55:44 +03:00
|
|
|
ActionStep(
|
|
|
|
"Upload artifact",
|
2022-04-11 04:36:34 +03:00
|
|
|
action="actions/upload-artifact@v3",
|
2021-12-09 05:57:25 +03:00
|
|
|
params={"name": self.name, "path": paths},
|
2020-02-12 21:55:44 +03:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2020-05-03 21:21:58 +03:00
|
|
|
def asset_patterns(self):
|
|
|
|
patterns = []
|
2022-04-25 23:27:56 +03:00
|
|
|
if self.uses_yum() or self.uses_zypper():
|
2020-05-03 21:21:58 +03:00
|
|
|
patterns += ["wezterm-*.rpm"]
|
2020-05-25 10:12:36 +03:00
|
|
|
elif "win" in self.name:
|
|
|
|
patterns += ["WezTerm-*.zip", "WezTerm-*.exe"]
|
|
|
|
elif "mac" in self.name:
|
2020-05-03 21:21:58 +03:00
|
|
|
patterns += ["WezTerm-*.zip"]
|
|
|
|
elif ("ubuntu" in self.name) or ("debian" in self.name):
|
2021-12-06 23:14:16 +03:00
|
|
|
patterns += ["wezterm-*.deb", "wezterm-*.xz"]
|
2022-02-15 18:58:34 +03:00
|
|
|
elif "alpine" in self.name:
|
2022-04-19 08:18:22 +03:00
|
|
|
patterns += ["wezterm-*.apk"]
|
2022-02-15 18:58:34 +03:00
|
|
|
if self.is_tag:
|
2022-04-19 08:18:22 +03:00
|
|
|
patterns.append("*.pub")
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
if self.app_image:
|
2021-12-06 23:14:16 +03:00
|
|
|
patterns.append("*src.tar.gz")
|
2020-05-03 21:21:58 +03:00
|
|
|
patterns.append("*.AppImage")
|
2020-05-05 09:38:50 +03:00
|
|
|
patterns.append("*.zsync")
|
2020-05-03 21:21:58 +03:00
|
|
|
return patterns
|
|
|
|
|
2021-12-08 20:14:08 +03:00
|
|
|
def upload_artifact_nightly(self):
|
2020-02-12 21:55:44 +03:00
|
|
|
steps = []
|
|
|
|
|
|
|
|
if self.uses_yum():
|
|
|
|
steps.append(
|
2020-02-13 00:20:11 +03:00
|
|
|
RunStep(
|
|
|
|
"Move RPM",
|
|
|
|
f"mv ~/rpmbuild/RPMS/*/*.rpm wezterm-nightly-{self.name}.rpm",
|
|
|
|
)
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
2022-04-19 16:19:59 +03:00
|
|
|
elif self.uses_apk():
|
2022-04-19 08:58:27 +03:00
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Move APKs",
|
2022-04-20 07:18:36 +03:00
|
|
|
f"mv ~/packages/wezterm/x86_64/*.apk wezterm-nightly-{self.name}.apk",
|
2022-04-19 08:58:27 +03:00
|
|
|
)
|
|
|
|
)
|
2022-04-25 23:27:56 +03:00
|
|
|
elif self.uses_zypper():
|
|
|
|
steps.append(
|
|
|
|
RunStep(
|
|
|
|
"Move RPM",
|
|
|
|
f"mv /usr/src/packages/RPMS/*/*.rpm wezterm-nightly-{self.name}.rpm",
|
|
|
|
)
|
|
|
|
)
|
2020-05-03 21:21:58 +03:00
|
|
|
|
2021-12-07 05:37:33 +03:00
|
|
|
patterns = self.asset_patterns()
|
|
|
|
glob = " ".join(patterns)
|
|
|
|
paths = "\n".join(patterns)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
return steps + [
|
2021-12-07 05:37:33 +03:00
|
|
|
ActionStep(
|
|
|
|
"Upload artifact",
|
2022-04-11 04:36:34 +03:00
|
|
|
action="actions/upload-artifact@v3",
|
2021-12-08 20:14:08 +03:00
|
|
|
params={"name": self.name, "path": paths, "retention-days": 5},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
def upload_asset_nightly(self):
|
|
|
|
steps = []
|
|
|
|
|
|
|
|
patterns = self.asset_patterns()
|
2022-07-25 18:39:24 +03:00
|
|
|
checksum = RunStep(
|
|
|
|
"Checksum",
|
|
|
|
f"for f in {' '.join(patterns)} ; do sha256sum $f > $f.sha256 ; done",
|
|
|
|
)
|
|
|
|
|
|
|
|
patterns.append("*.sha256")
|
2021-12-08 20:14:08 +03:00
|
|
|
glob = " ".join(patterns)
|
|
|
|
|
2024-01-11 01:54:36 +03:00
|
|
|
if self.container == "ubuntu:22.04":
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"Upload to gemfury",
|
|
|
|
f"for f in wezterm*.deb ; do curl -i -F package=@$f https://$FURY_TOKEN@push.fury.io/wez/ ; done",
|
|
|
|
env={"FURY_TOKEN": "${{ secrets.FURY_TOKEN }}"},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
return [
|
2021-12-08 20:14:08 +03:00
|
|
|
ActionStep(
|
|
|
|
"Download artifact",
|
2022-04-11 04:36:34 +03:00
|
|
|
action="actions/download-artifact@v3",
|
2021-12-08 20:14:08 +03:00
|
|
|
params={"name": self.name},
|
2021-12-07 05:37:33 +03:00
|
|
|
),
|
2022-07-25 18:39:24 +03:00
|
|
|
checksum,
|
2021-12-06 19:11:26 +03:00
|
|
|
RunStep(
|
2020-02-12 21:55:44 +03:00
|
|
|
"Upload to Nightly Release",
|
2021-12-08 21:19:00 +03:00
|
|
|
f"bash ci/retry.sh gh release upload --clobber nightly {glob}",
|
2021-12-06 19:11:26 +03:00
|
|
|
env={"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"},
|
2021-12-07 05:37:33 +03:00
|
|
|
),
|
2024-01-11 01:54:36 +03:00
|
|
|
] + steps
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def upload_asset_tag(self):
|
|
|
|
steps = []
|
|
|
|
|
2021-12-07 05:41:10 +03:00
|
|
|
patterns = self.asset_patterns()
|
2022-07-25 18:39:24 +03:00
|
|
|
checksum = RunStep(
|
|
|
|
"Checksum",
|
|
|
|
f"for f in {' '.join(patterns)} ; do sha256sum $f > $f.sha256 ; done",
|
|
|
|
)
|
|
|
|
|
|
|
|
patterns.append("*.sha256")
|
2021-12-07 05:41:10 +03:00
|
|
|
glob = " ".join(patterns)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
return steps + [
|
2021-12-07 05:41:10 +03:00
|
|
|
ActionStep(
|
2021-12-09 05:57:25 +03:00
|
|
|
"Download artifact",
|
2022-04-11 04:36:34 +03:00
|
|
|
action="actions/download-artifact@v3",
|
2021-12-09 05:57:25 +03:00
|
|
|
params={"name": self.name},
|
2021-12-07 05:41:10 +03:00
|
|
|
),
|
2022-07-25 18:39:24 +03:00
|
|
|
checksum,
|
2021-12-06 19:11:26 +03:00
|
|
|
RunStep(
|
|
|
|
"Create pre-release",
|
2022-01-01 23:33:40 +03:00
|
|
|
"bash ci/retry.sh bash ci/create-release.sh $(ci/tag-name.sh)",
|
2022-01-01 23:10:08 +03:00
|
|
|
env={
|
|
|
|
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
|
|
|
|
},
|
2021-12-06 19:11:26 +03:00
|
|
|
),
|
|
|
|
RunStep(
|
2020-02-12 21:55:44 +03:00
|
|
|
"Upload to Tagged Release",
|
2022-01-01 23:33:40 +03:00
|
|
|
f"bash ci/retry.sh gh release upload --clobber $(ci/tag-name.sh) {glob}",
|
2022-01-01 23:10:08 +03:00
|
|
|
env={
|
|
|
|
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
|
|
|
|
},
|
2021-12-06 19:11:26 +03:00
|
|
|
),
|
2020-02-12 21:55:44 +03:00
|
|
|
]
|
|
|
|
|
2023-03-26 08:16:22 +03:00
|
|
|
def create_flathub_pr(self):
|
|
|
|
if not self.app_image:
|
|
|
|
return []
|
|
|
|
return [
|
|
|
|
ActionStep(
|
|
|
|
"Checkout flathub/org.wezfurlong.wezterm",
|
2023-09-11 06:50:45 +03:00
|
|
|
action="actions/checkout@v4",
|
2023-03-26 08:16:22 +03:00
|
|
|
params={
|
|
|
|
"repository": "flathub/org.wezfurlong.wezterm",
|
|
|
|
"path": "flathub",
|
|
|
|
"token": "${{ secrets.GH_PAT }}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Create flathub commit and push",
|
|
|
|
"bash ci/make-flathub-pr.sh",
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Submit PR",
|
|
|
|
'cd flathub && gh pr create --fill --body "PR automatically created by release automation in the wezterm repo"',
|
|
|
|
env={
|
|
|
|
"GITHUB_TOKEN": "${{ secrets.GH_PAT }}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2022-06-28 21:47:11 +03:00
|
|
|
def create_winget_pr(self):
|
|
|
|
steps = []
|
|
|
|
if "windows" in self.name:
|
|
|
|
steps += [
|
|
|
|
ActionStep(
|
|
|
|
"Checkout winget-pkgs",
|
2023-09-11 06:50:45 +03:00
|
|
|
action="actions/checkout@v4",
|
2022-06-28 21:47:11 +03:00
|
|
|
params={
|
|
|
|
"repository": "wez/winget-pkgs",
|
|
|
|
"path": "winget-pkgs",
|
|
|
|
"token": "${{ secrets.GH_PAT }}",
|
|
|
|
},
|
|
|
|
),
|
2022-08-07 21:30:36 +03:00
|
|
|
RunStep(
|
|
|
|
"Setup email for winget repo",
|
|
|
|
"cd winget-pkgs && git config user.email wez@wezfurlong.org",
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Setup name for winget repo",
|
|
|
|
"cd winget-pkgs && git config user.name 'Wez Furlong'",
|
|
|
|
),
|
2022-06-28 21:47:11 +03:00
|
|
|
RunStep(
|
|
|
|
"Create winget manifest and push to fork",
|
|
|
|
"bash ci/make-winget-pr.sh winget-pkgs WezTerm-*.exe",
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Submit PR",
|
2022-08-07 20:51:56 +03:00
|
|
|
'cd winget-pkgs && gh pr create --fill --body "PR automatically created by release automation in the wezterm repo"',
|
2022-06-28 21:47:11 +03:00
|
|
|
env={
|
|
|
|
"GITHUB_TOKEN": "${{ secrets.GH_PAT }}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
return steps
|
|
|
|
|
2020-06-07 22:48:41 +03:00
|
|
|
def update_homebrew_tap(self):
|
|
|
|
steps = []
|
|
|
|
if "macos" in self.name:
|
|
|
|
steps += [
|
|
|
|
ActionStep(
|
|
|
|
"Checkout homebrew tap",
|
2023-09-11 06:50:45 +03:00
|
|
|
action="actions/checkout@v4",
|
2020-06-07 22:48:41 +03:00
|
|
|
params={
|
|
|
|
"repository": "wez/homebrew-wezterm",
|
|
|
|
"path": "homebrew-wezterm",
|
2020-06-08 20:16:43 +03:00
|
|
|
"token": "${{ secrets.GH_PAT }}",
|
2020-06-07 22:48:41 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Update homebrew tap formula",
|
2021-05-22 18:30:10 +03:00
|
|
|
"cp wezterm.rb homebrew-wezterm/Casks/wezterm.rb",
|
2020-06-07 22:48:41 +03:00
|
|
|
),
|
|
|
|
ActionStep(
|
|
|
|
"Commit homebrew tap changes",
|
|
|
|
action="stefanzweifel/git-auto-commit-action@v4",
|
|
|
|
params={
|
|
|
|
"commit_message": "Automated update to match latest tag",
|
2020-06-08 19:18:03 +03:00
|
|
|
"repository": "homebrew-wezterm",
|
2020-06-07 22:48:41 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
2020-07-05 19:40:28 +03:00
|
|
|
elif self.app_image:
|
|
|
|
steps += [
|
|
|
|
ActionStep(
|
|
|
|
"Checkout linuxbrew tap",
|
2023-09-11 06:50:45 +03:00
|
|
|
action="actions/checkout@v4",
|
2020-07-05 19:40:28 +03:00
|
|
|
params={
|
|
|
|
"repository": "wez/homebrew-wezterm-linuxbrew",
|
|
|
|
"path": "linuxbrew-wezterm",
|
|
|
|
"token": "${{ secrets.GH_PAT }}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Update linuxbrew tap formula",
|
|
|
|
"cp wezterm-linuxbrew.rb linuxbrew-wezterm/Formula/wezterm.rb",
|
|
|
|
),
|
|
|
|
ActionStep(
|
|
|
|
"Commit linuxbrew tap changes",
|
|
|
|
action="stefanzweifel/git-auto-commit-action@v4",
|
|
|
|
params={
|
|
|
|
"commit_message": "Automated update to match latest tag",
|
|
|
|
"repository": "linuxbrew-wezterm",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
2020-06-07 22:48:41 +03:00
|
|
|
|
|
|
|
return steps
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
def global_env(self):
|
|
|
|
if "macos" in self.name:
|
2022-02-15 18:58:34 +03:00
|
|
|
self.env["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
|
|
|
|
if "alpine" in self.name:
|
|
|
|
self.env["RUSTFLAGS"] = "-C target-feature=-crt-static"
|
|
|
|
return
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2020-10-10 19:25:11 +03:00
|
|
|
def prep_environment(self, cache=True):
|
2020-02-12 21:55:44 +03:00
|
|
|
steps = []
|
2021-12-06 19:52:19 +03:00
|
|
|
sudo = "sudo -n " if self.needs_sudo() else ""
|
2020-06-20 07:28:05 +03:00
|
|
|
if self.uses_apt():
|
2020-06-20 07:46:33 +03:00
|
|
|
if self.container:
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"set APT to non-interactive",
|
|
|
|
"echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections",
|
|
|
|
),
|
|
|
|
]
|
2020-12-11 06:52:36 +03:00
|
|
|
steps += [
|
|
|
|
RunStep("Update APT", f"{sudo}apt update"),
|
|
|
|
]
|
2021-12-06 19:45:14 +03:00
|
|
|
|
2022-04-25 23:27:56 +03:00
|
|
|
if self.uses_zypper():
|
|
|
|
if self.container:
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"Seed GITHUB_PATH to work around possible @action/core bug",
|
2022-04-26 07:11:00 +03:00
|
|
|
f'echo "$PATH:/bin:/usr/bin" >> $GITHUB_PATH',
|
2022-04-25 23:27:56 +03:00
|
|
|
),
|
|
|
|
RunStep(
|
2022-10-22 07:47:09 +03:00
|
|
|
"Install util-linux",
|
|
|
|
"zypper install -y util-linux",
|
2022-04-25 23:27:56 +03:00
|
|
|
),
|
|
|
|
]
|
2020-05-03 21:21:58 +03:00
|
|
|
if self.container:
|
2022-05-11 07:23:56 +03:00
|
|
|
if ("fedora" in self.container) or (
|
|
|
|
("centos" in self.container) and ("centos7" not in self.container)
|
|
|
|
):
|
2020-05-04 18:21:30 +03:00
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"Install config manager",
|
2020-06-07 22:20:56 +03:00
|
|
|
"dnf install -y 'dnf-command(config-manager)'",
|
2020-05-04 18:21:30 +03:00
|
|
|
),
|
2021-12-06 19:59:21 +03:00
|
|
|
]
|
2022-02-02 00:30:55 +03:00
|
|
|
if "centos:stream8" in self.container:
|
2021-12-06 19:59:21 +03:00
|
|
|
steps += [
|
2020-05-04 18:21:30 +03:00
|
|
|
RunStep(
|
|
|
|
"Enable PowerTools",
|
2020-12-08 08:34:30 +03:00
|
|
|
"dnf config-manager --set-enabled powertools",
|
2020-06-07 22:20:56 +03:00
|
|
|
),
|
2021-12-06 19:59:21 +03:00
|
|
|
]
|
2022-02-02 01:02:24 +03:00
|
|
|
if "centos:stream9" in self.container:
|
|
|
|
steps += [
|
|
|
|
# This holds the xcb bits
|
|
|
|
RunStep(
|
|
|
|
"Enable CRB repo for X bits",
|
|
|
|
"dnf config-manager --set-enabled crb",
|
|
|
|
),
|
|
|
|
]
|
2022-02-15 18:58:34 +03:00
|
|
|
if "alpine" in self.container:
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"Upgrade system",
|
|
|
|
"apk upgrade --update-cache",
|
|
|
|
shell="sh",
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Install CI dependencies",
|
2022-04-19 16:19:59 +03:00
|
|
|
"apk add nodejs zstd wget bash coreutils tar findutils",
|
2022-02-15 18:58:34 +03:00
|
|
|
shell="sh",
|
|
|
|
),
|
|
|
|
RunStep(
|
|
|
|
"Allow root login",
|
|
|
|
"sed 's/root:!/root:*/g' -i /etc/shadow",
|
|
|
|
),
|
|
|
|
]
|
2021-08-20 07:22:36 +03:00
|
|
|
steps += self.install_newer_compiler()
|
2020-02-12 21:55:44 +03:00
|
|
|
steps += self.install_git()
|
2020-05-03 21:21:58 +03:00
|
|
|
steps += self.install_curl()
|
2021-12-06 19:52:19 +03:00
|
|
|
|
|
|
|
if self.uses_apt():
|
|
|
|
if self.container:
|
|
|
|
steps += [
|
2021-12-06 20:40:51 +03:00
|
|
|
RunStep("Update APT", f"{sudo}apt update"),
|
2021-12-06 19:52:19 +03:00
|
|
|
]
|
|
|
|
|
2021-09-27 05:30:50 +03:00
|
|
|
steps += self.install_openssh_server()
|
2022-04-13 06:11:18 +03:00
|
|
|
steps += self.checkout()
|
2020-10-10 22:00:18 +03:00
|
|
|
steps += self.install_rust(cache="mac" not in self.name)
|
2020-02-12 21:55:44 +03:00
|
|
|
steps += self.install_system_deps()
|
|
|
|
return steps
|
|
|
|
|
|
|
|
def pull_request(self):
|
|
|
|
steps = self.prep_environment()
|
|
|
|
steps += self.build_all_release()
|
|
|
|
steps += self.test_all_release()
|
|
|
|
steps += self.package()
|
|
|
|
steps += self.upload_artifact()
|
2022-02-15 18:58:34 +03:00
|
|
|
|
2021-12-08 20:14:08 +03:00
|
|
|
return (
|
|
|
|
Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
2022-02-15 18:58:34 +03:00
|
|
|
env=self.env,
|
2021-12-08 20:14:08 +03:00
|
|
|
),
|
|
|
|
None,
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
2022-04-13 06:11:18 +03:00
|
|
|
def checkout(self, submodules=True):
|
|
|
|
steps = []
|
|
|
|
if self.container:
|
|
|
|
steps += [
|
|
|
|
RunStep(
|
|
|
|
"Workaround git permissions issue",
|
2022-04-26 07:11:00 +03:00
|
|
|
"git config --global --add safe.directory /__w/wezterm/wezterm",
|
2022-04-13 06:11:18 +03:00
|
|
|
)
|
|
|
|
]
|
2023-09-11 06:50:45 +03:00
|
|
|
steps += [CheckoutStep(submodules=submodules, container=self.container)]
|
2022-04-13 06:11:18 +03:00
|
|
|
return steps
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
def continuous(self):
|
2020-10-10 22:00:18 +03:00
|
|
|
steps = self.prep_environment()
|
2020-02-12 21:55:44 +03:00
|
|
|
steps += self.build_all_release()
|
|
|
|
steps += self.test_all_release()
|
2021-11-22 21:27:14 +03:00
|
|
|
steps += self.package(trusted=True)
|
2021-12-08 20:14:08 +03:00
|
|
|
steps += self.upload_artifact_nightly()
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
self.env["BUILD_REASON"] = "Schedule"
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-12-08 21:19:00 +03:00
|
|
|
uploader = Job(
|
|
|
|
runs_on="ubuntu-latest",
|
2022-04-13 06:11:18 +03:00
|
|
|
steps=self.checkout(submodules=False) + self.upload_asset_nightly(),
|
2021-12-08 21:19:00 +03:00
|
|
|
)
|
2021-12-08 20:14:08 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
2022-02-15 18:58:34 +03:00
|
|
|
env=self.env,
|
2021-12-08 20:14:08 +03:00
|
|
|
),
|
|
|
|
uploader,
|
2020-11-17 04:28:37 +03:00
|
|
|
)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def tag(self):
|
|
|
|
steps = self.prep_environment()
|
|
|
|
steps += self.build_all_release()
|
|
|
|
steps += self.test_all_release()
|
2021-11-22 21:27:14 +03:00
|
|
|
steps += self.package(trusted=True)
|
2021-12-09 05:57:25 +03:00
|
|
|
steps += self.upload_artifact()
|
2020-06-07 22:48:41 +03:00
|
|
|
steps += self.update_homebrew_tap()
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-12-09 05:57:25 +03:00
|
|
|
uploader = Job(
|
|
|
|
runs_on="ubuntu-latest",
|
2022-08-07 20:52:16 +03:00
|
|
|
steps=self.checkout(submodules=False)
|
|
|
|
+ self.upload_asset_tag()
|
2023-03-26 08:16:22 +03:00
|
|
|
+ self.create_winget_pr()
|
|
|
|
+ self.create_flathub_pr(),
|
2021-12-09 05:57:25 +03:00
|
|
|
)
|
|
|
|
|
2021-12-08 20:14:08 +03:00
|
|
|
return (
|
|
|
|
Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
2022-02-15 18:58:34 +03:00
|
|
|
env=self.env,
|
2021-12-08 20:14:08 +03:00
|
|
|
),
|
2021-12-09 05:57:25 +03:00
|
|
|
uploader,
|
2020-11-17 04:28:37 +03:00
|
|
|
)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
TARGETS = [
|
2023-02-12 20:31:06 +03:00
|
|
|
Target(container="ubuntu:20.04", continuous_only=True, app_image=True),
|
2022-04-26 05:23:24 +03:00
|
|
|
Target(container="ubuntu:22.04", continuous_only=True),
|
2020-05-03 21:21:58 +03:00
|
|
|
# debian 8's wayland libraries are too old for wayland-client
|
|
|
|
# Target(container="debian:8.11", continuous_only=True, bootstrap_git=True),
|
2022-07-05 01:44:44 +03:00
|
|
|
# harfbuzz's C++ is too new for debian 9's toolchain
|
|
|
|
# Target(container="debian:9.12", continuous_only=True, bootstrap_git=True),
|
2020-05-03 21:21:58 +03:00
|
|
|
Target(container="debian:10.3", continuous_only=True),
|
2021-08-20 19:31:17 +03:00
|
|
|
Target(container="debian:11", continuous_only=True),
|
2023-07-12 22:02:47 +03:00
|
|
|
Target(container="debian:12", continuous_only=True),
|
2022-02-01 22:07:51 +03:00
|
|
|
Target(name="centos8", container="quay.io/centos/centos:stream8"),
|
2022-02-02 00:18:57 +03:00
|
|
|
Target(name="centos9", container="quay.io/centos/centos:stream9"),
|
2021-08-18 07:06:12 +03:00
|
|
|
Target(name="macos", os="macos-11"),
|
2021-09-26 03:56:49 +03:00
|
|
|
# https://fedoraproject.org/wiki/End_of_life?rd=LifeCycle/EOL
|
2022-11-20 22:42:22 +03:00
|
|
|
Target(container="fedora:37"),
|
2023-04-20 07:51:17 +03:00
|
|
|
Target(container="fedora:38"),
|
2023-11-25 06:20:04 +03:00
|
|
|
Target(container="fedora:39"),
|
2023-05-28 00:10:07 +03:00
|
|
|
# Target(container="alpine:3.15"),
|
2021-11-23 16:57:48 +03:00
|
|
|
Target(name="windows", os="windows-latest", rust_target="x86_64-pc-windows-msvc"),
|
2020-02-12 21:55:44 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
def generate_actions(namer, jobber, trigger, is_continuous, is_tag=False):
|
2020-02-12 21:55:44 +03:00
|
|
|
for t in TARGETS:
|
2022-06-25 21:40:47 +03:00
|
|
|
# Clone the definition, as some Target methods called
|
|
|
|
# in the body below have side effects that we don't
|
|
|
|
# want to bleed across into different schedule types
|
|
|
|
t = deepcopy(t)
|
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
t.is_tag = is_tag
|
2020-06-07 22:20:56 +03:00
|
|
|
# if t.continuous_only and not is_continuous:
|
2020-05-03 21:21:58 +03:00
|
|
|
# continue
|
2020-02-12 21:55:44 +03:00
|
|
|
name = namer(t).replace(":", "")
|
|
|
|
print(name)
|
2021-12-08 20:14:08 +03:00
|
|
|
job, uploader = jobber(t)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
file_name = f".github/workflows/gen_{name}.yml"
|
|
|
|
if job.container:
|
2023-02-17 22:13:02 +03:00
|
|
|
if t.app_image:
|
|
|
|
container = f"container:\n image: {yv(job.container)}\n options: --privileged"
|
|
|
|
else:
|
|
|
|
container = f"container: {yv(job.container)}"
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
else:
|
|
|
|
container = ""
|
|
|
|
|
2023-03-16 07:34:33 +03:00
|
|
|
trigger_paths = [file_name]
|
2023-03-16 07:31:46 +03:00
|
|
|
trigger_paths += TRIGGER_PATHS
|
|
|
|
if "win" in name:
|
|
|
|
trigger_paths += TRIGGER_PATHS_WIN
|
|
|
|
elif "macos" in name:
|
|
|
|
trigger_paths += TRIGGER_PATHS_MAC
|
|
|
|
else:
|
|
|
|
trigger_paths += TRIGGER_PATHS_UNIX
|
|
|
|
if t.app_image:
|
|
|
|
trigger_paths += TRIGGER_PATHS_APPIMAGE
|
|
|
|
|
|
|
|
trigger_paths = "- " + "\n - ".join(yv(p) for p in sorted(trigger_paths))
|
2023-03-16 10:05:00 +03:00
|
|
|
trigger_with_paths = trigger.replace("@PATHS@", trigger_paths)
|
2023-03-16 07:31:46 +03:00
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
with open(file_name, "w") as f:
|
|
|
|
f.write(
|
2021-09-21 16:24:52 +03:00
|
|
|
f"""name: {name}
|
2023-03-16 10:05:00 +03:00
|
|
|
{trigger_with_paths}
|
2020-02-12 21:55:44 +03:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: {yv(job.runs_on)}
|
|
|
|
{container}
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2022-02-15 18:58:34 +03:00
|
|
|
t.render_env(f)
|
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
job.render(f, 3)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
2021-12-09 05:57:25 +03:00
|
|
|
# We upload using a native runner as github API access
|
|
|
|
# inside a container is really unreliable and can result
|
|
|
|
# in broken releases that can't automatically be repaired
|
|
|
|
# <https://github.com/cli/cli/issues/4863>
|
2021-12-08 20:14:08 +03:00
|
|
|
if uploader:
|
|
|
|
f.write(
|
|
|
|
"""
|
|
|
|
upload:
|
|
|
|
runs-on: ubuntu-latest
|
2021-12-08 20:16:58 +03:00
|
|
|
needs: build
|
2021-12-08 20:14:08 +03:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
uploader.render(f, 3)
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
# Sanity check the yaml, if pyyaml is available
|
|
|
|
try:
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
with open(file_name) as f:
|
|
|
|
yaml.safe_load(f)
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def generate_pr_actions():
|
|
|
|
generate_actions(
|
2020-02-13 00:36:31 +03:00
|
|
|
lambda t: f"{t.name}",
|
2020-02-12 21:55:44 +03:00
|
|
|
lambda t: t.pull_request(),
|
|
|
|
trigger="""
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
2021-09-21 16:24:52 +03:00
|
|
|
- main
|
2023-03-16 07:31:46 +03:00
|
|
|
paths:
|
|
|
|
@PATHS@
|
2020-02-12 21:55:44 +03:00
|
|
|
""",
|
2020-05-03 21:21:58 +03:00
|
|
|
is_continuous=False,
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def continuous_actions():
|
|
|
|
generate_actions(
|
|
|
|
lambda t: f"{t.name}_continuous",
|
|
|
|
lambda t: t.continuous(),
|
|
|
|
trigger="""
|
|
|
|
on:
|
|
|
|
schedule:
|
2021-01-30 23:34:54 +03:00
|
|
|
- cron: "10 3 * * *"
|
|
|
|
push:
|
|
|
|
branches:
|
2021-09-21 16:24:52 +03:00
|
|
|
- main
|
2023-03-16 07:31:46 +03:00
|
|
|
paths:
|
|
|
|
@PATHS@
|
2020-02-12 21:55:44 +03:00
|
|
|
""",
|
2020-05-03 21:21:58 +03:00
|
|
|
is_continuous=True,
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def tag_actions():
|
|
|
|
generate_actions(
|
|
|
|
lambda t: f"{t.name}_tag",
|
|
|
|
lambda t: t.tag(),
|
|
|
|
trigger="""
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- "20*"
|
|
|
|
""",
|
2020-05-03 21:21:58 +03:00
|
|
|
is_continuous=True,
|
2022-02-15 18:58:34 +03:00
|
|
|
is_tag=True,
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-03-20 08:45:50 +03:00
|
|
|
def remove_gen_actions():
|
|
|
|
for name in glob.glob(".github/workflows/gen_*.yml"):
|
|
|
|
os.remove(name)
|
|
|
|
|
|
|
|
|
|
|
|
remove_gen_actions()
|
2020-02-12 21:55:44 +03:00
|
|
|
generate_pr_actions()
|
|
|
|
continuous_actions()
|
|
|
|
tag_actions()
|