Merge pull request #2 from peterino2/dev/peterino

saving
This commit is contained in:
Peter Li 2025-10-12 12:28:30 -07:00 committed by GitHub
commit 1162a0b008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 82 additions and 13 deletions

View File

@ -2,7 +2,7 @@ name: Build Projects
on: on:
push: push:
branches: [ main, integration ] branches: [ main, integration, dev/**]
pull_request: pull_request:
branches: [ main, integration ] branches: [ main, integration ]
@ -14,8 +14,14 @@ jobs:
target: target:
- zig: x86_64-linux-gnu - zig: x86_64-linux-gnu
os: self-hosted-linux os: self-hosted-linux
zipCommand: tar -cvfz
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
zipName: package.zip
python: %PYTHON_NAME%
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -23,15 +29,12 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Build projects - name: Get short commit SHA
working-directory: ./projects id: commit
run: zig build install -Dtarget=${{ matrix.target.zig }} shell: bash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build Debug
working-directory: ./projects
run: ${{ matrix.target.python }} ../tools/scripts/automation.py ${{ matrix.target.zig }} --deploy=${{ steps.commit.outputs.sha_short }} --branch=${{ github.head_ref || github.ref_name }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: build-artifacts-${{ matrix.target.zig }}
path: |
projects/zig-out/
retention-days: 7

View File

@ -401,7 +401,6 @@ pub const Program = struct {
for (self.gameModules.items) |*m| { for (self.gameModules.items) |*m| {
if (std.mem.eql(u8, m.name, module)) { if (std.mem.eql(u8, m.name, module)) {
m.enabled = enable; m.enabled = enable;
std.debug.print("enabling module {s} {any}\n", .{ module, enable });
return; return;
} }
} }

View File

@ -0,0 +1,67 @@
import os
import argparse
import subprocess
orig_dir = os.path.abspath(os.path.dirname(__file__))
def getCommitHash():
commit_hash = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD'],
text=True
).strip()
print(commit_hash)
dryRun = False
def run(cmd):
global dryRun
print(" ".join(cmd))
if not dryRun:
print(subprocess.check_output(cmd, shell=True).decode())
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'])
if deploy is not None:
def makePackage(target, branch, deploy, tag):
host = '$BACKLOG_INFRA_DEPLOY_HOST'
path = '$BACKLOG_INFRA_DEPLOY_PATH'
if os.name == 'nt':
host = '%BACKLOG_INFRA_DEPLOY_HOST%'
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(['scp', packageFile, f'{host}:{path}/{branch}/{deploy}/{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}'])
makePackage(target, branch, deploy, 'debug')
makePackage(target, branch, deploy, 'release')
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('--branch', default="manual", help='branch name')
parser.add_argument('--dry', action="store_true", help='dont run anything')
parser.add_argument('target', help='required')
args = parser.parse_args()
if args.dry:
dryRun = True
buildAndPackage(args.branch, args.target, args.deploy)