Skip to content

Commit 19770a2

Browse files
committed
Updated config and other files
1 parent 397019a commit 19770a2

File tree

9 files changed

+404
-420
lines changed

9 files changed

+404
-420
lines changed

Tools/scripts/ReleaseAutomation/netcodeReleaseBranchCreation.py

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
import datetime
2+
import sys
3+
import os
4+
from github import Github
5+
from github import GithubException
6+
7+
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
8+
sys.path.insert(0, PARENT_DIR)
9+
10+
from Utils.general_utils import get_package_version_from_manifest # nopep8
11+
from release import make_package_release_ready # nopep8
12+
13+
class GithubUtils:
14+
def __init__(self, access_token, repo):
15+
self.github = Github(base_url="https://api.github.com",
16+
login_or_token=access_token)
17+
self.repo = self.github.get_repo(repo)
18+
19+
def is_branch_present(self, branch_name):
20+
try:
21+
self.repo.get_branch(branch_name)
22+
return True # Branch exists
23+
24+
except GithubException as ghe:
25+
if ghe.status == 404:
26+
return False # Branch does not exist
27+
raise Exception(f"An error occurred with the GitHub API: {ghe.status}", data=ghe.data)
28+
29+
class ReleaseConfig:
30+
"""A simple class to hold all shared configuration."""
31+
def __init__(self):
32+
self.manifest_path = 'com.unity.netcode.gameobjects/package.json'
33+
self.changelog_path = 'com.unity.netcode.gameobjects/CHANGELOG.md'
34+
self.validation_exceptions_path = 'com.unity.netcode.gameobjects/ValidationExceptions.json'
35+
self.github_repo = 'Unity-Technologies/com.unity.netcode.gameobjects'
36+
self.default_repo_branch = 'develop-2.0.0' # Changelog and package version change will be pushed to this branch
37+
self.yamato_project_id = '1201'
38+
self.command_to_run_on_release_branch = make_package_release_ready
39+
40+
self.release_weekday = 5 # Saturday
41+
self.release_week_cycle = 4 # Release every 4 weeks
42+
self.anchor_date = datetime.date(2025, 7, 19) # Anchor date for the release cycle (previous release Saturday)
43+
44+
self.package_version = get_package_version_from_manifest(self.manifest_path)
45+
self.release_branch_name = f"release/{self.package_version}" # Branch from which we want to release
46+
self.commit_message = f"Updated changelog and package version for Netcode in anticipation of v{self.package_version} release"
47+
48+
GITHUB_TOKEN_NAME = "NETCODE_GITHUB_CDS_TOKEN"
49+
YAMATO_API_KEY_NAME = "NETCODE_YAMATO_API_KEY"
50+
self.github_token = os.environ.get(GITHUB_TOKEN_NAME)
51+
self.yamato_api_token = os.environ.get(YAMATO_API_KEY_NAME)
52+
self.commiter_name = "netcode-automation"
53+
self.commiter_email = "[email protected]"
54+
55+
self.yamato_samples_to_build = [
56+
{
57+
"name": "BossRoom",
58+
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_BossRoom_project",
59+
},
60+
{
61+
"name": "Asteroids",
62+
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_Asteroids_project",
63+
},
64+
{
65+
"name": "SocialHub",
66+
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_SocialHub_project",
67+
}
68+
]
69+
70+
self.yamato_build_automation_configs = [
71+
{
72+
"job_name": "Build Sample for Windows with minimal supported editor (2022.3), burst ON, IL2CPP",
73+
"variables": [
74+
{ "key": "BURST_ON_OFF", "value": "on" },
75+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
76+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
77+
{ "key": "UNITY_VERSION", "value": "2022.3" } # Minimal supported editor
78+
]
79+
},
80+
{
81+
"job_name": "Build Sample for Windows with latest functional editor (6000.2), burst ON, IL2CPP",
82+
"variables": [
83+
{ "key": "BURST_ON_OFF", "value": "on" },
84+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
85+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
86+
{ "key": "UNITY_VERSION", "value": "6000.2" } # Editor that most our users will use (not alpha). Sometimes when testing on trunk we have weird editor issues not caused by us so the preference will be to test on latest editor that our users will use.
87+
]
88+
},
89+
{
90+
"job_name": "Build Sample for Windows with latest editor (trunk), burst ON, IL2CPP",
91+
"variables": [
92+
{ "key": "BURST_ON_OFF", "value": "on" },
93+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
94+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
95+
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
96+
]
97+
},
98+
{
99+
"job_name": "Build Sample for MacOS with minimal supported editor (2022.3), burst OFF, Mono",
100+
"variables": [
101+
{ "key": "BURST_ON_OFF", "value": "off" },
102+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
103+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
104+
{ "key": "UNITY_VERSION", "value": "2022.3" } # Minimal supported editor
105+
]
106+
},
107+
{
108+
"job_name": "Build Sample for MacOS with latest functional editor (6000.2), burst OFF, Mono",
109+
"variables": [
110+
{ "key": "BURST_ON_OFF", "value": "off" },
111+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
112+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
113+
{ "key": "UNITY_VERSION", "value": "6000.2" } # Editor that most our users will use (not alpha). Sometimes when testing on trunk we have weird editor issues not caused by us so the preference will be to test on latest editor that our users will use.
114+
]
115+
},
116+
{
117+
"job_name": "Build Sample for MacOS with latest editor (trunk), burst OFF, Mono",
118+
"variables": [
119+
{ "key": "BURST_ON_OFF", "value": "off" },
120+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
121+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
122+
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
123+
]
124+
},
125+
{
126+
"job_name": "Build Sample for Android with minimal supported editor (2022.3), burst ON, IL2CPP",
127+
"variables": [
128+
{ "key": "BURST_ON_OFF", "value": "on" },
129+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
130+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
131+
{ "key": "UNITY_VERSION", "value": "2022.3" } # Minimal supported editor
132+
]
133+
},
134+
{
135+
"job_name": "Build Sample for Android with latest functional editor (6000.2), burst ON, IL2CPP",
136+
"variables": [
137+
{ "key": "BURST_ON_OFF", "value": "on" },
138+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
139+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
140+
{ "key": "UNITY_VERSION", "value": "6000.2" } # Editor that most our users will use (not alpha). Sometimes when testing on trunk we have weird editor issues not caused by us so the preference will be to test on latest editor that our users will use.
141+
]
142+
},
143+
{
144+
"job_name": "Build Sample for Android with latest editor (trunk), burst ON, IL2CPP",
145+
"variables": [
146+
{ "key": "BURST_ON_OFF", "value": "on" },
147+
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
148+
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
149+
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
150+
]
151+
}
152+
]
153+
154+
error_messages = []
155+
if not os.path.exists(self.manifest_path):
156+
error_messages.append(f" Path does not exist: {self.manifest_path}")
157+
158+
if not os.path.exists(self.changelog_path):
159+
error_messages.append(f" Path does not exist: {self.changelog_path}")
160+
161+
if not os.path.exists(self.validation_exceptions_path):
162+
error_messages.append(f" Path does not exist: {self.validation_exceptions_path}")
163+
164+
if not callable(self.command_to_run_on_release_branch):
165+
error_messages.append("command_to_run_on_release_branch is not a function! Actual value:", self.command_to_run_on_release_branch)
166+
167+
if self.package_version is None:
168+
error_messages.append(f"Package version not found at {self.manifest_path}")
169+
170+
if not self.github_token:
171+
error_messages.append(f"Error: {GITHUB_TOKEN_NAME} environment variable not set.")
172+
173+
if not self.yamato_api_token:
174+
error_messages.append("Error: {YAMATO_API_KEY_NAME} environment variable not set.")
175+
176+
# Initialize PyGithub and get the repository object
177+
self.github_manager = GithubUtils(self.github_token, self.github_repo)
178+
179+
if not self.github_manager.is_branch_present(self.default_repo_branch):
180+
error_messages.append(f"Branch '{self.default_repo_branch}' does not exist.")
181+
182+
if self.github_manager.is_branch_present(self.release_branch_name):
183+
error_messages.append(f"Branch '{self.release_branch_name}' is already present in the repo.")
184+
185+
if error_messages:
186+
summary = "Failed to initialize NetcodeReleaseConfig due to invalid setup:\n" + "\n".join(f"- {msg}" for msg in error_messages)
187+
raise ValueError(summary)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
import os
3+
4+
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
5+
sys.path.insert(0, PARENT_DIR)
6+
7+
from ReleaseAutomation.release_config import ReleaseConfig # nopep8
8+
from Utils.git_utils import create_branch_execute_commands_and_push # nopep8
9+
from Utils.verifyReleaseConditions import verifyReleaseConditions # nopep8
10+
from Utils.commitChangelogAndPackageVersionUpdates import commitChangelogAndPackageVersionUpdates # nopep8
11+
from Utils.triggerYamatoJobsForReleasePreparation import trigger_release_preparation_jobs # nopep8
12+
13+
def PrepareNetcodePackageForRelease():
14+
try:
15+
config = ReleaseConfig()
16+
17+
print("\nStep 1: Verifying release conditions...")
18+
verifyReleaseConditions(config)
19+
20+
print("\nStep 2: Creating release branch...")
21+
create_branch_execute_commands_and_push(config)
22+
23+
print("\nStep 3: Triggering Yamato validation jobs...")
24+
trigger_release_preparation_jobs(config)
25+
26+
print("\nStep 4: Committing changelog and version updates...")
27+
commitChangelogAndPackageVersionUpdates(config)
28+
29+
except Exception as e:
30+
print(f"\n--- ERROR: Netcode release process failed ---", file=sys.stderr)
31+
print(f"Reason: {e}", file=sys.stderr)
32+
sys.exit(1)
33+
34+
if __name__ == "__main__":
35+
PrepareNetcodePackageForRelease()

0 commit comments

Comments
 (0)