Build via Script.
This commit is contained in:
@@ -27,15 +27,14 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build Unity Player (${{ matrix.platform }})
|
||||
env:
|
||||
UNITY_BUILD_OUTPUT_PATH: "${{ github.workspace }}/Builds/${{ matrix.platform }}/${{ matrix.output_file }}"
|
||||
run: |
|
||||
set -e
|
||||
REPO_ROOT="$(pwd)"
|
||||
PROJECT_PATH="${REPO_ROOT}/${UNITY_PROJECT_SUBDIR}"
|
||||
BUILD_DIR="${REPO_ROOT}/Builds/${{ matrix.platform }}"
|
||||
|
||||
echo "REPO_ROOT: $REPO_ROOT"
|
||||
echo "PROJECT_PATH: $PROJECT_PATH"
|
||||
echo "BUILD_DIR: $BUILD_DIR"
|
||||
LOG_FILE="${BUILD_DIR}/build-${{ matrix.platform }}.log"
|
||||
|
||||
mkdir -p "$BUILD_DIR"
|
||||
|
||||
@@ -44,14 +43,15 @@ jobs:
|
||||
-quit \
|
||||
-projectPath "$PROJECT_PATH" \
|
||||
-buildTarget "${{ matrix.build_target }}" \
|
||||
-customBuildPath "$BUILD_DIR/${{ matrix.output_file }}" \
|
||||
-logFile "Builds/unity-${{ matrix.platform }}.log"
|
||||
-customBuildPath "$UNITY_BUILD_OUTPUT_PATH" \
|
||||
-executeMethod CommandLineBuild.BuildFromCli \
|
||||
-logFile "$LOG_FILE"
|
||||
|
||||
- name: Print Unity Logs on Failure
|
||||
if: failure()
|
||||
run: |
|
||||
echo "=== Custom Log ==="
|
||||
cat "Builds/${{ matrix.platform }}/unity-build.log" 2>/dev/null || echo "Kein Custom-Log vorhanden"
|
||||
echo "=== Build Log ==="
|
||||
cat "Builds/${{ matrix.platform }}/build-${{ matrix.platform }}.log" 2>/dev/null || echo "Kein Build-Log vorhanden"
|
||||
echo "=== Unity Editor.log ==="
|
||||
tail -n 150 "$HOME/.config/unity3d/Unity/Editor.log" 2>/dev/null || echo "Kein Editor.log vorhanden"
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
public static class CommandLineBuild
|
||||
{
|
||||
public static void BuildFromCli()
|
||||
{
|
||||
string buildPath = Environment.GetEnvironmentVariable("UNITY_BUILD_OUTPUT_PATH");
|
||||
if (string.IsNullOrWhiteSpace(buildPath))
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
int idx = Array.IndexOf(args, "-customBuildPath");
|
||||
if (idx >= 0 && idx + 1 < args.Length)
|
||||
{
|
||||
buildPath = args[idx + 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(buildPath))
|
||||
{
|
||||
Debug.LogError("Kein Build-Ausgabepfad angegeben.");
|
||||
EditorApplication.Exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
string[] scenes = EditorBuildSettings.scenes
|
||||
.Where(s => s.enabled)
|
||||
.Select(s => s.path)
|
||||
.ToArray();
|
||||
|
||||
if (scenes.Length == 0)
|
||||
{
|
||||
Debug.LogError("Keine aktivierten Szenen in Build Settings gefunden!");
|
||||
EditorApplication.Exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
BuildReport report = BuildPipeline.BuildPlayer(
|
||||
scenes,
|
||||
buildPath,
|
||||
EditorUserBuildSettings.activeBuildTarget,
|
||||
BuildOptions.None
|
||||
);
|
||||
|
||||
if (report.summary.result != BuildResult.Succeeded)
|
||||
{
|
||||
Debug.LogError($"Build fehlgeschlagen: {report.summary.result}");
|
||||
EditorApplication.Exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user