diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-06-09 01:26:21 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-06-09 20:33:24 -0700 |
commit | 82dc712d9312f06e653213d030b6db21529a422f (patch) | |
tree | 495de311a06e7710ad7ed10f0a1dfeec1ba3d2e2 /releng/environment.py | |
parent | ce71d0e9abe347147f50fba4bf11eac97b2a90ef (diff) |
releng: add prod environment, ready for release
I am *reasonably* confident that this releng infrastructure can actually
build a Lix 2.90 and release it successfully. Let's make it possible to
do, and add some cute colours to the confirmation message.
Change-Id: I85e498b6fb49ffc5e75c0a72c5e45fb1f69030d3
Diffstat (limited to 'releng/environment.py')
-rw-r--r-- | releng/environment.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/releng/environment.py b/releng/environment.py index b2278491a..ca8194fe5 100644 --- a/releng/environment.py +++ b/releng/environment.py @@ -1,4 +1,8 @@ +from typing import Callable import urllib.parse +import re +import functools +import subprocess import dataclasses S3_HOST = 's3.lix.systems' @@ -41,6 +45,7 @@ class DockerTarget: @dataclasses.dataclass class RelengEnvironment: name: str + colour: Callable[[str], str] cache_store_overlay: dict[str, str] cache_bucket: str @@ -56,8 +61,19 @@ class RelengEnvironment: return self.cache_bucket + "?" + urllib.parse.urlencode(qs) +SGR = '\x1b[' +RED = '31;1m' +GREEN = '32;1m' +RESET = '0m' + + +def sgr(colour: str, text: str) -> str: + return f'{SGR}{colour}{text}{SGR}{RESET}' + + STAGING = RelengEnvironment( name='staging', + colour=functools.partial(sgr, GREEN), docs_bucket='s3://staging-docs', cache_bucket='s3://staging-cache', cache_store_overlay={'secret-key': 'staging.key'}, @@ -72,8 +88,42 @@ STAGING = RelengEnvironment( ], ) +GERRIT_REMOTE_RE = re.compile(r'^ssh://(\w+@)?gerrit.lix.systems:2022/lix$') + + +def guess_gerrit_remote(): + """ + Deals with people having unknown gerrit username. + """ + out = [ + x.split()[1] for x in subprocess.check_output( + ['git', 'remote', '-v']).decode().splitlines() + ] + return next(x for x in out if GERRIT_REMOTE_RE.match(x)) + + +PROD = RelengEnvironment( + name='production', + colour=functools.partial(sgr, RED), + docs_bucket='s3://docs', + cache_bucket='s3://cache', + # FIXME: we should decrypt this with age into a tempdir in the future, but + # the issue is how to deal with the recipients file. For now, we should + # just delete it after doing a release. + cache_store_overlay={'secret-key': 'prod.key'}, + releases_bucket='s3://releases', + git_repo=guess_gerrit_remote(), + docker_targets=[ + # latest will be auto tagged if appropriate + DockerTarget('git.lix.systems/lix-project/lix', + tags=['{version}', '{major}']), + DockerTarget('ghcr.io/lix-project/lix', tags=['{version}', '{major}']), + ], +) + ENVIRONMENTS = { 'staging': STAGING, + 'production': PROD, } |