Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
CI CDようにビルドパイプラインを集背い
Browse files Browse the repository at this point in the history
  • Loading branch information
sakastudio committed Aug 22, 2023
1 parent 1a69f1b commit b637ec6
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions Assets/Scripts/Editor/BuildWithServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using GameConst;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;


Expand All @@ -11,18 +12,26 @@ public class BuildWithServer
[MenuItem("moorestech/WindowsBuild")]
public static void WindowsBuild()
{
Pipeline(BuildTarget.StandaloneWindows64);
Pipeline(BuildTarget.StandaloneWindows64,false);
}
[MenuItem("moorestech/LinuxBuild")]
public static void LinuxBuild()
{
Pipeline(BuildTarget.StandaloneLinux64);
Pipeline(BuildTarget.StandaloneLinux64,false);
}

#region from Github Action
public static void WindowsBuildFromGithubAction()
{
Pipeline(BuildTarget.StandaloneWindows64,true);
}
public static void LinuxBuildFromGithubAction()
{
Pipeline(BuildTarget.StandaloneLinux64,true);
}
#endregion



private static void Pipeline(BuildTarget buildTarget)
private static void Pipeline(BuildTarget buildTarget,bool isErrorExit)
{
var playerPrefsKey = OutputPathKey + buildTarget;
var path = EditorUtility.OpenFolderPanel("Build", PlayerPrefs.GetString(playerPrefsKey,""),
Expand All @@ -44,8 +53,29 @@ private static void Pipeline(BuildTarget buildTarget)
buildOptions.locationPathName = path + "/moorestech.exe";
buildOptions.scenes = EditorBuildSettings.scenes.Select(s => s.path).ToArray();

BuildPipeline.BuildPlayer(buildOptions);
var report = BuildPipeline.BuildPlayer(buildOptions);

EditorUtility.RevealInFinder( path );


if (isErrorExit)
{
//ビルドレポートを表示
foreach (var buildStep in report.steps)
{
var stepName = buildStep.name;
foreach (var message in buildStep.messages)
{
Debug.LogError(stepName + " : " + message.type + " : " + message.content);
}
}
if (report.summary.result == BuildResult.Failed)
{
EditorApplication.Exit(1);
}
}
}



}

0 comments on commit b637ec6

Please sign in to comment.