Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- fix latest release matching
  • Loading branch information
StephenHodgson committed Oct 18, 2024
1 parent d62125a commit caef936
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
24 changes: 11 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34826,19 +34826,17 @@ async function Unity(version, changeset, architecture, modules) {
}
async function getLatestRelease(version, isSilicon) {
const releases = (await execUnityHub([`editors`, `--releases`])).split('\n');
for (const release of releases) {
if (!release || release.trim().length === 0) {
continue;
}
const semVersion = semver.coerce(version);
const semVerRelease = semver.coerce(release);
core.debug(`Checking ${semVersion} against ${semVerRelease}`);
if (semver.satisfies(semVerRelease, `^${semVersion}`)) {
const match = release.match(/(?<version>\d+\.\d+\.\d+[fab]?\d*)\s*(?:\((?<arch>Apple silicon|Intel)\))?/);
if (match && match.groups && match.groups.version) {
core.info(`Found Unity ${match.groups.version}`);
return [match.groups.version, undefined];
}
const semVersion = semver.coerce(version);
const validReleases = releases
.map(release => semver.coerce(release))
.filter(release => release && semver.satisfies(release, `^${semVersion}`))
.sort((a, b) => semver.compare(b, a));
for (const release of validReleases) {
const originalRelease = releases.find(r => r.includes(release.version));
const match = originalRelease.match(/(?<version>\d+\.\d+\.\d+[fab]?\d*)\s*(?:\((?<arch>Apple silicon|Intel)\))?/);
if (match && match.groups && match.groups.version) {
core.info(`Found Unity ${match.groups.version}`);
return [match.groups.version, undefined];
}
}
core.info(`Searching for Unity ${version} release...`);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unity-setup",
"version": "1.0.7",
"version": "1.0.8",
"description": "A GitHub action for setting up the Unity Game Engine for CI/CD workflows.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down Expand Up @@ -41,6 +41,7 @@
"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"
}
}
24 changes: 12 additions & 12 deletions src/unity-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,17 @@ async function Unity(version: string, changeset: string, architecture: string, m

async function getLatestRelease(version: string, isSilicon: boolean): Promise<[string, string]> {
const releases = (await execUnityHub([`editors`, `--releases`])).split('\n');
for (const release of releases) {
if (!release || release.trim().length === 0) { continue; }
const semVersion = semver.coerce(version);
const semVerRelease = semver.coerce(release);
core.debug(`Checking ${semVersion} against ${semVerRelease}`);
if (semver.satisfies(semVerRelease, `^${semVersion}`)) {
const match = release.match(/(?<version>\d+\.\d+\.\d+[fab]?\d*)\s*(?:\((?<arch>Apple silicon|Intel)\))?/);
if (match && match.groups && match.groups.version) {
core.info(`Found Unity ${match.groups.version}`);
return [match.groups.version, undefined];
}
const semVersion = semver.coerce(version);
const validReleases = releases
.map(release => semver.coerce(release))
.filter(release => release && semver.satisfies(release, `^${semVersion}`))
.sort((a, b) => semver.compare(b, a));
for (const release of validReleases) {
const originalRelease = releases.find(r => r.includes(release.version));
const match = originalRelease.match(/(?<version>\d+\.\d+\.\d+[fab]?\d*)\s*(?:\((?<arch>Apple silicon|Intel)\))?/);
if (match && match.groups && match.groups.version) {
core.info(`Found Unity ${match.groups.version}`);
return [match.groups.version, undefined];
}
}
core.info(`Searching for Unity ${version} release...`);
Expand All @@ -289,7 +289,7 @@ async function getLatestRelease(version: string, isSilicon: boolean): Promise<[s
async function parseReleases(version: string, data: string): Promise<[string, string]> {
const releases = JSON.parse(data);
core.debug(`Found ${releases.official.length} official releases...`);
releases.official.sort((a, b) => semver.compare(a.version, b.version, true));
releases.official.sort((a: any, b: any) => semver.compare(a.version, b.version, true));
for (const release of releases.official) {
const semVersion = semver.coerce(version);
const semVerRelease = semver.coerce(release.version);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"declaration": false,
"noEmit": true,
},
"compileOnSave": true,
"include": [
Expand Down

0 comments on commit caef936

Please sign in to comment.