Initial Commit.
This commit is contained in:
17
unity-command/Dockerfile
Normal file
17
unity-command/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
#Arg is replaced with the desired Unity container.
|
||||
ARG IMAGE=debian:stable-slim
|
||||
FROM ${IMAGE}
|
||||
|
||||
RUN useradd -ms /bin/bash unity -u 1000
|
||||
|
||||
COPY entrypoint.sh /
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
COPY install-dotnet.sh /
|
||||
RUN bash /install-dotnet.sh
|
||||
|
||||
COPY UnityBuilder /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/UnityBuilder
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
USER unity
|
||||
BIN
unity-command/UnityBuilder
Normal file
BIN
unity-command/UnityBuilder
Normal file
Binary file not shown.
52
unity-command/action.yaml
Normal file
52
unity-command/action.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
name: unity-command
|
||||
description: "Run a Unity command using a specified version of Unity."
|
||||
inputs:
|
||||
platform:
|
||||
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
|
||||
required: true
|
||||
version:
|
||||
description: "Unity Version."
|
||||
required: true
|
||||
imageTag:
|
||||
description: "Tag to use for the temporary version of Unity. Must refer to an existing public Docker image. Must be the same is in the Dockerfile of the called action."
|
||||
required: true
|
||||
default: unityci/base:latest
|
||||
serial:
|
||||
description: "Unity license serial number. Or 'public' for a public license."
|
||||
required: true
|
||||
default: public
|
||||
email:
|
||||
description: "Unity email."
|
||||
required: true
|
||||
password:
|
||||
description: "Unity password."
|
||||
required: true
|
||||
command:
|
||||
description: "Unity command to run."
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Get Unity container name."
|
||||
id: getContainer
|
||||
uses: act/unity/unity-get-container@master
|
||||
with:
|
||||
version: ${{ inputs.version }}
|
||||
platform: ${{ inputs.platform }}
|
||||
- name: "Pull Unity container."
|
||||
run: |
|
||||
CONTAINER=${{ steps.getContainer.outputs.container }}
|
||||
|
||||
docker build -t ${{ inputs.imageTag }} --build-arg IMAGE=$CONTAINER ${{ github.action_path }}
|
||||
shell: bash
|
||||
- name: "Run Unity command."
|
||||
uses: act/unity/unity@master
|
||||
with:
|
||||
serial: ${{ inputs.serial }}
|
||||
email: ${{ inputs.email }}
|
||||
password: ${{ inputs.password }}
|
||||
command: ${{ inputs.command }}
|
||||
- name: "Remove temporary image."
|
||||
run: |
|
||||
docker image rm ${{ inputs.imageTag }}
|
||||
shell: bash
|
||||
34
unity-command/entrypoint.sh
Normal file
34
unity-command/entrypoint.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
SERIAL=$1; EMAIL=$2; PASSWORD=$3; COMMAND=$4
|
||||
DEFAULT_ARGS="-quit -logFile -"
|
||||
|
||||
rm -rf $HOME/.config/unity3d
|
||||
rm -rf /home/unity/.config/unity3d
|
||||
|
||||
#Add ssh key information for resolving packages.
|
||||
if [[ -n "$SSH_PUBLIC_KEY" && -n "$SSH_PRIVATE_KEY" ]]; then
|
||||
echo "ADDING SSH KEYS!"
|
||||
SSH_DIR="/home/$(whoami)/.ssh"
|
||||
mkdir -p $SSH_DIR
|
||||
|
||||
echo "$SSH_PUBLIC_KEY" > $SSH_DIR/id_rsa.pub
|
||||
echo "$SSH_PRIVATE_KEY" > $SSH_DIR/id_rsa
|
||||
cat << EOF > $SSH_DIR/config
|
||||
Host *
|
||||
StrictHostKeyChecking no
|
||||
EOF
|
||||
|
||||
chmod 600 $SSH_DIR/id_rsa
|
||||
chmod 644 $SSH_DIR/id_rsa.pub
|
||||
cat $SSH_DIR/config
|
||||
fi
|
||||
|
||||
#Activate Unity
|
||||
if [[ "$SERIAL" == "public" ]]; then
|
||||
unity-editor $DEFAULT_ARGS -serial $SERIAL -username $EMAIL -password $PASSWORD
|
||||
else
|
||||
UnityBuilder -i unity-editor -u $EMAIL -p $PASSWORD
|
||||
fi
|
||||
|
||||
#Run the command.
|
||||
unity-editor $DEFAULT_ARGS $COMMAND
|
||||
10
unity-command/install-dotnet.sh
Normal file
10
unity-command/install-dotnet.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
||||
dpkg -i packages-microsoft-prod.deb
|
||||
rm packages-microsoft-prod.deb
|
||||
|
||||
apt update
|
||||
apt install -y dotnet-sdk-6.0
|
||||
|
||||
#For UnityBuilder
|
||||
apt install -y chromium-browser
|
||||
34
unity-get-buildtarget/action.yaml
Normal file
34
unity-get-buildtarget/action.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: unity-get-buildtarget
|
||||
description: "Get the correct Unity build target from a provided platform."
|
||||
inputs:
|
||||
platform:
|
||||
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
|
||||
required: true
|
||||
outputs:
|
||||
buildTarget:
|
||||
description: "Unity Build Target."
|
||||
value: ${{ steps.getTarget.outputs.buildTarget }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Get Unity Build Target."
|
||||
id: getTarget
|
||||
run: |
|
||||
#Choose the correct buildTarget: https://docs.unity3d.com/Manual/EditorCommandLineArguments.html
|
||||
UNITY_PLATFORM=${{ inputs.platform }}
|
||||
UNITY_TARGET=$UNITY_PLATFORM
|
||||
|
||||
if [[ $UNITY_PLATFORM == "windows" ]]; then
|
||||
UNITY_TARGET=Win64
|
||||
elif [[ $UNITY_PLATFORM == "windows32bit" ]]; then
|
||||
UNITY_TARGET=Win
|
||||
elif [[ $UNITY_PLATFORM == "mac" ]]; then
|
||||
UNITY_TARGET=OSXUniversal
|
||||
elif [[ $UNITY_PLATFORM == "linux" ]]; then
|
||||
UNITY_TARGET=Linux64
|
||||
elif [[ $UNITY_PLATFORM == "android" ]]; then
|
||||
UNITY_TARGET=Android
|
||||
fi
|
||||
|
||||
echo "::set-output name=buildTarget::$UNITY_TARGET"
|
||||
shell: bash
|
||||
38
unity-get-container/action.yaml
Normal file
38
unity-get-container/action.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
name: unity-get-container
|
||||
description: "Get the correct Unity docker container from a provided platform."
|
||||
inputs:
|
||||
version:
|
||||
description: "Unity Version."
|
||||
required: true
|
||||
platform:
|
||||
description: "Unity Platform. Options: windows, windows32bit, mac, linux, android"
|
||||
required: true
|
||||
outputs:
|
||||
container:
|
||||
description: "Unity Docker Container"
|
||||
value: ${{ steps.getContainer.outputs.container }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Get Unity Docker Container."
|
||||
id: getContainer
|
||||
run: |
|
||||
#Choose the appropriate container from: https://hub.docker.com/r/unityci/editor
|
||||
UNITY_VERSION=${{ inputs.version }}
|
||||
UNITY_PLATFORM=${{ inputs.platform }}
|
||||
|
||||
if [[ $UNITY_PLATFORM == "windows" || $UNITY_PLATFORM == "windows32bit" ]]; then
|
||||
UNITY_PLATFORM=windows-mono-1.0.1
|
||||
elif [[ $UNITY_PLATFORM == "mac" ]]; then
|
||||
UNITY_PLATFORM=mac-mono-1.0.1
|
||||
elif [[ $UNITY_PLATFORM == "linux" ]]; then
|
||||
UNITY_PLATFORM=base-1.0.1
|
||||
UNITY_VERSION=ubuntu-$UNITY_VERSION
|
||||
elif [[ $UNITY_PLATFORM == "android" ]]; then
|
||||
UNITY_PLATFORM=$UNITY_PLATFORM-1.0.1
|
||||
fi
|
||||
|
||||
CONTAINER=unityci/editor:$UNITY_VERSION-$UNITY_PLATFORM
|
||||
|
||||
echo "::set-output name=container::$CONTAINER"
|
||||
shell: bash
|
||||
26
unity-get-version/action.yaml
Normal file
26
unity-get-version/action.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
name: unity-get-version
|
||||
description: "Get the correct Unity version from a provided project."
|
||||
inputs:
|
||||
projectPath:
|
||||
description: "Path to the Unity project."
|
||||
required: true
|
||||
default: "."
|
||||
outputs:
|
||||
projectVersion:
|
||||
description: "Unity project version."
|
||||
value: ${{ steps.getVersion.outputs.projectVersion }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Get Unity project version."
|
||||
id: getVersion
|
||||
run: |
|
||||
VERSION_KEY="m_EditorVersion"
|
||||
VERSION_FILE="ProjectSettings/ProjectVersion.txt"
|
||||
VERSION_FILE_PATH="${{ inputs.projectPath }}/$VERSION_FILE"
|
||||
|
||||
VERSION=$(grep -w $VERSION_KEY $VERSION_FILE_PATH | cut -d ':' -f2 | xargs)
|
||||
|
||||
echo "::set-output name=projectVersion::$VERSION"
|
||||
shell: bash
|
||||
|
||||
44
unity-project/action.yaml
Normal file
44
unity-project/action.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: unity-project
|
||||
description: "Run a Unity command using a project's version and a build target."
|
||||
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
|
||||
command:
|
||||
description: "Unity command to run."
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: "Get Unity Version."
|
||||
id: getVersion
|
||||
uses: act/unity/unity-get-version@master
|
||||
with:
|
||||
projectPath: ${{ inputs.projectPath }}
|
||||
- name: "Get Unity buildTarget."
|
||||
id: getTarget
|
||||
uses: act/unity/unity-get-buildtarget@master
|
||||
with:
|
||||
platform: ${{ inputs.platform }}
|
||||
- name: "Run Unity command."
|
||||
uses: act/unity/unity-command@master
|
||||
with:
|
||||
platform: ${{ inputs.platform }}
|
||||
version: ${{ steps.getVersion.outputs.projectVersion }}
|
||||
serial: ${{ inputs.serial }}
|
||||
email: ${{ inputs.email }}
|
||||
password: ${{ inputs.password }}
|
||||
command: -projectPath ${{ inputs.projectPath }} -buildTarget ${{ steps.getTarget.outputs.buildTarget }} ${{ inputs.command }}
|
||||
24
unity/action.yaml
Normal file
24
unity/action.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
name: unity
|
||||
description: "Register Unity with the provided license and run a Unity command."
|
||||
inputs:
|
||||
serial:
|
||||
description: "Unity license serial number."
|
||||
required: true
|
||||
email:
|
||||
description: "Unity email."
|
||||
required: true
|
||||
password:
|
||||
description: "Unity password."
|
||||
required: true
|
||||
command:
|
||||
description: "Unity command to run."
|
||||
required: false
|
||||
runs:
|
||||
using: docker
|
||||
#This is a base "mock" image which is replaced by the correct image in the "unity-command" action at runtime.
|
||||
image: docker://unityci/base:latest
|
||||
args:
|
||||
- ${{ inputs.serial }}
|
||||
- ${{ inputs.email }}
|
||||
- ${{ inputs.password }}
|
||||
- ${{ inputs.command }}
|
||||
Reference in New Issue
Block a user