diff --git a/tasks/release.py b/tasks/release.py index 10e148f6c3ab8c..d8b75a34129666 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -667,7 +667,6 @@ def create_and_update_release_branch( """ def _main(): - ctx.run("git pull") print(color_message(f"Branching out to {release_branch}", "bold")) ctx.run(f"git checkout -b {release_branch}") @@ -687,8 +686,7 @@ def _main(): # Perform branch out in all required repositories print(color_message(f"Working repository: {repo}", "bold")) if repo == 'datadog-agent': - with agent_context(ctx, base_branch or get_default_branch(major=get_version_major(release_branch))): - _main() + _main() else: with ctx.cd(f"{base_directory}/{repo}"): # Step 1 - Create a local branch out from the default branch @@ -697,13 +695,16 @@ def _main(): or ctx.run(f"git remote show {upstream} | grep \"HEAD branch\" | sed 's/.*: //'").stdout.strip() ) ctx.run(f"git checkout {main_branch}") + ctx.run("git pull") _main() # TODO: unfreeze is the former name of this task, kept for backward compatibility. Remove in a few weeks. @task(help={'upstream': "Remote repository name (default 'origin')"}, aliases=["unfreeze"]) -def create_release_branches(ctx, base_directory="~/dd", major_version: int = 7, upstream="origin", check_state=True): +def create_release_branches( + ctx, commit, base_directory="~/dd", major_version: int = 7, upstream="origin", check_state=True +): """Create and push release branches in Agent repositories and update them. That includes: @@ -712,11 +713,12 @@ def create_release_branches(ctx, base_directory="~/dd", major_version: int = 7, - updates entries in .gitlab-ci.yml and .gitlab/notify/notify.yml which depend on local branch name Args: + commit: the commit on which the branch should be created (usually the one before the milestone bump) base_directory: Path to the directory where dd repos are cloned, defaults to ~/dd, but can be overwritten. use_worktree: If True, will go to datadog-agent-worktree instead of datadog-agent. Notes: - This requires a Github token (either in the GITHUB_TOKEN environment variable, or in the MacOS keychain), + This requires a GitHub token (either in the GITHUB_TOKEN environment variable, or in the MacOS keychain), with 'repo' permissions. This also requires that there are no local uncommitted changes, that the current branch is 'main' or the release branch, and that no branch named 'release/' already exists locally or upstream. @@ -731,7 +733,7 @@ def create_release_branches(ctx, base_directory="~/dd", major_version: int = 7, # Strings with proper branch/tag names release_branch = current.branch() - with agent_context(ctx, get_default_branch()): + with agent_context(ctx, commit=commit): # Step 0: checks ctx.run("git fetch")