Skip to content

Commit 1073a4f

Browse files
committed
Revert "Updated flow to use trigger branch as base for releasing"
This reverts commit 6e08459.
1 parent b34414e commit 1073a4f

File tree

4 files changed

+15
-75
lines changed

4 files changed

+15
-75
lines changed

Tools/scripts/ReleaseAutomation/release_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def __init__(self):
6565

6666
self.release_commit_message = f"Updated changelog and package version for Netcode in anticipation of v{self.package_version} release"
6767

68-
self.pr_branch_name = f"netcode-update-after-{self.package_version}-release-branch-creation" # Branch from which we will create PR to trigger branch with relevant changes after release branch is created
68+
self.pr_branch_name = f"netcode-update-after-{self.package_version}-release-branch-creation" # Branch from which we will create PR to default branch with relevant changes after release branch is created
6969
self.pr_commit_message = f"chore: Updated aspects of Netcode package in anticipation of v{self.package_version} release"
70-
self.pr_body = f"This PR was created in sync with branching of {self.release_branch_name}. It includes changes that should land on the branch this job was triggered from which usually is {self.default_repo_branch} (please double check if the target branch is different if this was intended) to reflect the new state of the package after the v{self.package_version} release:\n" \
70+
self.pr_body = f"This PR was created in sync with branching of {self.release_branch_name}. It includes changes that should land on the default Netcode branch ({self.default_repo_branch}) to reflect the new state of the package after the v{self.package_version} release:\n" \
7171
f"1) Updated CHANGELOG.md by adding new [Unreleased] section template at the top and cleaning the Changelog for the current release.\n" \
7272
f"2) Updated package version in package.json by incrementing the patch version to signify the current state of the package.\n" \
7373
f"3) Updated package version in ValidationExceptions.json to match the new package version.\n\n" \

Tools/scripts/Utils/createPrAfterRelease.py

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,31 @@ def createPrAfterRelease(config: ReleaseConfig):
2828
3) Update the package version in the package.json file by incrementing the patch version to signify the current state of the package.
2929
4) Update package version in the validation exceptions to match the new package version.
3030
31-
IMPORTANT: The PR is created against the trigger branch (the branch the job was triggered from),
32-
not the default branch. This ensures consistency with the validation and release branch creation.
33-
Please double check if the target branch is different and if so the if this was intended.
31+
This assumes that at the same time you already branched off for the release. Otherwise it may be confusing
3432
"""
3533

3634
try:
37-
repo = get_local_repo()
38-
trigger_branch = repo.active_branch.name
39-
40-
if not config.github_manager.is_branch_present(trigger_branch):
41-
raise Exception(f"Trigger branch '{trigger_branch}' does not exist. Exiting.")
4235
if not config.github_manager.is_branch_present(config.default_repo_branch):
43-
raise Exception(f"Default branch '{config.default_repo_branch}' does not exist. Exiting.")
44-
45-
# Check if PR branch already exists (could happen if a previous run failed partway through)
46-
if config.github_manager.is_branch_present(config.pr_branch_name):
47-
raise Exception(f"PR branch '{config.pr_branch_name}' already exists. This might indicate a previous incomplete run.")
36+
raise Exception(f"Branch '{config.default_repo_branch}' does not exist. Exiting.")
4837

4938
author = Actor(config.commiter_name, config.commiter_email)
5039
committer = Actor(config.commiter_name, config.commiter_email)
5140

41+
repo = get_local_repo()
5242
repo.git.fetch('--prune', '--prune-tags')
5343

54-
# Ensure we're on the trigger branch and have latest changes
55-
# Stash any uncommitted changes that might block operations
44+
# Check if there are uncommitted changes that would block checkout
45+
# Stash them if they exist to allow checkout to proceed
5646
has_uncommitted_changes = repo.is_dirty()
5747
if has_uncommitted_changes:
58-
print("Uncommitted changes detected. Stashing before operations...")
59-
repo.git.stash('push', '-m', 'Auto-stash before release PR creation')
48+
print("Uncommitted changes detected. Stashing before checkout...")
49+
repo.git.stash('push', '-m', 'Auto-stash before checkout for release PR creation')
6050

61-
repo.git.checkout(trigger_branch)
62-
repo.git.pull("origin", trigger_branch)
51+
repo.git.checkout(config.default_repo_branch)
52+
repo.git.pull("origin", config.default_repo_branch)
6353

64-
# Create a new branch for the release changes PR to trigger branch
65-
try:
66-
repo.git.checkout('-b', config.pr_branch_name)
67-
except Exception as e:
68-
# Branch might exist locally, try to checkout existing branch
69-
if 'already exists' in str(e).lower():
70-
raise Exception(f"Branch '{config.pr_branch_name}' already exists locally which is not expected. Exiting.")
71-
else:
72-
raise
54+
# Create a new branch for the release changes PR to default branch
55+
repo.git.checkout('-b', config.pr_branch_name)
7356

7457
# Update the changelog file with adding new [Unreleased] section
7558
update_changelog(config.changelog_path, config.package_version, add_unreleased_template=True)
@@ -85,10 +68,10 @@ def createPrAfterRelease(config: ReleaseConfig):
8568
repo.git.push("origin", config.pr_branch_name)
8669

8770
github = config.github_manager
88-
pr = github.create_pull_request(title=config.pr_commit_message, body=config.pr_body, head=config.pr_branch_name, base=trigger_branch)
71+
pr = github.create_pull_request(title=config.pr_commit_message, body=config.pr_body, head=config.pr_branch_name, base=config.default_repo_branch)
8972
github.request_reviews(pr, config.pr_reviewers)
9073

91-
print(f"Successfully updated and created the PR targeting trigger branch: {trigger_branch}")
74+
print(f"Successfully updated and created the PR targeting: {config.default_repo_branch}")
9275

9376
except GithubException as e:
9477
print(f"An error occurred with the GitHub API: {e.status}", file=sys.stderr)

Tools/scripts/Utils/git_utils.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,13 @@ def create_release_branch(config: ReleaseConfig):
4545
"""
4646
Creates a new branch with the specified name, performs specified action, commits the current changes and pushes it to the repo.
4747
Note that command_to_run_on_release_branch (within the Config) should be a single command that will be executed using subprocess.run. For multiple commands consider using a Python script file.
48-
49-
IMPORTANT: The release branch is created from the trigger branch (the branch the job was triggered from).
50-
This ensures the release branch is created from the branch that was validated and will be used for the PR.
51-
Please double check if the target branch is different and if so the if this was intended.
5248
"""
5349

5450
try:
5551
if config.github_manager.is_branch_present(config.release_branch_name):
5652
raise Exception(f"Branch '{config.release_branch_name}' already exists.")
5753

5854
repo = get_local_repo()
59-
trigger_branch = repo.active_branch.name
60-
61-
# Stash any uncommitted changes to allow pull
62-
has_uncommitted_changes = repo.is_dirty()
63-
if has_uncommitted_changes:
64-
print("Uncommitted changes detected. Stashing before pull...")
65-
repo.git.stash('push', '-m', 'Auto-stash before pull for release branch creation')
66-
67-
repo.git.fetch('--prune', '--prune-tags')
68-
repo.git.pull("origin", trigger_branch)
6955

7056
new_branch = repo.create_head(config.release_branch_name, repo.head.commit)
7157
new_branch.checkout()

Tools/scripts/Utils/verifyReleaseConditions.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
- Note that if the job is triggered manually, this condition will be bypassed.
88
2. **Is the [Unreleased] section of the CHANGELOG.md not empty?**
99
- The script checks if the [Unreleased] section in the CHANGELOG.md contains meaningful entries.
10-
- IMPORTANT: This check is performed on the branch the job was triggered from (after pulling latest).
11-
The release branch will be created from this trigger branch, and the PR will target this trigger branch.
12-
Please double check if the target branch is different and if so the if this was intended.
1310
3. **Does the release branch already exist?**
1411
- If the release branch for the target release already exists, the script will not run.
1512
"""
@@ -24,7 +21,6 @@
2421
import datetime
2522
import re
2623
from release_config import ReleaseConfig
27-
from Utils.git_utils import get_local_repo
2824

