Skip to content

Commit

Permalink
CI and Unity exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Apr 5, 2020
1 parent b27760b commit 4983386
Show file tree
Hide file tree
Showing 10 changed files with 1,033 additions and 159 deletions.
76 changes: 75 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,53 @@ executors:
environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NUGET_XMLDOC_MODE: skip
unity:
# https://hub.docker.com/r/gableroux/unity3d/tags
parameters:
version: {type: string}
docker:
- image: gableroux/unity3d:<< parameters.version >>
go:
docker:
- image: circleci/golang
commands:
unity_activate:
parameters:
unity_version: {type: string}
unity_license: {type: string}
steps:
# get activation file, if fail to activate unity, use this key and activate from https://license.unity3d.com/manual
- run: apt update && apt install libunwind8 -y
- run: /opt/Unity/Editor/Unity -quit -batchmode -nographics -logFile -createManualActivationFile || exit 0
- store_artifacts:
path: Unity_v<< parameters.unity_version >>.alf
destination: /Unity_v<< parameters.unity_version >>.alf
# get from UNITY_LICENSE envvar(base64 encoded(cat foo.ulf | base64 )), this file is generated from above manual activation
- run: echo << parameters.unity_license >> | base64 -di >> .circleci/Unity.ulf
- run: /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -manualLicenseFile .circleci/Unity.ulf || exit 0
jobs:
# create package for Unity
build-unity:
parameters:
unity_version: {type: string}
unity_license: {type: string}
executor:
name: unity
version: << parameters.unity_version >>
steps:
- run: apt update && apt install git -y
- checkout
- unity_activate:
unity_version: << parameters.unity_version >>
unity_license: << parameters.unity_license >>
- run:
name: Export unitypackage
command: /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
working_directory: src/ZLogger.Unity
- persist_to_workspace:
root: ./src/ZLogger.Unity/
paths:
- ./ZLogger.Unity.unitypackage
build-test:
executor: dotnet
steps:
Expand All @@ -24,6 70,17 @@ jobs:
path: ./src/ZLogger/bin/Release
destination: ./ZLogger/
- run: dotnet nuget push ./src/ZLogger/bin/Release/ZLogger.${CIRCLE_TAG}.nupkg -s https://www.nuget.org/api/v2/package -k ${NUGET_KEY}
# upload to github by ghr
upload-github:
executor: go
steps:
- attach_workspace:
at: .
- run: go get github.com/tcnksm/ghr
- run: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} ${CIRCLE_TAG} .
- store_artifacts:
path: ZLogger.Unity.unitypackage
destination: ZLogger.Unity.unitypackage
workflows:
version: 2
build-and-push:
Expand All @@ -32,10 89,27 @@ workflows:
filters:
tags:
only: /.*/
- build-unity:
unity_version: 2019.1.2f1
unity_license: ${UNITY_LICENSE_2019_1}
filters:
tags:
only: /^\d\.\d\.\d.*/
branches:
ignore: /.*/
- build-push:
filters:
tags:
only: /^\d\.\d\.\d.*/
branches:
ignore: /.*/
context: cysharp-nuget
context: cysharp-nuget
- upload-github:
requires:
- build-unity
- build-push
filters:
tags:
only: /^\d\.\d\.\d.*/
branches:
ignore: /.*/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@ ZLogger
===
[![CircleCI](https://circleci.com/gh/Cysharp/ZLogger.svg?style=svg)](https://circleci.com/gh/Cysharp/ZLogger)

**Z**ero Allocation Text/Strcutured **Logger** for .NET Core, built on top of a Microsoft.Extensions.Logging.
**Z**ero Allocation Text/Strcutured **Logger** for .NET Core and Unity, built on top of a Microsoft.Extensions.Logging.

Logging to standard output is very important, especially in the age of containerization, but traditionally its performance has been very slow, however anyone no concerned about it. It also supports both text logs and structured logs, which are important in cloud.

Expand Down
722 changes: 722 additions & 0 deletions src/ZLogger.Unity/Assembly-CSharp-Editor.csproj

Large diffs are not rendered by default.

321 changes: 165 additions & 156 deletions src/ZLogger.Unity/Assembly-CSharp.csproj

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/ZLogger.Unity/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions src/ZLogger.Unity/Assets/Editor/PackageExporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 1,43 @@
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

public static class PackageExporter
{
[MenuItem("Tools/Export Unitypackage")]
public static void Export()
{
var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION");

// configure
var root = "Scripts/ZLogger";
var fileName = string.IsNullOrEmpty(version) ? "ZLogger.Unity.unitypackage" : $"ZLogger.Unity.{version}.unitypackage";
var exportPath = "./" fileName;

var path = Path.Combine(Application.dataPath, root);
var assets = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)
.Where(x => Path.GetExtension(x) == ".cs" || Path.GetExtension(x) == ".meta" || Path.GetExtension(x) == ".asmdef")
.Where(x => Path.GetFileNameWithoutExtension(x) != "_InternalVisibleTo")
.Select(x => "Assets" x.Replace(Application.dataPath, "").Replace(@"\", "/"))
.ToArray();

var netStandardsAsset = Directory.EnumerateFiles(Path.Combine(Application.dataPath, "Plugins/"), "*", SearchOption.AllDirectories)
.Select(x => "Assets" x.Replace(Application.dataPath, "").Replace(@"\", "/"))
.ToArray();

assets = assets.Concat(netStandardsAsset).ToArray();

UnityEngine.Debug.Log("Export below files" Environment.NewLine string.Join(Environment.NewLine, assets));

var dir = new FileInfo(exportPath).Directory;
if (!dir.Exists) dir.Create();
AssetDatabase.ExportPackage(
assets,
exportPath,
ExportPackageOptions.Default);

UnityEngine.Debug.Log("Export complete: " Path.GetFullPath(exportPath));
}
}
11 changes: 11 additions & 0 deletions src/ZLogger.Unity/Assets/Editor/PackageExporter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/ZLogger.Unity/ZLogger.Unity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuntimeUnitTestToolkit", "R
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{4645EC22-ED36-654C-D8EB-D22E1B77FEA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{4B44454A-C82A-35BF-D0F3-ACC101B9FC07}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -31,6 33,10 @@ Global
{4645EC22-ED36-654C-D8EB-D22E1B77FEA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4645EC22-ED36-654C-D8EB-D22E1B77FEA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4645EC22-ED36-654C-D8EB-D22E1B77FEA8}.Release|Any CPU.Build.0 = Release|Any CPU
{4B44454A-C82A-35BF-D0F3-ACC101B9FC07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B44454A-C82A-35BF-D0F3-ACC101B9FC07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B44454A-C82A-35BF-D0F3-ACC101B9FC07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B44454A-C82A-35BF-D0F3-ACC101B9FC07}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added src/ZLogger.Unity/ZLogger.Unity.unitypackage
Binary file not shown.
3 changes: 2 additions & 1 deletion src/ZLogger/Entries/FormatLogEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 1,5 @@
using Cysharp.Text;
#pragma warning disable CS8601
using Cysharp.Text;
using System;
using System.Buffers;
using System.Collections.Concurrent;
Expand Down

0 comments on commit 4983386

Please sign in to comment.