From 3353cf0cd2cb736508626a8b5eb02d487c5b8024 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sat, 14 Sep 2024 20:45:43 -0700 Subject: [PATCH] here goes nothing --- .github/actions/build-assetbundle/action.yml | 22 -------- .../Dockerfile | 5 +- .github/actions/build-assetbundles/action.yml | 55 +++++++++++++++++++ .../build-assetbundles/build-assetbundle.sh | 0 .../workflows/internal-test-assetbundle.yml | 15 ++++- Editor/AssetBundleBuilder.cs | 18 +++++- KSPBuildTools.csproj | 1 + 7 files changed, 90 insertions(+), 26 deletions(-) delete mode 100644 .github/actions/build-assetbundle/action.yml rename .github/actions/{build-assetbundle => build-assetbundles}/Dockerfile (79%) create mode 100644 .github/actions/build-assetbundles/action.yml rename build-assetbundle.sh => .github/actions/build-assetbundles/build-assetbundle.sh (100%) diff --git a/.github/actions/build-assetbundle/action.yml b/.github/actions/build-assetbundle/action.yml deleted file mode 100644 index f8e1293..0000000 --- a/.github/actions/build-assetbundle/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -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' - -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: Run Docker Container - shell: bash - run: | - docker run --volume ${{ github.workspace }}:/github/workspace build-assetbundle - diff --git a/.github/actions/build-assetbundle/Dockerfile b/.github/actions/build-assetbundles/Dockerfile similarity index 79% rename from .github/actions/build-assetbundle/Dockerfile rename to .github/actions/build-assetbundles/Dockerfile index c4db084..5d7d23c 100644 --- a/.github/actions/build-assetbundle/Dockerfile +++ b/.github/actions/build-assetbundles/Dockerfile @@ -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"] \ No newline at end of file +ENTRYPOINT ["bash"] \ No newline at end of file diff --git a/.github/actions/build-assetbundles/action.yml b/.github/actions/build-assetbundles/action.yml new file mode 100644 index 0000000..2e2e9c9 --- /dev/null +++ b/.github/actions/build-assetbundles/action.yml @@ -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 + + diff --git a/build-assetbundle.sh b/.github/actions/build-assetbundles/build-assetbundle.sh similarity index 100% rename from build-assetbundle.sh rename to .github/actions/build-assetbundles/build-assetbundle.sh diff --git a/.github/workflows/internal-test-assetbundle.yml b/.github/workflows/internal-test-assetbundle.yml index e7603a6..a83843c 100644 --- a/.github/workflows/internal-test-assetbundle.yml +++ b/.github/workflows/internal-test-assetbundle.yml @@ -13,4 +13,17 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/build-assetbundle \ No newline at end of file + - 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 diff --git a/Editor/AssetBundleBuilder.cs b/Editor/AssetBundleBuilder.cs index 597a2fc..2986d49 100644 --- a/Editor/AssetBundleBuilder.cs +++ b/Editor/AssetBundleBuilder.cs @@ -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); } } \ No newline at end of file diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index 360a7b9..5a9c5f1 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -32,6 +32,7 @@ +