big rework on automation.py and staging game builds now

This commit is contained in:
peterino2 2025-10-12 15:24:57 -07:00
parent 1162a0b008
commit 0c9a3e45ae
4 changed files with 89 additions and 27 deletions

View File

@ -2,7 +2,7 @@ name: Build Projects
on: on:
push: push:
branches: [ main, integration, dev/**] branches: [ main, integration]
pull_request: pull_request:
branches: [ main, integration ] branches: [ main, integration ]
@ -14,14 +14,10 @@ jobs:
target: target:
- zig: x86_64-linux-gnu - zig: x86_64-linux-gnu
os: self-hosted-linux os: self-hosted-linux
zipCommand: tar -cvfz python: python3
zipName: package.tar.xz
python: $PYTHON_NAME
- zig: x86_64-windows - zig: x86_64-windows
os: self-hosted-windows os: self-hosted-windows
zipCommand: zip python: python
zipName: package.zip
python: %PYTHON_NAME%
steps: steps:
- name: Checkout repository - name: Checkout repository

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
.zig-cache/ .zig-cache/
zig-out/ zig-out/
staging/
zig-out-debug/
zig-out-release/
*Saved/* *Saved/*
.modulecache/ .modulecache/

2
lib/tracy/build.zig vendored
View File

@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {
//const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false; //const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false;
const tracy_enabled: bool = true; //if (b.graph.env_map.hash_map.get("WITH_TRACY") != null) true else false; const tracy_enabled: bool = false; //if (b.graph.env_map.hash_map.get("WITH_TRACY") != null) true else false;
// if (b.graph.env_map.hash_map.get("WITH_TRACY")) |with_tracy| { // if (b.graph.env_map.hash_map.get("WITH_TRACY")) |with_tracy| {
// tracy_enabled = with_tracy; // tracy_enabled = with_tracy;
// } // }

View File

@ -1,5 +1,7 @@
import os import os
import argparse import argparse
import shutil
import sys
import subprocess import subprocess
orig_dir = os.path.abspath(os.path.dirname(__file__)) orig_dir = os.path.abspath(os.path.dirname(__file__))
@ -14,45 +16,100 @@ def getCommitHash():
dryRun = False dryRun = False
def run(cmd): def run(cmd, cwd=None):
global dryRun global dryRun
print(" ".join(cmd)) print(" ".join(cmd))
c = os.getcwd()
if cwd is not None:
c = cwd
if not dryRun: if not dryRun:
print(subprocess.check_output(cmd, shell=True).decode()) print(subprocess.check_output(" ".join(cmd), shell=True, cwd=c).decode(), file=sys.stderr)
def buildAndPackage(branch, target, deploy): def buildAndPackage(branch, target, deploy):
run(['zig', 'build', 'install', f'-Dtarget={target}', '--prefix', 'zig-out-debug']) run(['zig', 'env'])
run(['zig', 'build', 'install', f'-Dtarget={target}', '-Dstatic_build', '-Doptimize=ReleaseSafe', '--prefix', 'zig-out-release']) run(['zig', 'build', f'-Dtarget={target}', '--prefix', 'zig-out-debug', 'install'])
run(['zig', 'build', f'-Dtarget={target}', '-Dstatic_build', '-Doptimize=ReleaseSafe', '--prefix', 'zig-out-release', 'install'])
if deploy is not None: if deploy is not None:
host = '$BACKLOG_INFRA_DEPLOY_HOST'
path = '$BACKLOG_INFRA_DEPLOY_PATH'
if os.name == 'nt':
host = '%BACKLOG_INFRA_DEPLOY_HOST%'
path = '%BACKLOG_INFRA_DEPLOY_PATH%'
sampleGameDeploy = f'{path}/sampleGame/{branch}/{deploy}'
binariesDeploy = f'{path}/binaries/{branch}/{deploy}'
def makePackage(target, branch, deploy, tag): def makePackage(target, branch, deploy, tag):
host = '$BACKLOG_INFRA_DEPLOY_HOST'
path = '$BACKLOG_INFRA_DEPLOY_PATH'
run(['ssh', host, f'mkdir -p {binariesDeploy}'])
run(['ssh', host, f'mkdir -p {sampleGameDeploy}'])
if os.name == 'nt': if os.name == 'nt':
host = '%BACKLOG_INFRA_DEPLOY_HOST%' packageFile = f'binaries-{deploy}-{tag}-{target}.zip'
path = '%BACKLOG_INFRA_DEPLOY_PATH%'
run(['ssh', host, f'mkdir -p {path}/{branch}/{deploy}'])
if os.name == 'nt':
packageFile = f'{deploy}-{tag}-{target}.zip'
run(['zip', '-r', '-7', packageFile, f'zig-out-{tag}']) run(['zip', '-r', '-7', packageFile, f'zig-out-{tag}'])
run(['scp', packageFile, f'{host}:{path}/{branch}/{deploy}/{packageFile}']) run(['scp', packageFile, f'{host}:{binariesDeploy}/{packageFile}'])
else: else:
packageFile = f'{deploy}-{tag}.tar.xz' packageFile = f'binaries-{deploy}-{tag}-{target}.tar.xz'
run(['tar', '-cvzf', packageFile, f'zig-out-{tag}']) run(['tar', '-cvzf', os.path.abspath(packageFile), '-C', f'zig-out-{tag}'])
run(['scp', packageFile, f'{host}:{path}/{branch}/{deploy}/{packageFile}']) run(['scp', packageFile, f'{host}:{binariesDeploy}/{packageFile}'])
os.makedirs(f'staging/sampleGame/{tag}', exist_ok=True)
excludeList = [
'headless.exe',
'headless.pdb',
'newProject.exe',
'newProject.pdb',
'toolbox.exe',
'toolbox.pdb'
]
for f in os.listdir(f'zig-out-{tag}/bin'):
shutil.copy(os.path.join(f'zig-out-{tag}/bin', f), f"staging/sampleGame/{tag}/")
if os.path.exists(f'zig-out-{tag}/modules'):
os.makedirs('staging/sampleGame/zig-out/modules', exist_ok=True)
for f in os.listdir(f'zig-out-{tag}/modules'):
print("module: ", f, os.path.join(f'zig-out-{tag}/modules', f))
shutil.copy(os.path.join(f'zig-out-{tag}/modules', f), f"staging/sampleGame/zig-out/modules/" + f)
makePackage(target, branch, deploy, 'debug') makePackage(target, branch, deploy, 'debug')
makePackage(target, branch, deploy, 'release') makePackage(target, branch, deploy, 'release')
# stage content
if os.path.exists('staging/sampleGame/content'):
shutil.rmtree('staging/sampleGame/content', ignore_errors=False, onerror=None)
shutil.copytree('content', 'staging/sampleGame/content')
if os.name == 'nt':
packageFile = f'sampleGame-{deploy}-{target}.zip'
run(['zip', '-r', '-7', os.path.abspath(packageFile), f'.'], cwd=os.path.join(os.getcwd(), 'staging/sampleGame'))
run(['scp', packageFile, f'{host}:{sampleGameDeploy}/{packageFile}'])
else:
packageFile = f'sampleGame-{deploy}-{target}.tar.xz'
run(['tar', '-cvzf', os.path.abspath(packageFile), '-C', f'staging/sampleGame'])
run(['scp', packageFile, f'{host}:{sampleGameDeploy}/{packageFile}'])
run(['zig', 'build', f'-Dtarget={target}', 'run-headless'])
run(['zig', 'build', f'-Dtarget={target}', '-Dstatic_build','run-headless'])
run(['zig', 'build', f'-Dtarget={target}', '-Dslow_logging','run-headless'])
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='run automation tasks for the repo') parser = argparse.ArgumentParser(description='run automation tasks for the repo')
# Positional argument (required) # Positional argument (required)
parser.add_argument('--deploy', nargs="?", help='Path to the input file') parser.add_argument('--deploy', nargs="?", help='tag for the deployment')
parser.add_argument('--branch', default="manual", help='branch name') parser.add_argument('--branch', default="manual", help='branch name')
parser.add_argument('--dry', action="store_true", help='dont run anything') parser.add_argument('--dry', action="store_true", help='dont run anything')
@ -63,5 +120,11 @@ if __name__ == "__main__":
if args.dry: if args.dry:
dryRun = True dryRun = True
buildAndPackage(args.branch, args.target, args.deploy)
def cleanBranchName(branch):
return branch.replace('/', '_')
b = cleanBranchName(args.branch)
buildAndPackage(b, args.target, args.deploy)