Skip to content

Commit c541be6

Browse files
authored
Merge pull request #69 from IShix-g/release
Release
2 parents 348f2f1 + 8b1930a commit c541be6

18 files changed

+338
-2
lines changed

.github/workflows/build-toc-generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: TOC Generation Workflow
1+
name: TOC Generation
22

33
on:
44
workflow_dispatch:
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: (Reusable) Build Package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
description: 'Git tag you want to create (e.g., 1.0.0).'
8+
required: true
9+
type: string
10+
commit-id:
11+
description: 'Commit ID for release and tag.'
12+
required: false
13+
type: string
14+
default: ''
15+
unity-version:
16+
description: 'Version of Unity to use for testing the project. Use "auto" to get from your ProjectSettings/ProjectVersion.txt. ⚠️ If testing a Unity Package, this field is required and cannot be set to "auto". https://game.ci/docs/docker/versions/'
17+
required: false
18+
type: string
19+
default: 'auto'
20+
project-path:
21+
description: 'Specify the path to your Unity project or package to be tested. The path should be relative to the root of your project.'
22+
required: false
23+
type: string
24+
default: ''
25+
builds-path:
26+
description: 'Path where the builds should be stored.'
27+
required: false
28+
type: string
29+
default: 'build'
30+
build-method:
31+
description: 'Path where the builds should be stored.'
32+
required: false
33+
type: string
34+
default: 'PackageExporter.Export'
35+
custom-parameters:
36+
description: 'Custom parameters to configure the build. https://game.ci/docs/github/builder#customparameters'
37+
required: false
38+
type: string
39+
default: ''
40+
secrets:
41+
UNITY_LICENSE:
42+
required: true
43+
UNITY_EMAIL:
44+
required: true
45+
UNITY_PASSWORD:
46+
required: true
47+
48+
jobs:
49+
print-unity-version:
50+
runs-on: ubuntu-22.04
51+
steps:
52+
- name: Print
53+
run: |
54+
unity_version=${{ inputs.unity-version }}
55+
echo "::notice title=Unity Version::$unity_version"
56+
57+
build-package:
58+
name: Build for StandaloneLinux64
59+
timeout-minutes: 20
60+
runs-on: ubuntu-22.04
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
ref: ${{ inputs.commit-id }}
65+
fetch-depth: 0
66+
lfs: true
67+
68+
- uses: actions/cache@v4
69+
with:
70+
path: Library
71+
key: Library-StandaloneLinux64
72+
restore-keys: Library-
73+
74+
- uses: game-ci/unity-builder@v4
75+
env:
76+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
77+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
78+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
79+
with:
80+
targetPlatform: StandaloneLinux64
81+
customParameters: -tag ${{ inputs.tag }} ${{ inputs.custom-parameters }}
82+
unityVersion: ${{ inputs.unity-version }}
83+
projectPath: ${{ inputs.project-path }}
84+
buildsPath: ${{ inputs.builds-path }}
85+
buildMethod: ${{ inputs.build-method }}
86+
87+
- uses: actions/upload-artifact@v4
88+
with:
89+
name: Build-StandaloneLinux64
90+
path: ${{ inputs.builds-path }}/StandaloneLinux64

.github/workflows/reusable-test-runner.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
needs: [prepare-test-modes]
6767
name: Test in ${{ matrix.testMode }}
6868
runs-on: ubuntu-22.04
69-
timeout-minutes: 20
69+
timeout-minutes: 15
7070
strategy:
7171
fail-fast: false
7272
matrix:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: (Test) Build Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
unity-version:
7+
description: 'Select the Unity version to use'
8+
required: true
9+
default: '2021.3.45f1'
10+
type: choice
11+
options:
12+
- '2021.3.45f1'
13+
- '2022.3.57f1'
14+
- '6000.0.37f1'
15+
workflow_call:
16+
inputs:
17+
unity-version:
18+
required: false
19+
type: string
20+
default: '2022.3.57f1'
21+
secrets:
22+
UNITY_LICENSE:
23+
required: true
24+
UNITY_EMAIL:
25+
required: true
26+
UNITY_PASSWORD:
27+
required: true
28+
29+
jobs:
30+
build-package:
31+
uses: ./.github/workflows/reusable-build-package.yaml
32+
secrets:
33+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
34+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
35+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
36+
with:
37+
tag: '1.0.0'
38+
unity-version: ${{ inputs.unity-version }}

