diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-07 20:51:25 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-08-07 21:46:44 -0700 |
commit | 7246c2d104f12877de7d5b20033346eff88048e6 (patch) | |
tree | 997942c8b0c7b3ad3829a060caab3dc4a647d030 | |
parent | 83247b1c38899a48a7ef683a1d1c14b21cb917d2 (diff) |
releng: fix the git push
This was broken because gerrit requires that the revision actually
is known before it is pushed as a tag.
Also, arguably this fixes the original problem mentioned in
https://git.lix.systems/lix-project/lix/issues/439
Change-Id: I0373ac01584440f18d32b8da5699bb359cc2c89a
-rw-r--r-- | releng/create_release.xsh | 26 | ||||
-rw-r--r-- | releng/environment.py | 3 |
2 files changed, 27 insertions, 2 deletions
diff --git a/releng/create_release.xsh b/releng/create_release.xsh index 62114350b..d8d6e8a83 100644 --- a/releng/create_release.xsh +++ b/releng/create_release.xsh @@ -2,6 +2,7 @@ import json import subprocess import itertools import textwrap +import logging from pathlib import Path import tempfile import hashlib @@ -15,6 +16,8 @@ from .version import VERSION, RELEASE_NAME, MAJOR, OFFICIAL_RELEASE from .gitutils import verify_are_on_tag, git_preconditions from . import release_notes +log = logging.getLogger(__name__) + $RAISE_SUBPROC_ERROR = True $XONSH_SHOW_TRACEBACK = True @@ -55,6 +58,9 @@ def official_release_commit_tag(force_tag=False): git commit -m @(message) git tag @(['-f'] if force_tag else []) -a -m @(message) @(VERSION) + with open('releng/prev-git-branch.txt', 'w') as fh: + fh.write(prev_branch) + return prev_branch @@ -235,8 +241,24 @@ def upload_artifacts(env: RelengEnvironment, noconfirm=False, no_check_git=False print('[+] Upload manual') upload_manual(env) - print('[+] git push tag') - git push @(['-f'] if force_push_tag else []) @(env.git_repo) f'{VERSION}:refs/tags/{VERSION}' + prev_branch = None + try: + with open('releng/prev-git-branch.txt', 'r') as fh: + prev_branch = fh.read().strip() + except FileNotFoundError: + log.warn('Cannot find previous git branch file, skipping pushing git objects') + + if prev_branch: + print('[+] git push to the repo') + # We have to push the ref to gerrit for review at least such that the + # commit is known, before we can push it as a tag. + if env.git_repo_is_gerrit: + git push @(env.git_repo) f'{prev_branch}:refs/for/{prev_branch}' + else: + git push @(env.git_repo) f'{prev_branch}:{prev_branch}' + + print('[+] git push tag') + git push @(['-f'] if force_push_tag else []) @(env.git_repo) f'{VERSION}:refs/tags/{VERSION}' def do_tag_merge(force_tag=False, no_check_git=False): diff --git a/releng/environment.py b/releng/environment.py index ca8194fe5..2b6554ede 100644 --- a/releng/environment.py +++ b/releng/environment.py @@ -52,6 +52,7 @@ class RelengEnvironment: releases_bucket: str docs_bucket: str git_repo: str + git_repo_is_gerrit: bool docker_targets: list[DockerTarget] @@ -79,6 +80,7 @@ STAGING = RelengEnvironment( cache_store_overlay={'secret-key': 'staging.key'}, releases_bucket='s3://staging-releases', git_repo='ssh://git@git.lix.systems/lix-project/lix-releng-staging', + git_repo_is_gerrit=False, docker_targets=[ # latest will be auto tagged if appropriate DockerTarget('git.lix.systems/lix-project/lix-releng-staging', @@ -113,6 +115,7 @@ PROD = RelengEnvironment( cache_store_overlay={'secret-key': 'prod.key'}, releases_bucket='s3://releases', git_repo=guess_gerrit_remote(), + git_repo_is_gerrit=True, docker_targets=[ # latest will be auto tagged if appropriate DockerTarget('git.lix.systems/lix-project/lix', |