Skip to content

Commit

Permalink
here goes nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
drewcassidy committed Sep 15, 2024
1 parent 11a852e commit 3353cf0
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 26 deletions.
22 changes: 0 additions & 22 deletions .github/actions/build-assetbundle/action.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ ARG UNITY_VERSION=2019.4.18f1
# Source from UnityCI's prebuild unity editor containers
FROM unityci/editor:${UNITY_VERSION}-windows-mono-3

RUN apt update
RUN apt install -y dotnet-sdk-8.0

#Copy entire KSPBuildTools repo into container
COPY ./ /KSPBuildTools

# Code file to execute when the docker container starts up (`build-assetbundle.sh`)
ENTRYPOINT ["/KSPBuildTools/build-assetbundle.sh", "--editor", "unity-editor"]
ENTRYPOINT ["bash"]
55 changes: 55 additions & 0 deletions .github/actions/build-assetbundles/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Assetbundle
description: Build an assetbundle

inputs:
unity-version:
description: Full unity version name to build with. e.g. 2019.4.18f1
default: '2019.4.18f1'

project-dir:
description: Location of the Unity project root (The folder that contains `Assets`) *relative to the github workspace*
default: .

assetbundle-dir:
description: Destination for built assetbundles

runs:
using: composite
steps:
- name: Build Docker Container
shell: bash
run: |
docker build --platform linux/amd64 --tag build-assetbundle --file ${{ github.action_path }}/Dockerfile --build-arg UNITY_VERSION=${{inputs.unity-version}} .
working-directory: ${{ github.action_path }}/../../..

- name: Start Docker Container
shell: bash
run: >
docker run --name build-assetbundle
-d -i -t
--volume ${{ github.workspace }}:/github/workspace
build-assetbundle
- name: Copy editor tools into project
shell: bash
run: |
mkdir /github/workspace/${{ inputs.project-dir }}/Assets/KSPBuildTools
docker exec -d build-assetbundle cp /KSPBuildTools/Editor /github/workspace/${{ inputs.project-dir }}/Editor
- name: Run assetbundle build
shell: bash
run: >
docker exec -d build-assetbundle
unity-editor
-batchmode
-nographics
-projectPath /github/workspace/${{ inputs.project-dir }}
-executeMethod AssetBundleBuilder.BuildBundles
-assetbundlePath /github/workspace/${{ inputs.assetbundle-dir }}
-quit
- name: Shutdown Docker Container
shell: bash
run: docker stop build-assetbundle


File renamed without changes.
15 changes: 14 additions & 1 deletion .github/workflows/internal-test-assetbundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/build-assetbundle
- uses: actions/checkout@v4
with:
repository: 'https://github.com/LGhassen/Deferred.git'
path: 'Deferred'

- uses: ./.github/actions/build-assetbundle
with:
project-dir: 'Deferred/shaders/DeferredKSPShaders'
assetbundle-dir: 'Bundle'

- uses: actions/upload-artifact@v4
with:
path: 'Bundle'
name: assetbundle
18 changes: 16 additions & 2 deletions Editor/AssetBundleBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
using System;
using UnityEditor;

namespace KSPBuildTools.Editor {
public class AssetBundleBuilder {
public class AssetBundleBuilder
{
public static void BuildBundles()
{
string[] args = Environment.GetCommandLineArgs();
string path = "";
string target = "";
for (int i = 0; i < args.Length; i++)
{
if(args[i] == "-assetbundlePath")
{
path = args[i + 1];
}
}

BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.StandaloneWindows64);
}
}
1 change: 1 addition & 0 deletions KSPBuildTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</PropertyGroup>

<ItemGroup>
<None Include=".github\actions\build-assetbundles\build-assetbundle.sh" />
<None Include="KSPCommon.props" Pack="True" PackagePath="build/KSPBuildTools.props" />
<None Include="KSPCommon.targets" Pack="True" PackagePath="build/KSPBuildTools.targets" />
<None Include="README.md" Pack="True" PackagePath="/"/>
Expand Down

0 comments on commit 3353cf0

Please sign in to comment.