Skip to content

Commit

Permalink
Update the create-release-branches task to create the release branch …
Browse files Browse the repository at this point in the history
…in the agent on a specific commit (#33603)
  • Loading branch information
FlorentClarret authored Jan 31, 2025
1 parent c2e3683 commit 04e2e0a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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/<new rc version>' already exists locally or upstream.
Expand All @@ -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")

Expand Down

0 comments on commit 04e2e0a

Please sign in to comment.