Assets/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/ArgumentsParser.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// https://github.com/Cysharp/UniTask/blob/master/src/UniTask/Assets/Editor/PackageExporter.cs
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
namespace UnityBuilderAction.Input
9+
{
10+
public class ArgumentsParser
11+
{
12+
static string EOL = Environment.NewLine;
13+
static readonly string[] Secrets = { "androidKeystorePass", "androidKeyaliasName", "androidKeyaliasPass" };
14+
15+
public static Dictionary<string, string> GetValidatedOptions()
16+
{
17+
Dictionary<string, string> validatedOptions;
18+
ParseCommandLineArguments(out validatedOptions);
19+
20+
if (!validatedOptions.TryGetValue("buildsPath", out var buildsPath) || string.IsNullOrEmpty(buildsPath))
21+
{
22+
PrintErrorLog("Please pass a buildsPath to with. buildsPath: build");
23+
}
24+
25+
if (!validatedOptions.TryGetValue("tag", out var tag) || string.IsNullOrEmpty(tag))
26+
{
27+
PrintErrorLog("Please pass a tag to customParameters. customParameters: -tag 1.0.0");
28+
}
29+
30+
return validatedOptions;
31+
}
32+
33+
static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
34+
{
35+
providedArguments = new Dictionary<string, string>();
36+
string[] args = Environment.GetCommandLineArgs();
37+
38+
Console.WriteLine(
39+
EOL +
40+
"###########################" + EOL +
41+
"# Parsing settings #" + EOL +
42+
"###########################" + EOL +
43+
EOL
44+
);
45+
46+
// Extract flags with optional values
47+
for (int current = 0, next = 1; current < args.Length; current++, next++) {
48+
// Parse flag
49+
bool isFlag = args[current].StartsWith("-");
50+
if (!isFlag) continue;
51+
string flag = args[current].TrimStart('-');
52+
53+
// Parse optional value
54+
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
55+
string value = flagHasValue ? args[next].TrimStart('-') : "";
56+
bool secret = Secrets.Contains(flag);
57+
string displayValue = secret ? "*HIDDEN*" : "\"" + value + "\"";
58+
59+
// Assign
60+
Console.WriteLine("Found flag \"" + flag + "\" with value " + displayValue);
61+
providedArguments.Add(flag, value);
62+
}
63+
}
64+
65+
public static void PrintErrorLog(string msg)
66+
{
67+
if (Application.isBatchMode)
68+
{
69+
Console.WriteLine($"::error:: {msg}");
70+
EditorApplication.Exit(1);
71+
}
72+
else Debug.LogError(msg);
73+
}
74+
}
75+
}

Assets/Editor/ArgumentsParser.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/PackageExporter.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using UnityBuilderAction.Input;
7+
using UnityEditor;
8+
using UnityEngine;
9+
10+
public sealed class PackageExporter
11+
{
12+
const string _folderPath = "Assets/Plugins/TestExportPackage";
13+
const string _exportPath = "TestExportPackage_{version}.unitypackage";
14+
static string _eol = Environment.NewLine;
15+
16+
[MenuItem("Tools/Export Unitypackage")]
17+
public static void ExportTest() => Export(_folderPath, ToExportPath(_exportPath, "1.0.0"));
18+
19+
public static void Export()
20+
{
21+
var options = ArgumentsParser.GetValidatedOptions();
22+
var exportPath = "./" + options.GetValueOrDefault("buildsPath") + "/" + ToExportPath(_exportPath, options.GetValueOrDefault("tag"));
23+
Export(_folderPath, exportPath);
24+
}
25+
26+
public static void Export(string folderPath, string exportPath)
27+
{
28+
var assets = AssetDatabase.FindAssets("", new[] { folderPath })
29+
.Select(AssetDatabase.GUIDToAssetPath)
30+
.ToArray();
31+
32+
PrintLog("Export below files" + _eol + string.Join(_eol, assets));
33+
34+
AssetDatabase.ExportPackage(
35+
assets,
36+
exportPath,
37+
ExportPackageOptions.Default);
38+
39+
PrintLog("Export complete: " + Path.GetFullPath(exportPath));
40+
}
41+
42+
static string ToExportPath(string exportPath, string tag) => exportPath.Replace("{version}", tag);
43+
44+
static void PrintLog(string msg)
45+
{
46+
if (Application.isBatchMode) Console.WriteLine(msg);
47+
else Debug.Log(msg);
48+
}
49+
50+
51+
}

Assets/Editor/PackageExporter.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)