106 lines
3.6 KiB
YAML
106 lines
3.6 KiB
YAML
name: unity-project-cached
|
|
description: "Run a Unity command using a project's version and a build target. Cache the library folder."
|
|
inputs:
|
|
projectPath:
|
|
description: "Path to the Unity project."
|
|
required: true
|
|
default: "."
|
|
platform:
|
|
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
|
|
required: true
|
|
serial:
|
|
description: "Unity license serial number."
|
|
required: true
|
|
email:
|
|
description: "Unity email."
|
|
required: true
|
|
password:
|
|
description: "Unity password."
|
|
required: true
|
|
executeMethod:
|
|
description: "Unity method to call."
|
|
required: false
|
|
command:
|
|
description: "Additional unity commands."
|
|
required: false
|
|
buildOnCacheHit:
|
|
description: "Whether or not to build if a cache was found. Default: true"
|
|
required: false
|
|
default: "true"
|
|
sshPublicKey:
|
|
description: "Public SSH key to use for git package restoration."
|
|
required: false
|
|
sshPrivateKey:
|
|
description: "Private SSH key to use for git package restoration."
|
|
required: false
|
|
cacheSuffix:
|
|
description: "Suffix or hash to use for the cache key."
|
|
required: false
|
|
default: ${{ github.sha }}
|
|
cachePrefix:
|
|
description: "Prefix to use for the cache key."
|
|
required: false
|
|
default: unity-library
|
|
releaseBranch:
|
|
description: "Release name to use for the middle of the cache key if an exact release match was not found."
|
|
required: false
|
|
default: release
|
|
cachePath:
|
|
description: "Cache path. Default: Library"
|
|
required: false
|
|
default: Library
|
|
outputs:
|
|
cacheChanged:
|
|
description: "Whether or not the cache was changed."
|
|
value: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: "Get full cache key and build command."
|
|
id: command
|
|
run: |
|
|
# Get the full cache id.
|
|
echo "key=${{ inputs.cachePrefix }}-${{ github.ref_name }}-${{ inputs.cacheSuffix }}" >> "$GITHUB_OUTPUT"
|
|
# Get the build command.
|
|
COMMAND="${{ inputs.command }}"
|
|
if [[ -n "${{ inputs.executeMethod }}" ]]; then
|
|
COMMAND="$COMMAND -executeMethod ${{ inputs.executeMethod }}"
|
|
fi
|
|
echo "command=$COMMAND" >> "$GITHUB_OUTPUT"
|
|
shell: bash
|
|
- name: "Check if cache exists."
|
|
if: ${{ !env.ACT }}
|
|
id: check-cache
|
|
uses: actions/cache/restore@v3
|
|
with:
|
|
path: ${{ inputs.cachePath }}
|
|
key: ${{ steps.command.outputs.key }}
|
|
lookup-only: true
|
|
- name: "Restore Library from Cache."
|
|
if: ${{ !env.ACT && ( inputs.buildOnCacheHit == 'true' || steps.check-cache.outputs.cache-hit != 'true' ) }}
|
|
uses: actions/cache/restore@v3
|
|
with:
|
|
path: ${{ inputs.cachePath }}
|
|
key: ${{ steps.command.outputs.key }}
|
|
restore-keys: |
|
|
${{ inputs.cachePrefix }}-${{ github.ref_name }}
|
|
${{ inputs.cachePrefix }}-${{ inputs.releaseBranch }}
|
|
${{ inputs.cachePrefix }}
|
|
- name: "Build project."
|
|
if: ${{ inputs.buildOnCacheHit == 'true' || steps.check-cache.outputs.cache-hit != 'true' }}
|
|
uses: act/common/unity/unity-project@master
|
|
with:
|
|
platform: ${{ inputs.platform }}
|
|
serial: ${{ inputs.serial }}
|
|
email: ${{ inputs.email }}
|
|
password: ${{ inputs.password }}
|
|
sshPublicKey: ${{ inputs.sshPublicKey }}
|
|
sshPrivateKey: ${{ inputs.sshPrivateKey }}
|
|
command: ${{ steps.command.outputs.command }}
|
|
- name: "Upload Library to Cache."
|
|
if: ${{ !env.ACT && steps.check-cache.outputs.cache-hit != 'true' }}
|
|
uses: actions/cache/save@v3
|
|
with:
|
|
path: ${{ inputs.cachePath }}
|
|
key: ${{ steps.command.outputs.key }}
|