diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-06-09 00:50:40 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-06-09 20:33:24 -0700 |
commit | ce71d0e9abe347147f50fba4bf11eac97b2a90ef (patch) | |
tree | 9d5dadf0a4b8232963e642fb4c95fb531f2255b1 /releng | |
parent | 9aeb314e6a8276d3bd29f968c2baa44d5d19ca37 (diff) |
releng: automatically figure out if we should tag latest for docker
For example, when releasing from release-2.90, if `main` has a 2.91 tag
ancestor, we know that 2.91 was released, so we should *not* tag latest.
Change-Id: Ia56b17a2ee03bbec74b7c271c742858c690d450d
Diffstat (limited to 'releng')
-rw-r--r-- | releng/__init__.py | 2 | ||||
-rw-r--r-- | releng/create_release.xsh | 15 | ||||
-rw-r--r-- | releng/environment.py | 2 | ||||
-rw-r--r-- | releng/gitutils.xsh | 37 |
4 files changed, 41 insertions, 15 deletions
diff --git a/releng/__init__.py b/releng/__init__.py index fc23c52f3..59d1709b9 100644 --- a/releng/__init__.py +++ b/releng/__init__.py @@ -11,6 +11,7 @@ from . import version from . import cli from . import docker from . import docker_assemble +from . import gitutils rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) @@ -35,3 +36,4 @@ def reload(): importlib.reload(cli) importlib.reload(docker) importlib.reload(docker_assemble) + importlib.reload(gitutils) diff --git a/releng/create_release.xsh b/releng/create_release.xsh index 6f4df2142..373c079bc 100644 --- a/releng/create_release.xsh +++ b/releng/create_release.xsh @@ -11,6 +11,7 @@ from .environment import RelengEnvironment from . import keys from . import docker from .version import VERSION, RELEASE_NAME, MAJOR +from .gitutils import verify_are_on_tag, git_preconditions $RAISE_SUBPROC_ERROR = True $XONSH_SHOW_TRACEBACK = True @@ -38,15 +39,6 @@ def setup_creds(env: RelengEnvironment): $AWS_ENDPOINT_URL = environment.S3_ENDPOINT -def git_preconditions(): - # verify there is nothing in index ready to stage - proc = !(git diff-index --quiet --cached HEAD --) - assert proc.rtn == 0 - # verify there is nothing *stageable* and tracked - proc = !(git diff-files --quiet) - assert proc.rtn == 0 - - def official_release_commit_tag(force_tag=False): print('[+] Setting officialRelease in flake.nix and tagging') prev_branch = $(git symbolic-ref --short HEAD).strip() @@ -240,11 +232,6 @@ def prepare_release_notes(): git commit -m @(commit_msg) -def verify_are_on_tag(): - current_tag = $(git describe --tag).strip() - assert current_tag == VERSION - - def upload_artifacts(env: RelengEnvironment, noconfirm=False, no_check_git=False, force_push_tag=False): if not no_check_git: verify_are_on_tag() diff --git a/releng/environment.py b/releng/environment.py index 3d65b2799..b2278491a 100644 --- a/releng/environment.py +++ b/releng/environment.py @@ -64,7 +64,7 @@ STAGING = RelengEnvironment( releases_bucket='s3://staging-releases', git_repo='ssh://git@git.lix.systems/lix-project/lix-releng-staging', docker_targets=[ - # FIXME: how do we make sure that latest gets the latest of the *most recent* branch? + # latest will be auto tagged if appropriate DockerTarget('git.lix.systems/lix-project/lix-releng-staging', tags=['{version}', '{major}']), DockerTarget('ghcr.io/lix-project/lix-releng-staging', diff --git a/releng/gitutils.xsh b/releng/gitutils.xsh new file mode 100644 index 000000000..3352a6b21 --- /dev/null +++ b/releng/gitutils.xsh @@ -0,0 +1,37 @@ +import subprocess +import json + + +def version_compare(v1: str, v2: str): + return json.loads($(nix-instantiate --eval --json --argstr v1 @(v1) --argstr v2 @(v2) --expr '{v1, v2}: builtins.compareVersions v1 v2')) + + +def latest_tag_on_branch(branch: str) -> str: + return $(git describe --abbrev=0 @(branch) e>/dev/null).strip() + + +def is_maintenance_branch(branch: str) -> bool: + try: + main_tag = latest_tag_on_branch('main') + current_tag = latest_tag_on_branch(branch) + + return version_compare(current_tag, main_tag) < 0 + except subprocess.CalledProcessError: + # This is the case before Lix releases 2.90, since main *has* no + # release tag on it. + # FIXME: delete this case after 2.91 + return False + + +def verify_are_on_tag(): + current_tag = $(git describe --tag).strip() + assert current_tag == VERSION + + +def git_preconditions(): + # verify there is nothing in index ready to stage + proc = !(git diff-index --quiet --cached HEAD --) + assert proc.rtn == 0 + # verify there is nothing *stageable* and tracked + proc = !(git diff-files --quiet) + assert proc.rtn == 0 |