2020-02-12 21:55:44 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
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
|
2020-02-12 21:55:44 +03:00
|
|
|
return '"' + v + '"'
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
|
|
|
|
class Step(object):
|
2021-09-21 16:24:52 +03:00
|
|
|
def render(self, f, env, depth=0):
|
2020-02-12 21:55:44 +03:00
|
|
|
raise NotImplementedError(repr(self))
|
|
|
|
|
|
|
|
|
|
|
|
class RunStep(Step):
|
|
|
|
def __init__(self, name, run, shell="bash"):
|
|
|
|
self.name = name
|
|
|
|
self.run = run
|
|
|
|
self.shell = shell
|
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
def render(self, f, env, depth=0):
|
|
|
|
indent = " " * depth
|
|
|
|
f.write(f"{indent}- name: {yv(self.name)}\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
|
|
|
|
|
|
|
|
if env:
|
|
|
|
for k, v in env.items():
|
2021-01-30 23:34:54 +03:00
|
|
|
if self.shell == "bash":
|
2020-02-12 21:55:44 +03:00
|
|
|
run = f"export {k}={v}\n{run}\n"
|
|
|
|
|
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
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
def render(self, f, env, depth=0):
|
|
|
|
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__(
|
2021-05-31 09:07:29 +03:00
|
|
|
name, action="actions/cache@v2.1.6", params={"path": path, "key": key}
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class CheckoutStep(ActionStep):
|
|
|
|
def __init__(self, name="checkout repo"):
|
2020-06-07 22:20:56 +03:00
|
|
|
super().__init__(
|
|
|
|
name, action="actions/checkout@v2", params={"submodules": "recursive"}
|
|
|
|
)
|
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):
|
2020-02-12 21:55:44 +03:00
|
|
|
for s in self.steps:
|
2021-09-21 16:24:52 +03:00
|
|
|
s.render(f, self.env, 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,
|
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
|
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
|
|
|
|
|
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"
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
if self.needs_sudo():
|
|
|
|
installer = f"sudo -n {installer}"
|
|
|
|
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):
|
2020-05-04 02:16:52 +03:00
|
|
|
if self.uses_yum() or (self.uses_apt() and self.container):
|
|
|
|
return self.install_system_package("curl")
|
|
|
|
return []
|
2020-05-03 21:21:58 +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"
|
|
|
|
|
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:
|
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
|
|
|
|
2020-10-10 19:25:11 +03:00
|
|
|
def install_rust(self, cache=True):
|
|
|
|
salt = "2"
|
2020-10-31 08:09:58 +03:00
|
|
|
key_prefix = f"{self.name}-{self.rust_target}-{salt}-${{{{ runner.os }}}}-${{{{ hashFiles('**/Cargo.lock') }}}}"
|
2020-02-12 21:55:44 +03:00
|
|
|
params = {
|
|
|
|
"profile": "minimal",
|
|
|
|
"toolchain": "stable",
|
|
|
|
"override": True,
|
|
|
|
"components": "rustfmt",
|
|
|
|
}
|
|
|
|
if self.rust_target:
|
|
|
|
params["target"] = self.rust_target
|
2020-10-10 19:25:11 +03:00
|
|
|
steps = [
|
2020-02-12 21:55:44 +03:00
|
|
|
ActionStep(
|
2020-11-17 04:28:37 +03:00
|
|
|
name="Install Rust",
|
2020-11-17 23:03:24 +03:00
|
|
|
action="actions-rs/toolchain@v1",
|
2020-11-17 04:28:37 +03:00
|
|
|
params=params,
|
|
|
|
env={"ACTIONS_ALLOW_UNSECURE_COMMANDS": "true"},
|
2020-02-12 21:55:44 +03:00
|
|
|
),
|
|
|
|
]
|
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:
|
2021-01-13 08:12:54 +03:00
|
|
|
cache_paths = ["~/.cargo/registry", "~/.cargo/git", "target"]
|
2020-10-10 19:25:11 +03:00
|
|
|
steps += [
|
|
|
|
CacheStep(
|
|
|
|
name="Cache cargo",
|
2021-01-13 08:12:54 +03:00
|
|
|
path="\n".join(cache_paths),
|
2020-10-10 19:25:11 +03:00
|
|
|
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 ""
|
2021-08-20 05:22:22 +03:00
|
|
|
return [
|
2021-09-21 16:24:52 +03:00
|
|
|
RunStep(name="Install System Deps", run=f"{sudo}env PATH=$PATH ./get-deps")
|
2021-08-20 05:22:22 +03:00
|
|
|
]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def check_formatting(self):
|
|
|
|
return [RunStep(name="Check formatting", run="cargo fmt --all -- --check")]
|
|
|
|
|
|
|
|
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):
|
2021-01-13 08:12:54 +03:00
|
|
|
if "macos" in self.name:
|
2021-08-20 05:22:22 +03:00
|
|
|
return [
|
|
|
|
RunStep(
|
|
|
|
name="Test (Release mode)",
|
|
|
|
run="cargo test --target x86_64-apple-darwin --all --release",
|
|
|
|
)
|
|
|
|
]
|
|
|
|
if self.name == "centos7":
|
|
|
|
enable = "source /opt/rh/devtoolset-9/enable && "
|
|
|
|
else:
|
|
|
|
enable = ""
|
|
|
|
return [
|
|
|
|
RunStep(
|
|
|
|
name="Test (Release mode)", run=enable + "cargo test --all --release"
|
|
|
|
)
|
|
|
|
]
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
def package(self):
|
2020-05-03 21:21:58 +03:00
|
|
|
steps = [RunStep("Package", "bash ci/deploy.sh")]
|
|
|
|
if self.app_image:
|
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):
|
|
|
|
run = "mkdir pkg_\n"
|
|
|
|
if self.uses_yum():
|
2020-05-03 21:21:58 +03:00
|
|
|
run += "mv ~/rpmbuild/RPMS/*/*.rpm pkg_\n"
|
2020-05-25 10:12:36 +03:00
|
|
|
if "win" in self.name:
|
|
|
|
run += "mv *.zip *.exe pkg_\n"
|
|
|
|
if "mac" in self.name:
|
2020-05-03 21:21:58 +03:00
|
|
|
run += "mv *.zip pkg_\n"
|
|
|
|
if ("ubuntu" in self.name) or ("debian" in self.name):
|
|
|
|
run += "mv *.deb *.xz pkg_\n"
|
|
|
|
if self.app_image:
|
2020-05-05 09:38:50 +03:00
|
|
|
run += "mv *.AppImage *.zsync pkg_\n"
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
return [
|
|
|
|
RunStep("Move Package for artifact upload", run),
|
|
|
|
ActionStep(
|
|
|
|
"Upload artifact",
|
|
|
|
action="actions/upload-artifact@master",
|
|
|
|
params={"name": self.name, "path": "pkg_"},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2020-05-03 21:21:58 +03:00
|
|
|
def asset_patterns(self):
|
|
|
|
patterns = []
|
|
|
|
if self.uses_yum():
|
|
|
|
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):
|
|
|
|
patterns += ["wezterm-*.deb", "wezterm-*.xz", "wezterm-*.tar.gz"]
|
|
|
|
|
|
|
|
if self.app_image:
|
|
|
|
patterns.append("*.AppImage")
|
2020-05-05 09:38:50 +03:00
|
|
|
patterns.append("*.zsync")
|
2020-05-03 21:21:58 +03:00
|
|
|
return patterns
|
|
|
|
|
2020-02-12 21:55:44 +03:00
|
|
|
def upload_asset_nightly(self):
|
|
|
|
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
|
|
|
)
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
patterns = self.asset_patterns()
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
return steps + [
|
|
|
|
ActionStep(
|
|
|
|
"Upload to Nightly Release",
|
2020-02-15 02:53:32 +03:00
|
|
|
action="wez/upload-release-assets@releases/v1",
|
2021-09-21 16:17:23 +03:00
|
|
|
condition="github.event.repository.fork == false",
|
2020-02-12 21:55:44 +03:00
|
|
|
params={
|
|
|
|
"files": ";".join(patterns),
|
2020-02-13 00:32:05 +03:00
|
|
|
"release-tag": "nightly",
|
2020-02-12 21:55:44 +03:00
|
|
|
"repo-token": "${{ secrets.GITHUB_TOKEN }}",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
def upload_asset_tag(self):
|
|
|
|
steps = []
|
|
|
|
|
|
|
|
if self.uses_yum():
|
|
|
|
steps.append(RunStep("Move RPM", "mv ~/rpmbuild/RPMS/*/*.rpm ."))
|
2020-05-03 21:21:58 +03:00
|
|
|
|
|
|
|
patterns = self.asset_patterns()
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
return steps + [
|
|
|
|
ActionStep(
|
|
|
|
"Upload to Tagged Release",
|
|
|
|
action="softprops/action-gh-release@v1",
|
2021-09-21 16:17:23 +03:00
|
|
|
condition="github.event.repository.fork == false",
|
2020-10-31 08:09:58 +03:00
|
|
|
params={"files": "\n".join(patterns), "prerelease": True},
|
2020-11-17 04:28:37 +03:00
|
|
|
env={
|
|
|
|
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
|
|
|
|
},
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
]
|
|
|
|
|
2020-06-07 22:48:41 +03:00
|
|
|
def update_homebrew_tap(self):
|
|
|
|
steps = []
|
|
|
|
if "macos" in self.name:
|
|
|
|
steps += [
|
|
|
|
ActionStep(
|
|
|
|
"Checkout homebrew tap",
|
|
|
|
action="actions/checkout@v2",
|
|
|
|
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",
|
|
|
|
action="actions/checkout@v2",
|
|
|
|
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):
|
|
|
|
env = {}
|
|
|
|
if "macos" in self.name:
|
|
|
|
env["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
|
|
|
|
return env
|
|
|
|
|
2020-10-10 19:25:11 +03:00
|
|
|
def prep_environment(self, cache=True):
|
2020-02-12 21:55:44 +03:00
|
|
|
steps = []
|
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",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
sudo = "sudo -n " if self.needs_sudo() else ""
|
2020-12-11 06:52:36 +03:00
|
|
|
steps += [
|
|
|
|
RunStep("Update APT", f"{sudo}apt update"),
|
|
|
|
]
|
2020-05-03 21:21:58 +03:00
|
|
|
if self.container:
|
2020-05-04 18:21:30 +03:00
|
|
|
if self.container == "centos:8":
|
|
|
|
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
|
|
|
),
|
|
|
|
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
|
|
|
),
|
2020-05-04 18:21:30 +03:00
|
|
|
]
|
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()
|
|
|
|
steps += [
|
|
|
|
CheckoutStep(),
|
|
|
|
# We need tags in order to use git describe for build/packaging
|
|
|
|
RunStep(
|
2020-06-07 22:20:56 +03:00
|
|
|
"Fetch tags", "git fetch --depth=1 origin +refs/tags/*:refs/tags/*"
|
2020-05-03 21:21:58 +03:00
|
|
|
),
|
2020-06-07 22:20:56 +03:00
|
|
|
RunStep("Fetch tag/branch history", "git fetch --prune --unshallow"),
|
2020-05-03 21:21:58 +03:00
|
|
|
]
|
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.check_formatting()
|
|
|
|
steps += self.build_all_release()
|
|
|
|
steps += self.test_all_release()
|
|
|
|
steps += self.package()
|
|
|
|
steps += self.upload_artifact()
|
|
|
|
return Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
|
|
|
env=self.global_env(),
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
steps += self.package()
|
|
|
|
steps += self.upload_asset_nightly()
|
|
|
|
|
|
|
|
env = self.global_env()
|
|
|
|
env["BUILD_REASON"] = "Schedule"
|
|
|
|
|
2020-11-17 04:28:37 +03:00
|
|
|
return Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
|
|
|
env=env,
|
|
|
|
)
|
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()
|
|
|
|
steps += self.package()
|
|
|
|
steps += self.upload_asset_tag()
|
2020-06-07 22:48:41 +03:00
|
|
|
steps += self.update_homebrew_tap()
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
env = self.global_env()
|
2020-11-17 04:28:37 +03:00
|
|
|
return Job(
|
|
|
|
runs_on=self.os,
|
|
|
|
container=self.container,
|
|
|
|
steps=steps,
|
|
|
|
env=env,
|
|
|
|
)
|
2020-02-12 21:55:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
TARGETS = [
|
2021-09-23 06:47:08 +03:00
|
|
|
Target(name="ubuntu:18", os="ubuntu-18.04", app_image=True),
|
2020-05-04 02:16:52 +03:00
|
|
|
Target(container="ubuntu:20.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),
|
|
|
|
Target(container="debian:9.12", continuous_only=True, bootstrap_git=True),
|
|
|
|
Target(container="debian:10.3", continuous_only=True),
|
2021-08-20 19:31:17 +03:00
|
|
|
Target(container="debian:11", continuous_only=True),
|
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
|
2020-11-29 21:26:11 +03:00
|
|
|
Target(container="fedora:33"),
|
2021-05-02 19:29:40 +03:00
|
|
|
Target(container="fedora:34"),
|
2020-02-12 21:55:44 +03:00
|
|
|
Target(container="centos:7", bootstrap_git=True),
|
2020-05-04 18:21:30 +03:00
|
|
|
Target(container="centos:8"),
|
2020-02-12 21:55:44 +03:00
|
|
|
Target(name="windows", os="vs2017-win2016", rust_target="x86_64-pc-windows-msvc"),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-05-03 21:21:58 +03:00
|
|
|
def generate_actions(namer, jobber, trigger, is_continuous):
|
2020-02-12 21:55:44 +03:00
|
|
|
for t in TARGETS:
|
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)
|
|
|
|
job = jobber(t)
|
|
|
|
|
|
|
|
file_name = f".github/workflows/gen_{name}.yml"
|
|
|
|
if job.container:
|
|
|
|
container = f"container: {yv(job.container)}"
|
|
|
|
else:
|
|
|
|
container = ""
|
|
|
|
|
|
|
|
with open(file_name, "w") as f:
|
|
|
|
f.write(
|
2021-09-21 16:24:52 +03:00
|
|
|
f"""name: {name}
|
2020-02-12 21:55:44 +03:00
|
|
|
{trigger}
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: {yv(job.runs_on)}
|
|
|
|
{container}
|
|
|
|
steps:
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2021-09-21 16:24:52 +03:00
|
|
|
job.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
|
2021-01-30 23:34:54 +03:00
|
|
|
paths-ignore:
|
2021-09-21 16:24:52 +03:00
|
|
|
- ".cirrus.yml"
|
|
|
|
- "docs/*"
|
|
|
|
- "ci/build-docs.sh"
|
|
|
|
- "ci/generate-docs.py"
|
|
|
|
- "ci/subst-release-info.py"
|
|
|
|
- ".github/workflows/pages.yml"
|
|
|
|
- ".github/ISSUE_TEMPLATE/*"
|
|
|
|
- "**/*.md"
|
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
|
2021-01-30 23:34:54 +03:00
|
|
|
paths-ignore:
|
2021-09-21 16:24:52 +03:00
|
|
|
- ".cirrus.yml"
|
|
|
|
- "docs/**"
|
|
|
|
- "ci/build-docs.sh"
|
|
|
|
- "ci/generate-docs.py"
|
|
|
|
- "ci/subst-release-info.py"
|
|
|
|
- ".github/workflows/pages.yml"
|
|
|
|
- ".github/ISSUE_TEMPLATE/*"
|
|
|
|
- "**/*.md"
|
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,
|
2020-02-12 21:55:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
generate_pr_actions()
|
|
|
|
continuous_actions()
|
|
|
|
tag_actions()
|