forked from Conjure-Tools/unity-runner
Merge pull request 'feat-mega-image' (#1) from feat-mega-image into main
Reviewed-on: https://gitea.lachee.dev/unity/unity-runner/pulls/1
This commit is contained in:
commit
4d120fba10
@ -1,9 +1,9 @@
|
|||||||
name: Create Images
|
name: 🤓 Individual Runners
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
# push:
|
||||||
branches: [main]
|
# branches: [main]
|
||||||
paths: ['versions.txt']
|
# paths: ['versions.txt']
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
|
|||||||
50
.gitea/workflows/create-runner.yaml
Normal file
50
.gitea/workflows/create-runner.yaml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
name: 😎 Uber Runner
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- versions.txt
|
||||||
|
- dockerfiles/runner.dockerfile
|
||||||
|
- .github/workflows/create-runner.yaml
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOCKER_REGISTRY: docker.lakes.house/
|
||||||
|
UNITY_MODULES: webgl android ios mac-mono windows-mono linux-il2cpp
|
||||||
|
GAMECI_VERSION: 3
|
||||||
|
|
||||||
|
name: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.DOCKER_REGISTRY }}
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Get Unity Version
|
||||||
|
run: |
|
||||||
|
VERSION=$(head -n 1 versions.txt)
|
||||||
|
echo "UNITY_VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "Unity Version: $VERSION"
|
||||||
|
|
||||||
|
- name: Docker Build
|
||||||
|
run: .gitea/workflows/scripts/build-runner-image.sh
|
||||||
|
id: build-image
|
||||||
|
env:
|
||||||
|
UNITY_VERSION: ${{ env.UNITY_VERSION }}
|
||||||
|
UNITY_MODULES: ${{ env.UNITY_MODULES }}
|
||||||
|
GAMECI_VERSION: ${{ env.GAMECI_VERSION }}
|
||||||
|
GAMECI_OS: ubuntu
|
||||||
|
IMAGE: ${{ env.DOCKER_REGISTRY }}unityci/editor
|
||||||
|
|
||||||
|
- name: Docker Push
|
||||||
|
run: |
|
||||||
|
echo "Pushing Docker Image ${{ steps.build-image.outputs.FULL_IMAGE }}"
|
||||||
|
echo "- Image: ${{ steps.build-image.outputs.IMAGE }}"
|
||||||
|
echo "- Tag: ${{ steps.build-image.outputs.TAG }}"
|
||||||
|
docker push ${{ steps.build-image.outputs.FULL_IMAGE }}
|
||||||
2
.gitea/workflows/scripts/build-image.sh → .gitea/workflows/scripts/build-individual-image.sh
Executable file → Normal file
2
.gitea/workflows/scripts/build-image.sh → .gitea/workflows/scripts/build-individual-image.sh
Executable file → Normal file
@ -86,7 +86,7 @@ docker build \
|
|||||||
${ADDITIONAL_TAGS} \
|
${ADDITIONAL_TAGS} \
|
||||||
-t ${FULL_IMAGE} \
|
-t ${FULL_IMAGE} \
|
||||||
${DOCKER_BUILD_ARGS} \
|
${DOCKER_BUILD_ARGS} \
|
||||||
.
|
-f ./dockerfiles/individual.dockerfile .
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Docker build failed."
|
echo "Error: Docker build failed."
|
||||||
114
.gitea/workflows/scripts/build-runner-image.sh
Normal file
114
.gitea/workflows/scripts/build-runner-image.sh
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Ensure UNITY_VERSION is set, pull from arguments if not
|
||||||
|
if [ -z "${UNITY_VERSION}" ]; then
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
UNITY_VERSION=$1
|
||||||
|
else
|
||||||
|
echo "Error: UNITY_VERSION is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch the changelog and extract the changeset ID for the specified Unity version
|
||||||
|
# This is because hub doesnt remember every version of unity and uses the changset for the exact id lookup.
|
||||||
|
if [ -z "${UNITY_CHANGESET}" ]; then
|
||||||
|
echo "Warning: No changeset provided. Scraping one from the change logs."
|
||||||
|
echo "This might take a while. Use the UNITY_CHANGESET to avoid this lookup."
|
||||||
|
CHANGELOG_URL="https://unity.com/releases/editor/whats-new/${UNITY_VERSION}"
|
||||||
|
UNITY_CHANGESET=$(curl -s -r 0-500 "$CHANGELOG_URL" | grep -oP 'unityhub://(?:[0-9a-z.])+/\K([a-z0-9]+)' | head -n 1)
|
||||||
|
if [ -z "$UNITY_CHANGESET" ]; then
|
||||||
|
echo "Error: Could not extract changeset for Unity version ${UNITY_VERSION}."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure we have some modules
|
||||||
|
if [ -z "${UNITY_MODULES}" ]; then
|
||||||
|
if [ -n "$3" ]; then
|
||||||
|
UNITY_MODULES=$3
|
||||||
|
else
|
||||||
|
echo "Error: UNITY_MODULES is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure IMAGE is set, pull from arguments if not
|
||||||
|
if [ -z "${IMAGE}" ]; then
|
||||||
|
if [ -n "$3" ]; then
|
||||||
|
IMAGE=$3
|
||||||
|
else
|
||||||
|
echo "Error: IMAGE is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure GAME_CI_VERSION is set, default to 3 if not
|
||||||
|
if [ -z "${GAMECI_VERSION}" ]; then
|
||||||
|
GAMECI_VERSION=3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure IMAGE_OS is set, default to ubuntu if not
|
||||||
|
if [ -z "${GAMECI_OS}" ]; then
|
||||||
|
|
||||||
|
# windows-il2cpp requires windows OS
|
||||||
|
if [ "${UNITY_PLATFORM}" = "windows-il2cpp" ]; then
|
||||||
|
GAMECI_OS="windows"
|
||||||
|
else
|
||||||
|
GAMECI_OS="ubuntu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: MacOS probably requires a mac image.
|
||||||
|
# Might be worth just putting this in the strategy at this point
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure PLATFORM is set, default to the current system if not
|
||||||
|
if [ -z "${PLATFORM}" ]; then
|
||||||
|
PLATFORM=$(uname -m)
|
||||||
|
case "${PLATFORM}" in
|
||||||
|
x86_64) PLATFORM="linux/amd64" ;;
|
||||||
|
arm64) PLATFORM="linux/arm64" ;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unsupported platform ${PLATFORM}."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure some additional build settings are set
|
||||||
|
if [ -z "${DOCKER_BUILD_ARGS}" ]; then
|
||||||
|
DOCKER_BUILD_ARGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
BASE_TAG=${GAMECI_OS}-${UNITY_VERSION}-base-${GAMECI_VERSION}
|
||||||
|
BASE_IMAGE=unityci/editor:${BASE_TAG}
|
||||||
|
DEST_TAG=${GAMECI_OS}-${UNITY_VERSION}-runner
|
||||||
|
DEST_IMAGE=${IMAGE}:${DEST_TAG}
|
||||||
|
|
||||||
|
echo "Building Docker image ${DEST_IMAGE}"
|
||||||
|
echo "- Version: ${UNITY_VERSION}"
|
||||||
|
echo "- Changeset: ${UNITY_CHANGESET}"
|
||||||
|
echo "- Platfrom: ${PLATFORM}"
|
||||||
|
echo "- Base: ${BASE_IMAGE}"
|
||||||
|
echo "- Tag: ${DEST_TAG}"
|
||||||
|
echo "- Image: ${DEST_IMAGE}"
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--platform ${PLATFORM} \
|
||||||
|
--build-arg "VERSION=${UNITY_VERSION}" \
|
||||||
|
--build-arg "CHANGESET=${UNITY_CHANGESET}" \
|
||||||
|
--build-arg "BASE_IMAGE=${BASE_IMAGE}" \
|
||||||
|
--build-arg "MODULE=${UNITY_MODULES}" \
|
||||||
|
-t ${DEST_IMAGE} ${DOCKER_BUILD_ARGS} \
|
||||||
|
-f ./dockerfiles/runner.dockerfile .
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Docker build failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Export IMAGE and TAG for GitHub Actions
|
||||||
|
if [ -n "$GITHUB_OUTPUT" ]; then
|
||||||
|
echo "IMAGE=${IMAGE}" >> $GITHUB_OUTPUT
|
||||||
|
echo "TAG=$DEST_TAG" >> $GITHUB_OUTPUT
|
||||||
|
echo "FULL_IMAGE=${DEST_IMAGE}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
4
.github/workflows/create-image.yaml
vendored
4
.github/workflows/create-image.yaml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Create Images
|
name: Individual Runners
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@ -43,7 +43,7 @@ jobs:
|
|||||||
echo "Unity Version: $VERSION"
|
echo "Unity Version: $VERSION"
|
||||||
|
|
||||||
- name: Docker Build
|
- name: Docker Build
|
||||||
run: .gitea/workflows/scripts/build-image.sh
|
run: .gitea/workflows/scripts/build-individual-image.sh
|
||||||
id: build-image
|
id: build-image
|
||||||
env:
|
env:
|
||||||
UNITY_VERSION: ${{ env.UNITY_VERSION }}
|
UNITY_VERSION: ${{ env.UNITY_VERSION }}
|
||||||
|
|||||||
52
.github/workflows/create-runner.yaml
vendored
Normal file
52
.github/workflows/create-runner.yaml
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
name: 😎 Uber Runner
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- versions.txt
|
||||||
|
- dockerfiles/runner.dockerfile
|
||||||
|
- .github/workflows/create-runner.yaml
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
UNITY_MODULES: webgl android ios mac-mono windows-mono linux-il2cpp
|
||||||
|
|
||||||
|
environment:
|
||||||
|
name: Docker Hub
|
||||||
|
|
||||||
|
name: Build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get Unity Version
|
||||||
|
id: unity-version
|
||||||
|
run: |
|
||||||
|
VERSION=$(head -n 1 versions.txt)
|
||||||
|
echo "UNITY_VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "Unity Version: $VERSION"
|
||||||
|
|
||||||
|
- name: Docker Build
|
||||||
|
run: .gitea/workflows/scripts/build-runner-image.sh
|
||||||
|
id: build-image
|
||||||
|
env:
|
||||||
|
UNITY_VERSION: ${{ env.UNITY_VERSION }}
|
||||||
|
UNITY_MODULES: ${{ env.UNITY_MODULES }}
|
||||||
|
GAMECI_VERSION: ${{ env.GAMECI_VERSION }}
|
||||||
|
GAMECI_OS: ubuntu
|
||||||
|
IMAGE: "${{ vars.DOCKERHUB_USERNAME }}/unity-runner"
|
||||||
|
|
||||||
|
- name: Docker Push
|
||||||
|
run: |
|
||||||
|
echo "Pushing Docker Image ${{ steps.build-image.outputs.FULL_IMAGE }}"
|
||||||
|
echo "- Image: ${{ steps.build-image.outputs.IMAGE }}"
|
||||||
|
echo "- Tag: ${{ steps.build-image.outputs.TAG }}"
|
||||||
|
docker push ${{ steps.build-image.outputs.FULL_IMAGE }}
|
||||||
10
README.md
10
README.md
@ -7,3 +7,13 @@ A table of available Docker images for Unity CI/CD:
|
|||||||
|---------|----------|----------|----------|----------|----------|----------|
|
|---------|----------|----------|----------|----------|----------|----------|
|
||||||
| 6000.0.35f1 |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-android-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-ios-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-linux-il2cpp-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-mac-mono-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-webgl-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-windows-mono-runner) |
|
| 6000.0.35f1 |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-android-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-ios-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-linux-il2cpp-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-mac-mono-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-webgl-runner) |[🐳 View](https://docker.lakes.house/unityci/editor/tag/ubuntu-6000.0.35f1-windows-mono-runner) |
|
||||||
<!-- /table -->
|
<!-- /table -->
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
https://github.com/mob-sakai/unity-changeset/blob/main/src/unityGraphQL.ts
|
||||||
|
|
||||||
|
use this library to get the change set.
|
||||||
|
Might as well orchestrate the build with it too.
|
||||||
85
dockerfiles/runner.dockerfile
Normal file
85
dockerfiles/runner.dockerfile
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
ARG BASE_IMAGE=unityci/editor
|
||||||
|
ARG HUB_IMAGE="unityci/hub"
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Builder #
|
||||||
|
###########################
|
||||||
|
FROM $HUB_IMAGE AS builder
|
||||||
|
# Install editor
|
||||||
|
ARG VERSION
|
||||||
|
ARG CHANGESET
|
||||||
|
RUN unity-hub install --version "$VERSION" --changeset "$CHANGESET" \
|
||||||
|
| tee /var/log/install-editor.log && grep 'Failed to install\|Error while installing an editor\|Completed with errors' /var/log/install-editor.log | exit $(wc -l)
|
||||||
|
|
||||||
|
# Install modules for that editor
|
||||||
|
ARG MODULE="non-existent-module"
|
||||||
|
RUN for mod in $MODULE; do \
|
||||||
|
if [ "$mod" = "base" ] ; then \
|
||||||
|
echo "running default modules for this baseOs"; \
|
||||||
|
else \
|
||||||
|
unity-hub install-modules --version "$VERSION" --module "$mod" --childModules | tee /var/log/install-module-${mod}.log && \
|
||||||
|
grep 'Missing module\|Completed with errors' /var/log/install-module-${mod}.log | exit $(wc -l); \
|
||||||
|
fi \
|
||||||
|
done \
|
||||||
|
# Set execute permissions for modules
|
||||||
|
&& chmod -R 755 /opt/unity/editors/$VERSION/Editor/Data/PlaybackEngines
|
||||||
|
|
||||||
|
RUN echo "$VERSION-$MODULE" | grep -q -vP '^(2021.2.(?)|2021.[3-9]|202[2-9]|[6-9][0-9]{3}|[1-9][0-9]{4,}).*linux' \
|
||||||
|
&& exit 0 \
|
||||||
|
|| unity-hub install-modules --version "$VERSION" --module "linux-server" --childModules | \
|
||||||
|
tee /var/log/install-module-linux-server.log && grep 'Missing module' /var/log/install-module-linux-server.log | exit $(wc -l);
|
||||||
|
|
||||||
|
RUN echo "$VERSION-$MODULE" | grep -q -vP '^(2021.2.(?)|2021.[3-9]|202[2-9]|[6-9][0-9]{3}|[1-9][0-9]{4,}).*windows' \
|
||||||
|
&& exit 0 \
|
||||||
|
|| unity-hub install-modules --version "$VERSION" --module "windows-server" --childModules | \
|
||||||
|
tee /var/log/install-module-windows-server.log && grep 'Missing module' /var/log/install-module-windows-server.log | exit $(wc -l);
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Editor #
|
||||||
|
###########################
|
||||||
|
FROM $BASE_IMAGE
|
||||||
|
|
||||||
|
# Always put "Editor" and "modules.json" directly in $UNITY_PATH
|
||||||
|
ARG VERSION
|
||||||
|
ARG MODULE
|
||||||
|
COPY --from=builder /opt/unity/editors/$VERSION/ "$UNITY_PATH/"
|
||||||
|
RUN echo $VERSION > "$UNITY_PATH/version"
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
gcc \
|
||||||
|
make \
|
||||||
|
libssl-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libsqlite3-dev
|
||||||
|
|
||||||
|
# Set up the scripts
|
||||||
|
RUN git clone --depth=1 https://github.com/game-ci/unity-builder.git /gameci && \
|
||||||
|
cp -rf /gameci/dist/platforms/ubuntu/steps /steps && \
|
||||||
|
cp -rf /gameci/dist/default-build-script /UnityBuilderAction && \
|
||||||
|
cp /gameci/dist/platforms/ubuntu/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
# Set up Node.js environment for github actions
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||||
|
apt-get install -y nodejs && \
|
||||||
|
npm install -g npm@latest
|
||||||
|
|
||||||
|
# Install Blender
|
||||||
|
ARG BLENDER_SHORT_VERSION=3.4
|
||||||
|
ARG BLENDER_FULL_VERSION=3.4.1
|
||||||
|
RUN echo "BLENDER_FULL_VERSION: $BLENDER_FULL_VERSION" && \
|
||||||
|
echo echo "BLENDER_SHORT_VERSION: $BLENDER_SHORT_VERSION" && \
|
||||||
|
apt-get install -y wget && \
|
||||||
|
wget https://download.blender.org/release/Blender$BLENDER_SHORT_VERSION/blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz && \
|
||||||
|
tar -xf blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz && \
|
||||||
|
rm blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz
|
||||||
|
ENV PATH="$PATH:/blender-$BLENDER_FULL_VERSION-linux-x64"
|
||||||
|
|
||||||
|
# Add custom scripts
|
||||||
|
COPY scripts/build.sh /build.sh
|
||||||
|
RUN chmod +x /build.sh
|
||||||
|
|
||||||
|
# Done
|
||||||
|
# ENTRYPOINT [ "/bin/bash" ]~
|
||||||
Loading…
x
Reference in New Issue
Block a user