Skip to content

[email protected] #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
25cea89
[email protected]
StephenHodgson Jul 13, 2025
ad0b09e
remove modules in validate workflow for 4.7.2
StephenHodgson Jul 13, 2025
5ec4816
fix compare
StephenHodgson Jul 13, 2025
86c4ac8
update regex
StephenHodgson Jul 13, 2025
f993199
refactor
StephenHodgson Jul 13, 2025
ba90629
4.x skip changeset
StephenHodgson Jul 13, 2025
28c8acb
tweak installation
StephenHodgson Jul 13, 2025
5ce2852
validate access to editor path before adding
StephenHodgson Jul 13, 2025
4d0a4c0
fix version to string
StephenHodgson Jul 13, 2025
d385331
typos
StephenHodgson Jul 13, 2025
7a6b8a9
debugging
StephenHodgson Jul 13, 2025
9ab0b36
use pkg installer
StephenHodgson Jul 13, 2025
9f4110d
more debug
StephenHodgson Jul 13, 2025
3e4a720
ensure legacy editor install path is valid
StephenHodgson Jul 13, 2025
0254f8b
tweaks
StephenHodgson Jul 14, 2025
234ec36
debug
StephenHodgson Jul 14, 2025
0f81cca
fix editor list
StephenHodgson Jul 14, 2025
bd217df
clean macOS install move
StephenHodgson Jul 14, 2025
a44ed1c
refactor
StephenHodgson Jul 14, 2025
9f46116
tweak path
StephenHodgson Jul 14, 2025
88c28d6
add debug
StephenHodgson Jul 14, 2025
ac0f4f4
more debugging
StephenHodgson Jul 14, 2025
9c380f5
dist
StephenHodgson Jul 14, 2025
57908cc
fix
StephenHodgson Jul 14, 2025
ba014df
fix windows
StephenHodgson Jul 14, 2025
6615806
fix win editor path
StephenHodgson Jul 14, 2025
ec86a48
cleanup
StephenHodgson Jul 14, 2025
83557b7
fix editor array
StephenHodgson Jul 14, 2025
785897a
fix legacy check
StephenHodgson Jul 14, 2025
ff3e33b
debug
StephenHodgson Jul 14, 2025
5f1cf78
debug
StephenHodgson Jul 14, 2025
a36b98a
update regex
StephenHodgson Jul 14, 2025
c51b90d
more debug
StephenHodgson Jul 14, 2025
50beee0
update regex
StephenHodgson Jul 14, 2025
4a17cad
regex
StephenHodgson Jul 14, 2025
d7b289d
normalize
StephenHodgson Jul 14, 2025
cfc8db7
tweaks
StephenHodgson Jul 14, 2025
6931697
more logging
StephenHodgson Jul 14, 2025
fca0b45
move bee backend patch into its own function
StephenHodgson Jul 14, 2025
b191c98
Normalize install path
js6pak Jul 15, 2025
9297868
regex
StephenHodgson Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
unity-version:
- None
- 4.7.2
- 5.6.7f1 (e80cc3114ac1)
- 2020.3
- 2021.3.x
Expand Down Expand Up @@ -56,6 +57,8 @@ jobs:
# Exclude Unity 5.x for linux as it is not supported
- os: ubuntu-latest
unity-version: '5.6.7f1 (e80cc3114ac1)'
- os: ubuntu-latest
unity-version: '4.7.2'
steps:
- uses: actions/checkout@v4

