Skip to content

Commit e9520ee

Browse files
committed
refactor: replace manual Unity license activation with game-ci/unity-activator
1 parent 01b8879 commit e9520ee

File tree

1 file changed

+22
-104
lines changed

1 file changed

+22
-104
lines changed

.github/workflows/claude-nl-suite.yml

Lines changed: 22 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -67,123 +67,53 @@ jobs:
6767
echo "No MCP Python deps found (skipping)"
6868
fi
6969
70-
# --- Licensing: allow both ULF and EBL when available ---
71-
- name: Decide license sources
72-
id: lic
73-
shell: bash
70+
# --- Use game-ci for Unity activation (handles all license types) ---
71+
- name: Activate Unity using game-ci
72+
uses: game-ci/unity-activator@v2
7473
env:
75-
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
7674
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
7775
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
78-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
79-
run: |
80-
set -eu
81-
use_ulf=false; use_ebl=false
82-
[[ -n "${UNITY_LICENSE:-}" ]] && use_ulf=true
83-
[[ -n "${UNITY_EMAIL:-}" && -n "${UNITY_PASSWORD:-}" ]] && use_ebl=true
84-
echo "use_ulf=$use_ulf" >> "$GITHUB_OUTPUT"
85-
echo "use_ebl=$use_ebl" >> "$GITHUB_OUTPUT"
86-
echo "has_serial=$([[ -n "${UNITY_SERIAL:-}" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
87-
88-
- name: Stage Unity .ulf license (from secret)
89-
if: steps.lic.outputs.use_ulf == 'true'
90-
id: ulf
91-
env:
9276
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
93-
shell: bash
94-
run: |
95-
set -eu
96-
mkdir -p "$RUNNER_TEMP/unity-license-ulf" "$RUNNER_TEMP/unity-local/Unity"
97-
f="$RUNNER_TEMP/unity-license-ulf/Unity_lic.ulf"
98-
if printf "%s" "$UNITY_LICENSE" | base64 -d - >/dev/null 2>&1; then
99-
printf "%s" "$UNITY_LICENSE" | base64 -d - > "$f"
100-
else
101-
printf "%s" "$UNITY_LICENSE" > "$f"
102-
fi
103-
chmod 600 "$f" || true
104-
# If someone pasted an entitlement XML into UNITY_LICENSE by mistake, re-home it:
105-
if head -c 100 "$f" | grep -qi '<\?xml'; then
106-
mkdir -p "$RUNNER_TEMP/unity-config/Unity/licenses"
107-
mv "$f" "$RUNNER_TEMP/unity-config/Unity/licenses/UnityEntitlementLicense.xml"
108-
echo "ok=false" >> "$GITHUB_OUTPUT"
109-
elif grep -qi '<Signature>' "$f"; then
110-
# provide it in the standard local-share path too
111-
cp -f "$f" "$RUNNER_TEMP/unity-local/Unity/Unity_lic.ulf"
112-
echo "ok=true" >> "$GITHUB_OUTPUT"
113-
else
114-
echo "ok=false" >> "$GITHUB_OUTPUT"
115-
fi
77+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
78+
with:
79+
unity-version: 2021.3.45f2
11680

