Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/build-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"2021.3.x",
"2022.x",
"6000.0.x",
"6000.1",
"6000"
],
"include": [
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,18 @@ jobs:
echo "UNITY_EDITORS: '${{ env.UNITY_EDITORS }}'"
echo "UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'"
echo "UNITY_PROJECT_PATH: '${{ env.UNITY_PROJECT_PATH }}'"
# Extract Unity version from UNITY_EDITOR_PATH using regex
if [[ "${{ env.UNITY_EDITOR_PATH }}" =~ ([0-9]+\.[0-9]+\.[0-9]+[abcfpx]?[0-9]*) ]]; then
UNITY_EDITOR_VERSION="${BASH_REMATCH[1]}"
echo "Detected Unity Editor version: $UNITY_EDITOR_VERSION"
else
echo "Could not extract Unity version from UNITY_EDITOR_PATH: '${{ env.UNITY_EDITOR_PATH }}'"
exit 1
fi
# Check if UNITY_EDITOR_VERSION satisfies matrix.unity-version (exact match or prefix match)
if [[ "$UNITY_EDITOR_VERSION" == "${{ matrix.unity-version }}"* ]]; then
echo "Unity version matches matrix.unity-version: $UNITY_EDITOR_VERSION satisfies ${{ matrix.unity-version }}"
else
echo "Unity version mismatch: $UNITY_EDITOR_VERSION does not satisfy ${{ matrix.unity-version }}"
exit 1
fi
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36481,7 +36481,7 @@ class UnityVersion {
const validReleases = versions
.map(release => semver.coerce(release))
.filter(release => release && semver.satisfies(release, `^${this.semVer}`))
.sort((a, b) => semver.compare(a, b));
.sort((a, b) => semver.compare(b, a));
core.debug(`Searching for fallback match for ${this.version}:`);
validReleases.forEach(release => {
core.debug(` > ${release}`);
Expand Down Expand Up @@ -46678,7 +46678,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
const { blockQuote, commentString, lineWidth } = ctx.options;
// 1. Block can't end in whitespace unless the last line is non-empty.
// 2. Strings consisting of only whitespace are best rendered explicitly.
if (!blockQuote || /\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
if (!blockQuote || /\n[\t ]+$/.test(value)) {
return quotedString(value, ctx);
}
const indent = ctx.indent ||
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "1.2.4",
"version": "1.2.5",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "Buildalon",
"license": "MIT",
Expand Down Expand Up @@ -30,19 +30,19 @@
"@electron/asar": "^3.4.1",
"@rage-against-the-pixel/unity-releases-api": "^1.0.1",
"semver": "^7.7.2",
"yaml": "^2.8.0"
"yaml": "^2.8.1"
},
"devDependencies": {
"@types/node": "^22.17.0",
"@types/node": "^22.17.2",
"@types/semver": "^7.7.0",
"@vercel/ncc": "^0.34.0",
"shx": "^0.3.4",
"typescript": "^5.8.3"
"typescript": "^5.9.2"
},
"scripts": {
"build": "npm run clean && npm run bundle",
"bundle": "ncc build src/index.ts -o dist --source-map --license licenses.txt",
"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"
}
}
}
20 changes: 17 additions & 3 deletions src/unity-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class UnityVersion {
const match = r.match(/(?<version>\d+\.\d+\.\d+[abcfpx]?\d*)/);
return match && match.groups && match.groups.version === this.version;
});

if (exactMatch) {
core.debug(`Exact match found for ${this.version}`);
return new UnityVersion(this.version, null, this.architecture);
Expand All @@ -51,43 +52,56 @@ export class UnityVersion {
// Only fall back to caret range if both minor and patch are 0 (ignoring suffixes)
const versionParts = this.version.match(/^(\d+)\.(\d+)\.(\d+)/);
let minorIsZero = false, patchIsZero = false;

if (versionParts) {
const [, , minor, patch] = versionParts;
minorIsZero = minor === '0';
patchIsZero = patch === '0';
}

if (minorIsZero && patchIsZero) {
const validReleases = versions
.map(release => semver.coerce(release))
.filter(release => release && semver.satisfies(release, `^${this.semVer}`))
.sort((a, b) => semver.compare(a, b)); // sort ascending (lowest first)
.sort((a, b) => semver.compare(b, a)); // sort descending (highest first)
core.debug(`Searching for fallback match for ${this.version}:`);
validReleases.forEach(release => {
core.debug(` > ${release}`);
});

for (const release of validReleases) {
if (!release) { continue; }

const originalRelease = versions.find(r => r.includes(release.version));

if (!originalRelease) { continue; }

const match = originalRelease.match(/(?<version>\d+\.\d+\.\d+[abcfpx]?\d*)\s*(?:\((?<arch>Apple silicon|Intel)\))?/);

if (!(match && match.groups && match.groups.version)) { continue; }
if ((this.version.includes('a') && match.groups.version.includes('a')) ||

if (
(this.version.includes('a') && match.groups.version.includes('a')) ||
(this.version.includes('b') && match.groups.version.includes('b')) ||
match.groups.version.includes('f')) {
match.groups.version.includes('f')
) {
core.debug(`Found fallback Unity ${match.groups.version}`);
return new UnityVersion(match.groups.version, null, this.architecture);
}
}
}

core.debug(`No matching Unity version found for ${this.version}`);
return this;
}

satisfies(version: string): boolean {
const coercedVersion = semver.coerce(version);

if (!coercedVersion) {
throw new Error(`Invalid version to check against: ${version}`);
}

return semver.satisfies(coercedVersion, `^${this.semVer}`);
}
}
Loading