Expand Down
317 changes: 222 additions & 95 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions dist/install-unityhub-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ else
fi
fileName="UnityHubSetup"
url="$baseUrl/$fileName-$cpuArch.dmg"
downloadPath="$RUNNER_TEMP/$fileName-$cpuArch.dmg"
downloadPath="${RUNNER_TEMP}/$fileName-$cpuArch.dmg"
echo "Downloading Unity Hub from $url to $downloadPath..."
wget -qO "$downloadPath" "$url"
if [ ! -f "$downloadPath" ]; then
wget -qO "${downloadPath}" "${url}"
if [ ! -f "${downloadPath}" ]; then
echo "Failed to download Unity Hub"
exit 1
fi
volume=$(hdiutil attach "$downloadPath" -nobrowse | grep -o "/Volumes/.*" | head -n1)
if [ -z "$volume" ]; then
echo "Failed to mount $downloadPath"
volumes=$(hdiutil attach "${downloadPath}" -nobrowse | grep -o "/Volumes/.*" | head -n1)
if [ -z "${volumes}" ]; then
echo "Failed to mount ${downloadPath}"
exit 1
fi
appPath=$(find "$volume" -name "*.app" | head -n1)
if [ -z "$appPath" ]; then
echo "Failed to find Unity Hub app in $volume"
echo "Mounted volumes:"
echo "${volumes}"
volume=$(echo "${volumes}" | grep -o "/Volumes/Unity Hub.*-${cpuArch}" | head -n1)
if [ -z "${volume}" ]; then
echo "Failed to mount ${downloadPath}"
hdiutil unmount "${volume}" -quiet
exit 1
fi
cp -vrf "$appPath" /Applications
hdiutil unmount "$volume" -quiet
appPath=$(find "${volume}" -name "*.app" | head -n1)
echo "moving ${appPath} to /Applications..."
if [ -z "${appPath}" ]; then
echo "Failed to find Unity Hub app in ${volume}"
hdiutil unmount "${volume}" -quiet
exit 1
fi
cp -vrf "${appPath}" /Applications
hdiutil unmount "${volume}" -quiet
sudo chmod -R 777 /Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub
sudo mkdir -p /Library/Application\ Support/Unity
sudo chmod -R 777 /Library/Application\ Support/Unity
Expand Down
8 changes: 6 additions & 2 deletions dist/install-unityhub-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Write-Host "::group::Installing Unity Hub..."
$tempPath = "$env:RUNNER_TEMP/UnityHubSetup.exe"
$tempPath = "$env:RUNNER_TEMP\UnityHubSetup.exe"
$url = 'https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe'
$wc = New-Object System.Net.WebClient
Write-Host "Downloading `"$url`" > `"$tempPath`"..."
$wc.DownloadFile($url, $tempPath)
Write-Host "`"$tempPath`" /S"
if (-not (Test-Path $tempPath)) {
Write-Host "Error: Failed to download Unity Hub installer."
exit 1
}
Write-Host "[command]pwsh `"$tempPath`" /S"
$process = Start-Process -FilePath $tempPath -ArgumentList '/S' -PassThru -Wait
Write-Host "::endgroup::"
exit [int]$process.ExitCode
48 changes: 48 additions & 0 deletions dist/unity-editor-installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This script is used to download and install older unity versions.
# https://discussions.unity.com/t/early-unity-versions-downloads/927331
# input arguments:
# 1. Unity Editor Version (Required)
# 2. Install Directory (Required)
# url example: https://beta.unity3d.com/download/UnitySetup-4.7.2.exe
$version = $args[0]
$installDir = $args[1]
if (-not $version) {
Write-Host "Error: Unity version is required."
exit 1
}
if (-not $installDir) {
Write-Host "Error: Install directory is required."
exit 1
}
Write-Host "::group::Installing Unity $version..."
$installerUrl = "https://beta.unity3d.com/download/UnitySetup-$version.exe"
$installerPath = "$env:TEMP\UnitySetup-$version.exe"
$wc = New-Object System.Net.WebClient
Write-Host "Downloading `"$installerUrl`" to `"$installerPath`"..."
$wc.DownloadFile($installerUrl, $installerPath)
if (-not (Test-Path $installerPath)) {
Write-Host "Error: Failed to download Unity installer."
exit 1
}
$targetPath = "$installDir\Unity $version"
Write-Host "[command]pwsh `"$installerPath`" /S /D=$targetPath"
if (-not (Test-Path $targetPath)) {
New-Item -ItemType Directory -Path $targetPath -Force | Out-Null
}
try {
Start-Process -FilePath $installerPath -ArgumentList "/S /D=$targetPath" -Wait -NoNewWindow
if (-not (Test-Path "$targetPath")) {
Write-Host "Error: Unity installation failed."
exit 1
}
Write-Host "Listing installed files in $targetPath"
Get-ChildItem -Path "$targetPath" -Recurse | ForEach-Object {
Write-Host $_.FullName
}
} catch {
Write-Host "Error: Failed to start Unity installer."
exit 1
} finally {
Remove-Item -Path $installerPath -Force
Write-Host "::endgroup::"
}
72 changes: 72 additions & 0 deletions dist/unity-editor-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
set -e
# This script is used to download and install older unity versions.
# https://discussions.unity.com/t/early-unity-versions-downloads/927331
# input arguments:
# 1. Unity Editor Version (Required)
# 2. Install Directory (Required)
# url example: https://beta.unity3d.com/download/unity-4.7.2.dmg
VERSION="$1"
INSTALL_DIR="$2"
if [ -z "${VERSION}" ] || [ -z "${INSTALL_DIR}" ]; then
echo "Usage: $0 <Unity Version> <Install Directory>"
exit 1
fi
if [ ! -d "${INSTALL_DIR}" ]; then
mkdir -p "${INSTALL_DIR}"
fi
url="https://beta.unity3d.com/download/unity-${VERSION}.dmg"
downloadPath="${RUNNER_TEMP}/unity-${VERSION}.dmg"
echo "::group::Installing Unity ${VERSION}..."
echo "Downloading Unity from ${url} to ${downloadPath}..."
wget -qO "${downloadPath}" "${url}"
if [ ! -f "${downloadPath}" ]; then
echo "Failed to download Unity ${VERSION}"
exit 1
fi
volumes=$(hdiutil attach "${downloadPath}" -nobrowse | grep -o "/Volumes/.*")
if [ -z "${volumes}" ]; then
echo "Failed to mount ${downloadPath}"
exit 1
fi
echo "Mounted volumes:"
echo "${volumes}"
volume=$(echo "${volumes}" | grep -o "/Volumes/Unity Installer" | head -n1)
if [ -z "${volume}" ]; then
echo "Failed to mount ${downloadPath}"
hdiutil unmount "${volume}" -quiet
exit 1
fi
echo "selected volume: ${volume}"
pkgPath=$(find "${volume}" -type f -name "Unity.pkg" | head -n1)
if [ -z "${pkgPath}" ]; then
echo "Failed to find Unity .pkg in ${volume}"
echo "Available files in ${volume}:"
find "${volume}" -type f
hdiutil unmount "${volume}" -quiet
exit 1
fi

echo "Found .pkg installer: ${pkgPath}"
sudo installer -pkg "${pkgPath}" -target / -verboseR
UNITY_APP_PATH="/Applications/Unity"
TARGET_PATH="${INSTALL_DIR}/Unity ${VERSION}"
if [ -d "$UNITY_APP_PATH" ]; then
echo "Moving $UNITY_APP_PATH to $TARGET_PATH..."
mkdir -p "$(dirname "$TARGET_PATH")"
for item in "$UNITY_APP_PATH"/*; do
name="$(basename "$item")"
if [ "$name" != "Hub" ]; then
sudo cp -R "$item" "$TARGET_PATH/"
sudo rm -rf "$item"
fi
done
sudo chmod -R 777 "$TARGET_PATH"
else
echo "$UNITY_APP_PATH not found after installation."
hdiutil unmount "${volume}" -quiet
exit 1
fi
hdiutil unmount "${volume}" -quiet
echo "::endgroup::"
exit 0
34 changes: 32 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "1.1.1",
"version": "1.2.0",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down Expand Up @@ -28,6 +28,7 @@
"@actions/exec": "^1.1.1",
"@actions/glob": "^0.4.0",
"@electron/asar": "^3.4.1",
"@rage-against-the-pixel/unity-releases-api": "^1.0.0",
"semver": "^7.7.2",
"yaml": "^2.8.0"
},
Expand All @@ -44,4 +45,4 @@
"watch": "ncc build src/index.ts -o dist --source-map --license licenses.txt --watch",
"clean": "npm install && shx rm -rf dist/ out/ node_modules/ && npm ci"
}
}
}
16 changes: 9 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const main = async () => {
await unityHub.SetInstallPath(installPath);
}
const editors = [];
for (const [version, changeset] of versions) {
const unityEditorPath = await unityHub.Unity(version, changeset, architecture, modules);
// for now just export the highest installed version
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath);
for (const unityVersion of versions) {
const unityEditorPath = await unityHub.Unity(unityVersion, architecture, modules);
core.exportVariable('UNITY_EDITOR_PATH', unityEditorPath); // always sets the last installed editor path
if (modules.includes('android') && unityProjectPath !== undefined) {
await CheckAndroidSdkInstalled(unityEditorPath, unityProjectPath);
}
editors.push([version, unityEditorPath]);
core.info(`Installed Unity Editor: ${unityVersion.toString()} at ${unityEditorPath}`);
editors.push([unityVersion.version, unityEditorPath]);
}
const installedEditors = editors.map(([version, path]) => `\"${version}\":\"${path}\"`).join(',');
core.exportVariable('UNITY_EDITORS', `[${installedEditors}]`);
if (editors.length !== versions.length) {
throw new Error(`Expected to install ${versions.length} Unity versions, but installed ${editors.length}.`);
}
core.exportVariable('UNITY_EDITORS', JSON.stringify(Object.fromEntries(editors)));
core.info('Unity Setup Complete!');
process.exit(0);
} catch (error) {
Expand Down
Loading
Loading