Build Assetbundles#

action build-assetbundles#

Build a Unity assetbundle

Example

- uses: KSPModdingLibs/KSPBuildTools/.github/actions/build-assetbundles@1.1.1
  with:
    project-dir: .

Inputs

input unity-version#
Default:
2019.4.18f1

Full unity version name to build with. e.g. 2019.4.18f1

input project-dir#

Location of the Unity project root (The folder that contains Assets) relative to the github workspace

input asset-files#

Glob of assets to bundle. Mutually exclusive with project-dir

input assetbundle-name#

Name of the assetbundle to generate. Mutually exclusive with project-dir

input output-dir#
Default:
Bundle

Destination for built assetbundles

input build-method#
Default:
KSPBuildTools.AssetBundleBuilder.BuildBundles

Method to call to build the assetbundles. Uses a builtin build script with sensible values by default

Environment Variables

env UNITY_LICENSE#

The contents of your Unity license file. Store this as a secret

env UNITY_EMAIL#

The address used for your Unity account

env UNITY_PASSWORD#

The password for your Unity account. Store this as a secret

Usage#

Activation#

The Unity editor requires a login to function, even with the free edition. You will have to make some repository secrets in order to allow Unity to function. Follow the instructions in the GameCI documentation to set these up.

Using a Unity project#

If your repo has a complete Unity project already checked in, you can point the action at it and have it build all your defined asset bundles.

- uses: 
    KSPModdingLibs/KSPBuildTools/docs/.github/actions/build-assetbundles@1.1.1
  with:
    project-dir: MyUnityProject
  env:
    UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
    UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}

Using a list of assets#

Alternatively, you can give the action an assetbundle name and a list of assets to compile, and it will create a temporary project in order to compile them

- uses: 
    KSPModdingLibs/KSPBuildTools/docs/.github/actions/build-assetbundles@1.1.1
  with:
    assetbundle-name: mybundle.shab
    asset-files: MyAssets/*.shader MyAssets/*.cginc
  env:
    UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
    UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
    UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}

Build Method#

By default, this action will use the KSPBuildTools.KSPBuildTools.AssetBundleBuilder.BuildBundles build method. This function calls on the Unity build pipeline to build your assetbundles. If you need, you can provide your own custom build function and call it with the build-method input.