117-
# --- Activate via EBL inside the same Unity image (writes host-side entitlement) ---
118-
- name: Activate Unity (EBL via container - host-mount)
119-
if: steps.lic.outputs.use_ebl == 'true'
81+
# Copy activation artifacts to Docker mount locations
82+
- name: Prepare Unity license for Docker containers
12083
shell: bash
121-
env:
122-
UNITY_IMAGE: ${{ env.UNITY_IMAGE }}
123-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
124-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
125-
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
12684
run: |
12785
set -euxo pipefail
128-
# host dirs to receive the full Unity config and local-share
12986
mkdir -p "$RUNNER_TEMP/unity-config" "$RUNNER_TEMP/unity-local"
13087
131-
# Try Pro first if serial is present, otherwise named-user EBL.
132-
docker run --rm --network host \
133-
-e HOME=/root \
134-
-e UNITY_EMAIL -e UNITY_PASSWORD -e UNITY_SERIAL \
135-
-v "$RUNNER_TEMP/unity-config:/root/.config/unity3d" \
136-
-v "$RUNNER_TEMP/unity-local:/root/.local/share/unity3d" \
137-
"$UNITY_IMAGE" bash -lc '
138-
set -euxo pipefail
139-
if [[ -n "${UNITY_SERIAL:-}" ]]; then
140-
/opt/unity/Editor/Unity -batchmode -nographics -logFile - \
141-
-username "$UNITY_EMAIL" -password "$UNITY_PASSWORD" -serial "$UNITY_SERIAL" -quit || true
142-
else
143-
/opt/unity/Editor/Unity -batchmode -nographics -logFile - \
144-
-username "$UNITY_EMAIL" -password "$UNITY_PASSWORD" -quit || true
145-
fi
146-
ls -la /root/.config/unity3d/Unity/licenses || true
147-
'
148-
149-
# Verify entitlement written to host mount; allow ULF-only runs to proceed
150-
if ! find "$RUNNER_TEMP/unity-config" -type f -iname "*.xml" | grep -q .; then
151-
if [[ "${{ steps.ulf.outputs.ok }}" == "true" ]]; then
152-
echo "EBL entitlement not found; proceeding with ULF-only (ok=true)."
153-
else
154-
echo "No entitlement produced and no valid ULF; cannot continue." >&2
155-
exit 1
156-
fi
88+
# game-ci stores license files in standard Unity locations
89+
# Copy them to our Docker mount points
90+
if [ -d "$HOME/.local/share/unity3d" ]; then
91+
cp -r "$HOME/.local/share/unity3d"/* "$RUNNER_TEMP/unity-local/" || true
92+
fi
93+
if [ -d "$HOME/.config/unity3d" ]; then
94+
cp -r "$HOME/.config/unity3d"/* "$RUNNER_TEMP/unity-config/" || true
15795
fi
15896
159-
# EBL entitlement is already written directly to $RUNNER_TEMP/unity-config by the activation step
97+
# Verify license files exist
98+
echo "Unity license files prepared:"
99+
find "$RUNNER_TEMP/unity-local" -type f || true
100+
find "$RUNNER_TEMP/unity-config" -type f || true
160101
161102
# ---------- Warm up project (import Library once) ----------
162103
- name: Warm up project (import Library once)
163-
if: steps.lic.outputs.use_ulf == 'true' || steps.lic.outputs.use_ebl == 'true'
104+
if: steps.detect.outputs.unity_ok == 'true'
164105
shell: bash
165106
env:
166107
UNITY_IMAGE: ${{ env.UNITY_IMAGE }}
167-
ULF_OK: ${{ steps.ulf.outputs.ok }}
168-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
169-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
170-
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
171108
run: |
172109
set -euxo pipefail
173-
manual_args=()
174-
if [[ "${ULF_OK:-false}" == "true" ]]; then
175-
manual_args=(-manualLicenseFile "/root/.local/share/unity3d/Unity/Unity_lic.ulf")
176-
fi
177110
docker run --rm --network host \
178111
-e HOME=/root \
179-
-e UNITY_EMAIL="${UNITY_EMAIL:-}" \
180-
-e UNITY_PASSWORD="${UNITY_PASSWORD:-}" \
181112
-v "${{ github.workspace }}:/workspace" -w /workspace \
182113
-v "$RUNNER_TEMP/unity-config:/root/.config/unity3d" \
183114
-v "$RUNNER_TEMP/unity-local:/root/.local/share/unity3d" \
184115
"$UNITY_IMAGE" /opt/unity/Editor/Unity -batchmode -nographics -logFile - \
185116
-projectPath /workspace/TestProjects/UnityMCPTests \
186-
"${manual_args[@]}" \
187117
-quit
188118
189119
# ---------- Clean old MCP status ----------
@@ -195,27 +125,16 @@ jobs:
195125
196126
# ---------- Start headless Unity (persistent bridge) ----------
197127
- name: Start Unity (persistent bridge)
198-
if: steps.lic.outputs.use_ulf == 'true' || steps.lic.outputs.use_ebl == 'true'
128+
if: steps.detect.outputs.unity_ok == 'true'
199129
shell: bash
200130
env:
201131
UNITY_IMAGE: ${{ env.UNITY_IMAGE }}
202-
ULF_OK: ${{ steps.ulf.outputs.ok }}
203-
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
204-
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
205-
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
206132
run: |
207133
set -euxo pipefail
208-
manual_args=()
209-
if [[ "${ULF_OK:-false}" == "true" ]]; then
210-
manual_args=(-manualLicenseFile "/root/.local/share/unity3d/Unity/Unity_lic.ulf")
211-
fi
212-
213134
mkdir -p "$RUNNER_TEMP/unity-status"
214135
docker rm -f unity-mcp >/dev/null 2>&1 || true
215136
docker run -d --name unity-mcp --network host \
216137
-e HOME=/root \
217-
-e UNITY_EMAIL="${UNITY_EMAIL:-}" \
218-
-e UNITY_PASSWORD="${UNITY_PASSWORD:-}" \
219138
-e UNITY_MCP_ALLOW_BATCH=1 \
220139
-e UNITY_MCP_STATUS_DIR=/root/.unity-mcp \
221140
-e UNITY_MCP_BIND_HOST=127.0.0.1 \
@@ -226,7 +145,6 @@ jobs:
226145
"$UNITY_IMAGE" /opt/unity/Editor/Unity -batchmode -nographics -logFile - \
227146
-stackTraceLogType Full \
228147
-projectPath /workspace/TestProjects/UnityMCPTests \
229-
"${manual_args[@]}" \
230148
-executeMethod MCPForUnity.Editor.MCPForUnityBridge.StartAutoConnect
231149
232150
# ---------- Wait for Unity bridge ----------
@@ -967,7 +885,7 @@ jobs:
967885
docker rm -f unity-mcp || true
968886
969887
- name: Return Pro license (if used)
970-
if: always() && steps.lic.outputs.use_ebl == 'true' && steps.lic.outputs.has_serial == 'true'
888+
if: always()
971889
uses: game-ci/unity-return-license@v2
972890
continue-on-error: true
973891
env:

0 commit comments

Comments
 (0)