mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-03 23:49:08 +08:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75aac428f1 | ||
|
|
564f7e60fd | ||
|
|
75fc07ef3c | ||
|
|
23f2c2c0fa | ||
|
|
bed2573f99 | ||
|
|
bda25a9cc1 | ||
|
|
c8b1b80829 | ||
|
|
35e88ac302 | ||
|
|
abf39fb044 | ||
|
|
5d0c1ba5c1 | ||
|
|
fb7bd5bff5 | ||
|
|
4fc0f7dd2c | ||
|
|
a017ab7c43 | ||
|
|
0558bc6213 | ||
|
|
14e59b6099 | ||
|
|
273a12eefa |
@@ -4,3 +4,4 @@
|
|||||||
# Files required for the action
|
# Files required for the action
|
||||||
!entrypoint.sh
|
!entrypoint.sh
|
||||||
!action.yml
|
!action.yml
|
||||||
|
!default-build-script
|
||||||
|
|||||||
18
.github/workflows/main.yml
vendored
18
.github/workflows/main.yml
vendored
@@ -1,5 +1,7 @@
|
|||||||
name: Actions 😎
|
name: Actions 😎
|
||||||
on: [push]
|
on:
|
||||||
|
pull_request: {}
|
||||||
|
push: { branches: [master] }
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
buildForWebGL:
|
buildForWebGL:
|
||||||
@@ -10,17 +12,22 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
# Activate license
|
||||||
|
- name: Activate license
|
||||||
|
uses: webbertakken/unity-activate@v1
|
||||||
|
env:
|
||||||
|
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||||
|
|
||||||
# Configure builder
|
# Configure builder
|
||||||
- name: Build project
|
- name: Build project
|
||||||
id: buildStep
|
id: buildStep
|
||||||
uses: ./
|
uses: ./
|
||||||
env:
|
env:
|
||||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
|
||||||
UNITY_PROJECT_PATH: test-project
|
UNITY_PROJECT_PATH: test-project
|
||||||
BUILD_NAME: TestBuild
|
BUILD_NAME: TestBuild
|
||||||
BUILD_TARGET: WebGL
|
BUILD_TARGET: WebGL
|
||||||
BUILDS_PATH: builds
|
BUILDS_PATH: builds
|
||||||
BUILD_COMMAND: ""
|
BUILD_METHOD: ""
|
||||||
|
|
||||||
# Upload distributables
|
# Upload distributables
|
||||||
- name: Upload Build
|
- name: Upload Build
|
||||||
@@ -28,3 +35,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: Build
|
name: Build
|
||||||
path: ${{ steps.buildStep.outputs.allBuildsPath }}
|
path: ${{ steps.buildStep.outputs.allBuildsPath }}
|
||||||
|
|
||||||
|
# Return license
|
||||||
|
- name: Return License
|
||||||
|
uses: webbertakken/unity-return-license@v1
|
||||||
|
if: always()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ LABEL "repository"="http://github.com/webbertakken/unity-actions"
|
|||||||
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
LABEL "homepage"="http://github.com/webbertakken/unity-actions"
|
||||||
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
LABEL "maintainer"="Webber Takken <webber@takken.io>"
|
||||||
|
|
||||||
|
ADD default-build-script /UnityBuilderAction
|
||||||
ADD entrypoint.sh /entrypoint.sh
|
ADD entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
37
README.md
37
README.md
@@ -1,6 +1,18 @@
|
|||||||
# Unity - Builder
|
# Unity - Builder
|
||||||
[](https://github.com/webbertakken/unity-builder/actions?query=branch%3Amaster+workflow%3A%22Actions+%F0%9F%98%8E%22)
|
[](https://github.com/webbertakken/unity-builder/actions?query=branch%3Amaster+workflow%3A%22Actions+%F0%9F%98%8E%22)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
GitHub Action to
|
||||||
|
[build Unity projects](https://github.com/marketplace/actions/unity-builder)
|
||||||
|
for different platforms.
|
||||||
|
|
||||||
|
Part of the
|
||||||
|
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||||
|
collection.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
[Github Action](https://github.com/features/actions)
|
[Github Action](https://github.com/features/actions)
|
||||||
to build Unity projects for different platforms.
|
to build Unity projects for different platforms.
|
||||||
|
|
||||||
@@ -30,16 +42,18 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Activate Unity in a step using the
|
||||||
|
[Unity Activate](https://github.com/marketplace/actions/unity-activate)
|
||||||
|
action.
|
||||||
|
|
||||||
Configure the builder as follows:
|
Configure the builder as follows:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Configure builder
|
# Configure builder
|
||||||
- name: Build project
|
- name: Build project
|
||||||
id: buildStep
|
id: buildStep
|
||||||
uses: webbertakken/unity-builder@v0.1 # WIP (only webgl for now)
|
uses: webbertakken/unity-builder@v0.2 # WIP (only webgl for now)
|
||||||
env:
|
env:
|
||||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
|
||||||
|
|
||||||
# Optional: Path to your project, leave blank for "./"
|
# Optional: Path to your project, leave blank for "./"
|
||||||
UNITY_PROJECT_PATH: path/to/your/project
|
UNITY_PROJECT_PATH: path/to/your/project
|
||||||
|
|
||||||
@@ -52,10 +66,13 @@ Configure the builder as follows:
|
|||||||
# Target platform for your build
|
# Target platform for your build
|
||||||
BUILD_TARGET: WebGL
|
BUILD_TARGET: WebGL
|
||||||
|
|
||||||
# Optional: <StaticBuildClass.StaticMethod>, defaults to Builder.BuildProject
|
# Optional: <StaticBuildClass.StaticMethod>
|
||||||
BUILD_COMMAND: ""
|
BUILD_METHOD: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> _**Note:** By default the enabled scenes from the
|
||||||
|
project's settings will be built._
|
||||||
|
|
||||||
You use the id to **upload your built files** like so:
|
You use the id to **upload your built files** like so:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -67,6 +84,10 @@ You use the id to **upload your built files** like so:
|
|||||||
path: ${{ steps.buildStep.outputs.allBuildsPath }}
|
path: ${{ steps.buildStep.outputs.allBuildsPath }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Return the Unity license in a final step using the
|
||||||
|
[Unity Return License](https://github.com/marketplace/actions/unity-return-license)
|
||||||
|
action.
|
||||||
|
|
||||||
Commit and push your workflow definition.
|
Commit and push your workflow definition.
|
||||||
|
|
||||||
## More actions
|
## More actions
|
||||||
@@ -74,3 +95,9 @@ Commit and push your workflow definition.
|
|||||||
Visit
|
Visit
|
||||||
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
[Unity Actions](https://github.com/webbertakken/unity-actions)
|
||||||
to find related actions for Unity.
|
to find related actions for Unity.
|
||||||
|
|
||||||
|
Feel free to contribute.
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
[MIT](./LICENSE)
|
||||||
|
|||||||
56
default-build-script/.gitignore
vendored
Normal file
56
default-build-script/.gitignore
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#
|
||||||
|
# Note: Non default ignore file, as this only tests Builder script.
|
||||||
|
#
|
||||||
|
|
||||||
|
[Ll]ibrary/
|
||||||
|
[Tt]emp/
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]uild/
|
||||||
|
[Bb]uilds/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Additional ignores
|
||||||
|
[Bb]in/
|
||||||
|
|
||||||
|
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||||
|
# [Aa]ssets/AssetStoreTools*
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.vs/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Gradle cache directory
|
||||||
|
.gradle/
|
||||||
|
|
||||||
|
# Autogenerated VS/MD/Consulo solution and project files
|
||||||
|
ExportedObj/
|
||||||
|
.consulo/
|
||||||
|
#*.csproj
|
||||||
|
*.unityproj
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.tmp
|
||||||
|
*.user
|
||||||
|
*.userprefs
|
||||||
|
*.pidb
|
||||||
|
*.booproj
|
||||||
|
*.svd
|
||||||
|
*.pdb
|
||||||
|
*.mdb
|
||||||
|
*.opendb
|
||||||
|
*.VC.db
|
||||||
|
|
||||||
|
# Unity3D generated meta files
|
||||||
|
*.pidb.meta
|
||||||
|
*.pdb.meta
|
||||||
|
*.mdb.meta
|
||||||
|
|
||||||
|
# Unity3D generated file on crash reports
|
||||||
|
sysinfo.txt
|
||||||
|
|
||||||
|
# Builds
|
||||||
|
*.apk
|
||||||
|
*.unitypackage
|
||||||
|
|
||||||
|
# Crashlytics generated file
|
||||||
|
crashlytics-build.properties
|
||||||
147
default-build-script/Builder.cs
Normal file
147
default-build-script/Builder.cs
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Build.Reporting;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UnityBuilderAction
|
||||||
|
{
|
||||||
|
static class Builder
|
||||||
|
{
|
||||||
|
private static string EOL = Environment.NewLine;
|
||||||
|
|
||||||
|
private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
|
||||||
|
{
|
||||||
|
providedArguments = new Dictionary<string, string>();
|
||||||
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"# Parsing settings #{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"{EOL}"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Extract flags with optional values
|
||||||
|
for (int current = 0, next = 1; current < args.Length; current++, next++) {
|
||||||
|
// Parse flag
|
||||||
|
bool isFlag = args[current].StartsWith("-");
|
||||||
|
if (!isFlag) continue;
|
||||||
|
string flag = args[current].TrimStart('-');
|
||||||
|
|
||||||
|
// Parse optional value
|
||||||
|
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
|
||||||
|
string value = flagHasValue ? args[next].TrimStart('-') : "";
|
||||||
|
|
||||||
|
// Assign
|
||||||
|
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
|
||||||
|
providedArguments.Add(flag, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, string> GetValidatedOptions()
|
||||||
|
{
|
||||||
|
ParseCommandLineArguments(out var validatedOptions);
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("projectPath", out var projectPath)) {
|
||||||
|
Console.WriteLine("Missing argument -projectPath");
|
||||||
|
EditorApplication.Exit(110);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("buildTarget", out var buildTarget)) {
|
||||||
|
Console.WriteLine("Missing argument -buildTarget");
|
||||||
|
EditorApplication.Exit(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) {
|
||||||
|
EditorApplication.Exit(121);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("customBuildPath", out var customBuildPath)) {
|
||||||
|
Console.WriteLine("Missing argument -customBuildPath");
|
||||||
|
EditorApplication.Exit(130);
|
||||||
|
}
|
||||||
|
|
||||||
|
string defaultCustomBuildName = "TestBuild";
|
||||||
|
if (!validatedOptions.TryGetValue("customBuildName", out var customBuildName)) {
|
||||||
|
Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
||||||
|
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
||||||
|
}
|
||||||
|
else if (customBuildName == "") {
|
||||||
|
Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
||||||
|
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return validatedOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BuildProject()
|
||||||
|
{
|
||||||
|
// Gather values from args
|
||||||
|
var options = GetValidatedOptions();
|
||||||
|
|
||||||
|
// Gather values from project
|
||||||
|
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
||||||
|
|
||||||
|
// Define BuildPlayer Options
|
||||||
|
var buildOptions = new BuildPlayerOptions {
|
||||||
|
scenes = scenes,
|
||||||
|
locationPathName = options["customBuildPath"],
|
||||||
|
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Perform build
|
||||||
|
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
||||||
|
|
||||||
|
// Summary
|
||||||
|
BuildSummary summary = buildReport.summary;
|
||||||
|
ReportSummary(summary);
|
||||||
|
|
||||||
|
// Result
|
||||||
|
BuildResult result = summary.result;
|
||||||
|
ExitWithResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ReportSummary(BuildSummary summary)
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
$"{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"# Build results #{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"{EOL}" +
|
||||||
|
$"Duration: {summary.totalTime.ToString()}{EOL}" +
|
||||||
|
$"Warnings: {summary.totalWarnings.ToString()}{EOL}" +
|
||||||
|
$"Errors: {summary.totalErrors.ToString()}{EOL}" +
|
||||||
|
$"Size: {summary.totalSize.ToString()} bytes{EOL}" +
|
||||||
|
$"{EOL}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ExitWithResult(BuildResult result)
|
||||||
|
{
|
||||||
|
if (result == BuildResult.Succeeded) {
|
||||||
|
Console.WriteLine("Build succeeded!");
|
||||||
|
EditorApplication.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == BuildResult.Failed) {
|
||||||
|
Console.WriteLine("Build failed!");
|
||||||
|
EditorApplication.Exit(101);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == BuildResult.Cancelled) {
|
||||||
|
Console.WriteLine("Build cancelled!");
|
||||||
|
EditorApplication.Exit(102);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == BuildResult.Unknown) {
|
||||||
|
Console.WriteLine("Build result is unknown!");
|
||||||
|
EditorApplication.Exit(103);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
default-build-script/Builder.cs.meta
Normal file
3
default-build-script/Builder.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc057061ce9f406aa6b57a62d67fe9c0
|
||||||
|
timeCreated: 1575145310
|
||||||
35
default-build-script/Properties/AssemblyInfo.cs
Normal file
35
default-build-script/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("UnityBuilderAction")]
|
||||||
|
[assembly: AssemblyDescription("Builder script for Unity Builder action")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("UnityBuilderAction")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2019-present")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("031F5EE1-35CE-4F77-975A-7E326F898185")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
57
default-build-script/UnityBuilderAction.csproj
Normal file
57
default-build-script/UnityBuilderAction.csproj
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{031F5EE1-35CE-4F77-975A-7E326F898185}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>UnityBuilderAction</RootNamespace>
|
||||||
|
<AssemblyName>UnityBuilderAction</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<HintPath>..\..\..\Program Files\Unity\2019.2.11f1\Editor\Data\Managed\UnityEditor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>C:\Program Files\Unity\2019.2.11f1\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Builder.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#
|
|
||||||
# Set license file path
|
|
||||||
#
|
|
||||||
|
|
||||||
LICENSE_FILE_PATH=UnityLicenseFile.ulf
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set project path
|
# Set project path
|
||||||
#
|
#
|
||||||
@@ -23,14 +17,6 @@ fi
|
|||||||
#
|
#
|
||||||
# Set the builds target platform;
|
# Set the builds target platform;
|
||||||
#
|
#
|
||||||
# possible options are:
|
|
||||||
#
|
|
||||||
# Standalone, Win, Win64, OSXUniversal,
|
|
||||||
# Linux64, iOS, Android, WebGL, XboxOne,
|
|
||||||
# PS4, WindowsStoreApps, Switch, tvOS
|
|
||||||
#
|
|
||||||
# New options array:
|
|
||||||
#
|
|
||||||
# Web: WebGL
|
# Web: WebGL
|
||||||
# Desktop: StandaloneOSX, StandaloneWindows, StandaloneWindows64, StandaloneLinux64
|
# Desktop: StandaloneOSX, StandaloneWindows, StandaloneWindows64, StandaloneLinux64
|
||||||
# Console: PS4, XboxOne, Switch
|
# Console: PS4, XboxOne, Switch
|
||||||
@@ -61,48 +47,42 @@ CURRENT_BUILD_PATH=$BUILDS_PATH/$BUILD_TARGET
|
|||||||
CURRENT_BUILD_FULL_PATH=$BUILDS_FULL_PATH/$BUILD_TARGET
|
CURRENT_BUILD_FULL_PATH=$BUILDS_FULL_PATH/$BUILD_TARGET
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set the build command, must reference one of:
|
# Set the build method, must reference one of:
|
||||||
#
|
#
|
||||||
# - <NamespaceName.ClassName.MethodName>
|
# - <NamespaceName.ClassName.MethodName>
|
||||||
# - <ClassName.MethodName>
|
# - <ClassName.MethodName>
|
||||||
#
|
#
|
||||||
# For example: `BuildCommand.PerformBuild`
|
# For example: `BuildCommand.PerformBuild`
|
||||||
#
|
#
|
||||||
# The method must be defined static
|
# The method must be declared static and placed in project/Assets/Editor
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -z "$BUILD_COMMAND" ]; then
|
if [ -z "$BUILD_METHOD" ]; then
|
||||||
# TODO - copy Builder class from root
|
# User has not provided their own build command.
|
||||||
EXECUTE_CUSTOM_METHOD="-executeMethod Builder.BuildProject"
|
#
|
||||||
|
# Use the script from this action which builds the scenes that are enabled in
|
||||||
|
# the project.
|
||||||
|
#
|
||||||
|
# Create Editor directory if it does not exist
|
||||||
|
mkdir -p $UNITY_PROJECT_PATH/Assets/Editor/
|
||||||
|
# Copy the build script of Unity Builder action
|
||||||
|
cp -r /UnityBuilderAction $UNITY_PROJECT_PATH/Assets/Editor/
|
||||||
|
# Set the Build method to that of UnityBuilder Action
|
||||||
|
BUILD_METHOD="UnityBuilderAction.Builder.BuildProject"
|
||||||
|
# Verify recursive paths
|
||||||
|
ls -Ralph $UNITY_PROJECT_PATH/Assets/Editor/
|
||||||
|
#
|
||||||
else
|
else
|
||||||
EXECUTE_CUSTOM_METHOD="-executeMethod $BUILD_COMMAND"
|
# User has provided their own build method.
|
||||||
|
# Assume they also bring their own script.
|
||||||
|
#
|
||||||
|
echo "User set build method to $BUILD_METHOD."
|
||||||
|
#
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
# Set build method to execute as flag + argument
|
||||||
# Copy license file from Github variables
|
EXECUTE_BUILD_METHOD="-executeMethod $BUILD_METHOD"
|
||||||
#
|
|
||||||
|
|
||||||
echo "$UNITY_LICENSE" | tr -d '\r' > $LICENSE_FILE_PATH
|
|
||||||
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_lic.ulf
|
|
||||||
# TODO - test if this line has any effect
|
|
||||||
echo "$UNITY_LICENSE" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_v2019.x.ulf
|
|
||||||
|
|
||||||
#
|
|
||||||
# Activate license
|
|
||||||
#
|
|
||||||
|
|
||||||
echo "Requesting activation"
|
|
||||||
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
|
||||||
/opt/Unity/Editor/Unity \
|
|
||||||
-batchmode \
|
|
||||||
-nographics \
|
|
||||||
-logFile /dev/stdout \
|
|
||||||
-quit \
|
|
||||||
-manualLicenseFile $LICENSE_FILE_PATH
|
|
||||||
# This is expected to always exit with code 1 (both success and failure).
|
|
||||||
# Convert to exit code 0 by echoing the current exit code.
|
|
||||||
echo $?
|
|
||||||
# Exit code is now 0
|
|
||||||
|
|
||||||
# The build specification below may require Unity 2019.2.11f1 or later (not tested below).
|
# The build specification below may require Unity 2019.2.11f1 or later (not tested below).
|
||||||
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
||||||
@@ -155,7 +135,7 @@ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
|||||||
-buildTarget "$BUILD_TARGET" \
|
-buildTarget "$BUILD_TARGET" \
|
||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CURRENT_BUILD_FULL_PATH" \
|
-customBuildPath "$CURRENT_BUILD_FULL_PATH" \
|
||||||
$EXECUTE_CUSTOM_METHOD
|
$EXECUTE_BUILD_METHOD
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
BUILD_EXIT_CODE=$?
|
BUILD_EXIT_CODE=$?
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6f4ffa2938b3439f92f3caaf6a8055cc
|
|
||||||
timeCreated: 1575145041
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEditor.Build.Reporting;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
static class Builder
|
|
||||||
{
|
|
||||||
private static string EOL = Environment.NewLine;
|
|
||||||
|
|
||||||
private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
|
|
||||||
{
|
|
||||||
providedArguments = new Dictionary<string, string>();
|
|
||||||
string[] args = Environment.GetCommandLineArgs();
|
|
||||||
|
|
||||||
Console.WriteLine(
|
|
||||||
$"{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"# Parsing settings #{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"{EOL}"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Extract flags with optional values
|
|
||||||
for (int current = 0, next = 1; current < args.Length; current++, next++) {
|
|
||||||
// Parse flag
|
|
||||||
bool isFlag = args[current].StartsWith("-");
|
|
||||||
if (!isFlag) continue;
|
|
||||||
string flag = args[current].TrimStart('-');
|
|
||||||
|
|
||||||
// Parse optional value
|
|
||||||
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
|
|
||||||
string value = flagHasValue ? args[next].TrimStart('-') : "";
|
|
||||||
|
|
||||||
// Assign
|
|
||||||
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
|
|
||||||
providedArguments.Add(flag, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Dictionary<string, string> GetValidatedOptions()
|
|
||||||
{
|
|
||||||
ParseCommandLineArguments(out var validatedOptions);
|
|
||||||
|
|
||||||
if (!validatedOptions.TryGetValue("projectPath", out var projectPath)) {
|
|
||||||
Console.WriteLine("Missing argument -projectPath");
|
|
||||||
EditorApplication.Exit(110);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validatedOptions.TryGetValue("buildTarget", out var buildTarget)) {
|
|
||||||
Console.WriteLine("Missing argument -buildTarget");
|
|
||||||
EditorApplication.Exit(120);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) {
|
|
||||||
EditorApplication.Exit(121);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validatedOptions.TryGetValue("customBuildPath", out var customBuildPath)) {
|
|
||||||
Console.WriteLine("Missing argument -customBuildPath");
|
|
||||||
EditorApplication.Exit(130);
|
|
||||||
}
|
|
||||||
|
|
||||||
string defaultCustomBuildName = "TestBuild";
|
|
||||||
if (!validatedOptions.TryGetValue("customBuildName", out var customBuildName)) {
|
|
||||||
Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
|
||||||
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
|
||||||
}
|
|
||||||
else if (customBuildName == "") {
|
|
||||||
Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
|
||||||
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return validatedOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void BuildProject()
|
|
||||||
{
|
|
||||||
// Gather values from args
|
|
||||||
var options = GetValidatedOptions();
|
|
||||||
|
|
||||||
// Gather values from project
|
|
||||||
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
|
||||||
|
|
||||||
// Define BuildPlayer Options
|
|
||||||
var buildOptions = new BuildPlayerOptions {
|
|
||||||
scenes = scenes,
|
|
||||||
locationPathName = options["customBuildPath"],
|
|
||||||
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Perform build
|
|
||||||
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
|
||||||
|
|
||||||
// Summary
|
|
||||||
BuildSummary summary = buildReport.summary;
|
|
||||||
ReportSummary(summary);
|
|
||||||
|
|
||||||
// Result
|
|
||||||
BuildResult result = summary.result;
|
|
||||||
ExitWithResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ReportSummary(BuildSummary summary)
|
|
||||||
{
|
|
||||||
Console.WriteLine(
|
|
||||||
$"{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"# Build results #{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"{EOL}" +
|
|
||||||
$"Duration: {summary.totalTime.ToString()}{EOL}" +
|
|
||||||
$"Warnings: {summary.totalWarnings.ToString()}{EOL}" +
|
|
||||||
$"Errors: {summary.totalErrors.ToString()}{EOL}" +
|
|
||||||
$"Size: {summary.totalSize.ToString()} bytes{EOL}" +
|
|
||||||
$"{EOL}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ExitWithResult(BuildResult result)
|
|
||||||
{
|
|
||||||
if (result == BuildResult.Succeeded) {
|
|
||||||
Console.WriteLine("Build succeeded!");
|
|
||||||
EditorApplication.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Failed) {
|
|
||||||
Console.WriteLine("Build failed!");
|
|
||||||
EditorApplication.Exit(101);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Cancelled) {
|
|
||||||
Console.WriteLine("Build cancelled!");
|
|
||||||
EditorApplication.Exit(102);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Unknown) {
|
|
||||||
Console.WriteLine("Build result is unknown!");
|
|
||||||
EditorApplication.Exit(103);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: dc057061ce9f406aa6b57a62d67fe9c0
|
|
||||||
timeCreated: 1575145310
|
|
||||||
Reference in New Issue
Block a user