big rework on automation.py and staging game builds now
This commit is contained in:
parent
1162a0b008
commit
0c9a3e45ae
|
|
@ -2,7 +2,7 @@ name: Build Projects
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, integration, dev/**]
|
||||
branches: [ main, integration]
|
||||
pull_request:
|
||||
branches: [ main, integration ]
|
||||
|
||||
|
|
@ -14,14 +14,10 @@ jobs:
|
|||
target:
|
||||
- zig: x86_64-linux-gnu
|
||||
os: self-hosted-linux
|
||||
zipCommand: tar -cvfz
|
||||
zipName: package.tar.xz
|
||||
python: $PYTHON_NAME
|
||||
python: python3
|
||||
- zig: x86_64-windows
|
||||
os: self-hosted-windows
|
||||
zipCommand: zip
|
||||
zipName: package.zip
|
||||
python: %PYTHON_NAME%
|
||||
python: python
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
.zig-cache/
|
||||
zig-out/
|
||||
|
||||
staging/
|
||||
zig-out-debug/
|
||||
zig-out-release/
|
||||
*Saved/*
|
||||
|
||||
.modulecache/
|
||||
|
|
|
|||
|
|
@ -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: 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| {
|
||||
// tracy_enabled = with_tracy;
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
import argparse
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
orig_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
|
@ -14,18 +16,24 @@ def getCommitHash():
|
|||
|
||||
dryRun = False
|
||||
|
||||
def run(cmd):
|
||||
def run(cmd, cwd=None):
|
||||
global dryRun
|
||||
print(" ".join(cmd))
|
||||
c = os.getcwd()
|
||||
|
||||
if cwd is not None:
|
||||
c = cwd
|
||||
|
||||
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):
|
||||
run(['zig', 'build', 'install', f'-Dtarget={target}', '--prefix', 'zig-out-debug'])
|
||||
run(['zig', 'build', 'install', f'-Dtarget={target}', '-Dstatic_build', '-Doptimize=ReleaseSafe', '--prefix', 'zig-out-release'])
|
||||
run(['zig', 'env'])
|
||||
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:
|
||||
def makePackage(target, branch, deploy, tag):
|
||||
host = '$BACKLOG_INFRA_DEPLOY_HOST'
|
||||
path = '$BACKLOG_INFRA_DEPLOY_PATH'
|
||||
|
||||
|
|
@ -33,26 +41,75 @@ def buildAndPackage(branch, target, deploy):
|
|||
host = '%BACKLOG_INFRA_DEPLOY_HOST%'
|
||||
path = '%BACKLOG_INFRA_DEPLOY_PATH%'
|
||||
|
||||
run(['ssh', host, f'mkdir -p {path}/{branch}/{deploy}'])
|
||||
sampleGameDeploy = f'{path}/sampleGame/{branch}/{deploy}'
|
||||
binariesDeploy = f'{path}/binaries/{branch}/{deploy}'
|
||||
|
||||
def makePackage(target, branch, deploy, tag):
|
||||
|
||||
|
||||
run(['ssh', host, f'mkdir -p {binariesDeploy}'])
|
||||
run(['ssh', host, f'mkdir -p {sampleGameDeploy}'])
|
||||
|
||||
if os.name == 'nt':
|
||||
packageFile = f'{deploy}-{tag}-{target}.zip'
|
||||
packageFile = f'binaries-{deploy}-{tag}-{target}.zip'
|
||||
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:
|
||||
packageFile = f'{deploy}-{tag}.tar.xz'
|
||||
run(['tar', '-cvzf', packageFile, f'zig-out-{tag}'])
|
||||
run(['scp', packageFile, f'{host}:{path}/{branch}/{deploy}/{packageFile}'])
|
||||
packageFile = f'binaries-{deploy}-{tag}-{target}.tar.xz'
|
||||
run(['tar', '-cvzf', os.path.abspath(packageFile), '-C', f'zig-out-{tag}'])
|
||||
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, '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__":
|
||||
parser = argparse.ArgumentParser(description='run automation tasks for the repo')
|
||||
|
||||
# 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('--dry', action="store_true", help='dont run anything')
|
||||
|
||||
|
|
@ -63,5 +120,11 @@ if __name__ == "__main__":
|
|||
if args.dry:
|
||||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue