-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathrelease_config.py
More file actions
216 lines (186 loc) · 11.8 KB
/
release_config.py
File metadata and controls
216 lines (186 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
"""Netcode configuration for the release process automation."""
import datetime
import sys
import os
from github import Github
from github import GithubException
PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
sys.path.insert(0, PARENT_DIR)
from Utils.general_utils import get_package_version_from_manifest
from release import make_package_release_ready
class GithubUtils:
def __init__(self, access_token, repo):
self.github = Github(base_url="https://api.github.com",
login_or_token=access_token)
self.repo = self.github.get_repo(repo)
def is_branch_present(self, branch_name):
try:
self.repo.get_branch(branch_name)
return True # Branch exists
except GithubException as ghe:
if ghe.status == 404:
return False # Branch does not exist
raise Exception(f"An error occurred with the GitHub API: {ghe.status}", data=ghe.data)
def create_pull_request(self, title, body, head, base):
try:
return self.repo.create_pull(title=title, body=body, head=head, base=base)
except GithubException as ghe:
raise Exception(f"Failed to create pull request: {ghe.status}", ghe.data) from ghe
def request_reviews(self, pr, reviewers):
if not reviewers:
return
try:
pr.create_review_request(reviewers=reviewers)
except GithubException as ghe:
raise Exception(f"Failed to request reviews: {ghe.status}", ghe.data) from ghe
class ReleaseConfig:
"""A simple class to hold all shared configuration."""
def __init__(self):
self.manifest_path = 'com.unity.netcode.gameobjects/package.json'
self.changelog_path = 'com.unity.netcode.gameobjects/CHANGELOG.md'
self.validation_exceptions_path = './ValidationExceptions.json'
self.github_repo = 'Unity-Technologies/com.unity.netcode.gameobjects'
self.default_repo_branch = 'develop-2.0.0' # Changelog and package version change will be pushed to this branch
self.yamato_project_id = '1201'
self.command_to_run_on_release_branch = make_package_release_ready
self.release_weekday = 6 # Sunday
self.release_week_cycle = 4 # Release every 4 weeks
self.anchor_date = datetime.date(2025, 7, 20) # Anchor date for the release cycle (previous release Sunday)
self.package_version = get_package_version_from_manifest(self.manifest_path)
self.release_branch_name = f"release/{self.package_version}" # Branch from which we want to release
self.release_commit_message = f"Updated changelog and package version for Netcode in anticipation of v{self.package_version} release"
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
self.pr_commit_message = f"chore: Updated aspects of Netcode package in anticipation of v{self.package_version} release"
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" \
f"1) Updated CHANGELOG.md by adding new [Unreleased] section template at the top and cleaning the Changelog for the current release.\n" \
f"2) Updated package version in package.json by incrementing the patch version to signify the current state of the package.\n" \
f"3) Updated package version in ValidationExceptions.json to match the new package version.\n\n" \
f"Please review and merge this PR to keep the default branch up to date with the latest package state after the release. Those changes can land immediately OR after the release was finalized but make sure that the Changelog will be merged correctly as sometimes some discrepancies may be introduced due to new entries being introduced meantime\n"
self.pr_reviewers = ["michal-chrobot"]
GITHUB_TOKEN_NAME = "NETCODE_GITHUB_TOKEN"
YAMATO_API_KEY_NAME = "NETCODE_YAMATO_API_KEY"
self.github_token = os.environ.get(GITHUB_TOKEN_NAME)
self.yamato_api_token = os.environ.get(YAMATO_API_KEY_NAME)
self.commiter_name = "netcode-automation"
self.commiter_email = "svc-netcode-sdk@unity3d.com"
self.yamato_samples_to_build = [
{
"name": "BossRoom",
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_BossRoom_project",
},
{
"name": "Asteroids",
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_Asteroids_project",
},
{
"name": "SocialHub",
"jobDefinition": f".yamato%2Fproject-builders%2Fproject-builders.yml%23build_SocialHub_project",
}
]
self.yamato_build_automation_configs = [
{
"job_name": "Build Sample for Windows with minimal supported editor (6000.0.0f1), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "6000.0.0f1" } # Minimal supported editor
]
},
{
"job_name": "Build Sample for Windows with latest functional editor (6000.3), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "6000.3" } # 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.
]
},
{
"job_name": "Build Sample for Windows with latest editor (trunk), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "win64" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
]
},
{
"job_name": "Build Sample for MacOS with minimal supported editor (6000.0.0f1), burst OFF, Mono",
"variables": [
{ "key": "BURST_ON_OFF", "value": "off" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
{ "key": "UNITY_VERSION", "value": "6000.0.0f1" } # Minimal supported editor
]
},
{
"job_name": "Build Sample for MacOS with latest functional editor (6000.3), burst OFF, Mono",
"variables": [
{ "key": "BURST_ON_OFF", "value": "off" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
{ "key": "UNITY_VERSION", "value": "6000.3" } # 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.
]
},
{
"job_name": "Build Sample for MacOS with latest editor (trunk), burst OFF, Mono",
"variables": [
{ "key": "BURST_ON_OFF", "value": "off" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "mac" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "mono" },
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
]
},
{
"job_name": "Build Sample for Android with minimal supported editor (6000.0.0f1), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "6000.0.0f1" } # Minimal supported editor
]
},
{
"job_name": "Build Sample for Android with latest functional editor (6000.3), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "6000.3" } # 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.
]
},
{
"job_name": "Build Sample for Android with latest editor (trunk), burst ON, IL2CPP",
"variables": [
{ "key": "BURST_ON_OFF", "value": "on" },
{ "key": "PLATFORM_WIN64_MAC_ANDROID", "value": "android" },
{ "key": "SCRIPTING_BACKEND_IL2CPP_MONO", "value": "il2cpp" },
{ "key": "UNITY_VERSION", "value": "trunk" } # latest editor
]
}
]
error_messages = []
if not os.path.exists(self.manifest_path):
error_messages.append(f" Path does not exist: {self.manifest_path}")
if not os.path.exists(self.changelog_path):
error_messages.append(f" Path does not exist: {self.changelog_path}")
if not os.path.exists(self.validation_exceptions_path):
error_messages.append(f" Path does not exist: {self.validation_exceptions_path}")
if not callable(self.command_to_run_on_release_branch):
error_messages.append("command_to_run_on_release_branch is not a function! Actual value:", self.command_to_run_on_release_branch)
if self.package_version is None:
error_messages.append(f"Package version not found at {self.manifest_path}")
if not self.github_token:
error_messages.append(f"Error: {GITHUB_TOKEN_NAME} environment variable not set.")
if not self.yamato_api_token:
error_messages.append(f"Error: {YAMATO_API_KEY_NAME} environment variable not set.")
# Initialize PyGithub and get the repository object
self.github_manager = GithubUtils(self.github_token, self.github_repo)
if not self.github_manager.is_branch_present(self.default_repo_branch):
error_messages.append(f"Branch '{self.default_repo_branch}' does not exist.")
if self.github_manager.is_branch_present(self.release_branch_name):
error_messages.append(f"Branch '{self.release_branch_name}' is already present in the repo.")
if error_messages:
summary = "Failed to initialize NetcodeReleaseConfig due to invalid setup:\n" + "\n".join(f"- {msg}" for msg in error_messages)
raise ValueError(summary)