Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Allow configuring gen_build_info.py through environment variables" #25201

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions Tools/gen_build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"SS14.Server_osx-x64.zip"
]

FORK_ID = os.environ.get("CDN_FORK_ID", "wizards")
HOSTNAME = os.environ.get("CDN_HOSTNAME", "cdn.centcomm.spacestation14.com")
BUILD_URL = f"https://{HOSTNAME}/builds/{FORK_ID}/builds/{{FORK_VERSION}}/{FILE}"
MANIFEST_URL = f"https://{HOSTNAME}/version/{{FORK_VERSION}}/manifest"
MANIFEST_DOWNLOAD_URL = f"https://{HOSTNAME}/version/{{FORK_VERSION}}/download"
VERSION = os.environ['GITHUB_SHA']
FORK_ID = "wizards"
BUILD_URL = f"https://cdn.centcomm.spacestation14.com/builds/wizards/builds/{{FORK_VERSION}}/{FILE}"
MANIFEST_URL = f"https://cdn.centcomm.spacestation14.com/cdn/version/{{FORK_VERSION}}/manifest"
MANIFEST_DOWNLOAD_URL = f"https://cdn.centcomm.spacestation14.com/cdn/version/{{FORK_VERSION}}/download"

def main() -> None:
client_file = os.path.join("release", FILE)
Expand All @@ -38,33 +38,24 @@ def inject_manifest(zip_path: str, manifest: str) -> None:
z.writestr("build.json", manifest)


def get_git_sha() -> str:
proc = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True, encoding="UTF-8")
tag = proc.stdout.strip()
return tag

def generate_build_json(file: str) -> str:
# Env variables set by Jenkins.

hash = sha256_file(file)
engine_version = get_engine_version()
manifest_hash = generate_manifest_hash(file)
version = os.environ.get("GITHUB_SHA")
if not version:
version = get_git_sha()

return json.dumps({
"download": BUILD_URL,
"hash": hash,
"version": version,
"version": VERSION,
"fork_id": FORK_ID,
"engine_version": engine_version,
"manifest_url": MANIFEST_URL,
"manifest_download_url": MANIFEST_DOWNLOAD_URL,
"manifest_hash": manifest_hash
})


def generate_manifest_hash(file: str) -> str:
zip = ZipFile(file)
infos = zip.infolist()
Expand Down Expand Up @@ -92,6 +83,7 @@ def get_engine_version() -> str:
assert tag.startswith("v")
return tag[1:] # Cut off v prefix.


def sha256_file(path: str) -> str:
with open(path, "rb") as f:
h = hashlib.sha256()
Expand Down
Loading