2925
def get_yamato_trigger_type():
3026
"""
@@ -84,9 +80,6 @@ def verifyReleaseConditions(config: ReleaseConfig):
8480
This function checks the following conditions:
8581
1. If today is a scheduled release day (based on release cycle, weekday and anchor date).
8682
2. If the [Unreleased] section of the CHANGELOG.md is not empty.
87-
IMPORTANT: This check is performed on the branch the job was triggered from (after pulling latest).
88-
The release branch will be created from this trigger branch, and the PR will target this trigger branch.
89-
Please double check if the target branch is different and if so the if this was intended.
9083
3. If the release branch does not already exist.
9184
"""
9285

@@ -99,34 +92,12 @@ def verifyReleaseConditions(config: ReleaseConfig):
9992
if not is_manual and not is_release_date(config.release_weekday, config.release_week_cycle, config.anchor_date):
10093
error_messages.append(f"Condition not met: Today is not the scheduled release day. It should be weekday: {config.release_weekday}, every {config.release_week_cycle} weeks starting from {config.anchor_date}.")
10194

102-
# Pull latest changes from the trigger branch to ensure we're checking the latest state
103-
# The release branch will be created from this trigger branch, and the PR will target this trigger branch
104-
repo = get_local_repo()
105-
trigger_branch = repo.active_branch.name
106-
print(f"\nTrigger branch: {trigger_branch}")
107-
print(f"Pulling latest changes from '{trigger_branch}' to verify changelog state...")
108-
109-
# Stash any uncommitted changes to allow pull
110-
has_uncommitted_changes = repo.is_dirty()
111-
if has_uncommitted_changes:
112-
print("Uncommitted changes detected. Stashing before pull...")
113-
repo.git.stash('push', '-m', 'Auto-stash before pull for release verification')
114-
115-
repo.git.fetch('--prune', '--prune-tags')
116-
repo.git.pull("origin", trigger_branch)
117-
print(f"Now on branch '{trigger_branch}' with latest changes pulled.")
118-
11995
if is_changelog_empty(config.changelog_path):
12096
error_messages.append("Condition not met: The [Unreleased] section of the changelog has no meaningful entries.")
12197

12298
if config.github_manager.is_branch_present(config.release_branch_name):
12399
error_messages.append("Condition not met: The release branch already exists.")
124100

125-
# Restore stashed changes if any
126-
if has_uncommitted_changes:
127-
print("Restoring stashed changes...")
128-
repo.git.stash('pop')
129-
130101
if error_messages:
131102
print("\n--- Release conditions not met: ---")
132103
for i, msg in enumerate(error_messages, 1):

0 commit comments

Comments
 (0)