diff --git a/dist/index.js b/dist/index.js index 37cb10c7..ff6bad6f 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 20a881ef..987ce0d1 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/platforms/windows/activate.ps1 b/dist/platforms/windows/activate.ps1 index 1f630983..74ffdb58 100644 --- a/dist/platforms/windows/activate.ps1 +++ b/dist/platforms/windows/activate.ps1 @@ -50,6 +50,30 @@ if ( ($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($ Start-Sleep -Seconds 3 } } +elseif( ($null -ne ${env:UNITY_LICENSING_SERVER})) +{ + # + # Custom Unity License Server + # + + Write-Output "Adding licensing server config" + + $ACTIVATION_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" ` + -ArgumentList "--acquire-floating" ` + -NoNewWindow ` + -PassThru ` + -Wait ` + -RedirectStandardOutput "license.txt" + + $PARSEDFILE = (Get-Content "license.txt" | Select-String -AllMatches -Pattern '\".*?\"' | ForEach-Object { $_.Matches.Value }) -replace '"' + + $env:FLOATING_LICENSE = $PARSEDFILE[1] + $FLOATING_LICENSE_TIMEOUT = $PARSEDFILE[3] + + Write-Output "Acquired floating license: ""$env:FLOATING_LICENSE"" with timeout $FLOATING_LICENSE_TIMEOUT" + # Store the exit code from the verify command + $ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode +} else { # diff --git a/dist/platforms/windows/return_license.ps1 b/dist/platforms/windows/return_license.ps1 index edf7ec2e..66099180 100644 --- a/dist/platforms/windows/return_license.ps1 +++ b/dist/platforms/windows/return_license.ps1 @@ -6,7 +6,16 @@ Write-Output "# Return License #" Write-Output "###########################" Write-Output "" -if (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD})) +if (($null -ne ${env:UNITY_LICENSING_SERVER})) +{ + Write-Output "Returning floating license: ""$env:FLOATING_LICENSE""" + Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" ` + -ArgumentList "--return-floating ""$env:FLOATING_LICENSE"" " ` + -NoNewWindow ` + -Wait +} + +elseif (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD})) { # # SERIAL LICENSE MODE diff --git a/dist/platforms/windows/set_gitcredential.ps1 b/dist/platforms/windows/set_gitcredential.ps1 index f77f31b8..66126e42 100644 --- a/dist/platforms/windows/set_gitcredential.ps1 +++ b/dist/platforms/windows/set_gitcredential.ps1 @@ -5,12 +5,12 @@ else { Write-Host "GIT_PRIVATE_TOKEN is set configuring git credentials" git config --global credential.helper store - git config --global --replace-all "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/" - git config --global --add "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com" - git config --global --add "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/" + git config --global --replace-all url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/" + git config --global --add url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com" + git config --global --add url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/" - git config --global "url.https://ssh:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/" - git config --global "url.https://git:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com:" + git config --global url."https://ssh:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/" + git config --global url."https://git:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com:" } Write-Host "---------- git config --list -------------" diff --git a/src/model/docker.ts b/src/model/docker.ts index 1beb4923..544540f7 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -113,6 +113,7 @@ class Docker { --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \ --volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \ --volume "${actionFolder}/platforms/windows":"c:/steps" \ + --volume "${actionFolder}/unity-config":"C:/ProgramData/Unity/config" \ --volume "${actionFolder}/BlankProject":"c:/BlankProject" \ --cpus=${dockerCpuLimit} \ --memory=${dockerMemoryLimit} \ diff --git a/src/model/image-tag.test.ts b/src/model/image-tag.test.ts index 47adf65e..eb0db0f1 100644 --- a/src/model/image-tag.test.ts +++ b/src/model/image-tag.test.ts @@ -2,7 +2,7 @@ import ImageTag from './image-tag'; describe('ImageTag', () => { const testImageParameters = { - editorVersion: '2099.9.f9f9', + editorVersion: '2099.9.9f9', targetPlatform: 'Test', builderPlatform: '', containerRegistryRepository: 'unityci/editor', @@ -27,7 +27,7 @@ describe('ImageTag', () => { expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform); }); - test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => { + test.each(['2000.0.0f0', '2011.1.11f1', '6000.0.0f1'])('accepts %p version format', (version) => { expect( () => new ImageTag({ @@ -50,23 +50,23 @@ describe('ImageTag', () => { describe('toString', () => { it('returns the correct version', () => { const image = new ImageTag({ - editorVersion: '2099.1.1111', + editorVersion: '2099.1.1111f1', targetPlatform: testImageParameters.targetPlatform, containerRegistryRepository: 'unityci/editor', containerRegistryImageVersion: '3', }); switch (process.platform) { case 'win32': - expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-3`); + expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111f1-3`); break; case 'linux': - expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-3`); + expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111f1-3`); break; } }); it('returns customImage if given', () => { const image = new ImageTag({ - editorVersion: '2099.1.1111', + editorVersion: '2099.1.1111f1', targetPlatform: testImageParameters.targetPlatform, customImage: `${defaults.image}:2099.1.1111@347598437689743986`, containerRegistryRepository: 'unityci/editor', diff --git a/src/model/image-tag.ts b/src/model/image-tag.ts index e32ccbdd..2b9fd910 100644 --- a/src/model/image-tag.ts +++ b/src/model/image-tag.ts @@ -42,7 +42,7 @@ class ImageTag { } static get versionPattern(): RegExp { - return /^(20\d{2}\.\d\.\w{3,4}|3)$/; + return /^\d+\.\d+\.\d+[a-z]\d+$/; } static get targetPlatformSuffixes() { diff --git a/src/model/platform-validation/validate-windows.ts b/src/model/platform-validation/validate-windows.ts index 6158c9f8..2a7b68df 100644 --- a/src/model/platform-validation/validate-windows.ts +++ b/src/model/platform-validation/validate-windows.ts @@ -4,9 +4,14 @@ import { BuildParameters } from '..'; class ValidateWindows { public static validate(buildParameters: BuildParameters) { ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform); - if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) { - throw new Error(`Unity email and password must be set for Windows based builds to - authenticate the license. Make sure to set them inside UNITY_EMAIL + + const { unityLicensingServer } = buildParameters; + const hasLicensingCredentials = process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD; + const hasValidLicensingStrategy = hasLicensingCredentials || unityLicensingServer; + + if (!hasValidLicensingStrategy) { + throw new Error(`Unity email and password or alternatively a Unity licensing server url must be set for + Windows based builds to authenticate the license. Make sure to set them inside UNITY_EMAIL and UNITY_PASSWORD in Github Secrets and pass them into the environment.`); } } diff --git a/src/model/unity-versioning.test.ts b/src/model/unity-versioning.test.ts index 5db2af14..e5ffd6e9 100644 --- a/src/model/unity-versioning.test.ts +++ b/src/model/unity-versioning.test.ts @@ -11,6 +11,12 @@ describe('Unity Versioning', () => { m_EditorVersionWithRevision: 2021.3.4f1 (cb45f9cae8b7)`; expect(UnityVersioning.parse(projectVersionContents)).toBe('2021.3.4f1'); }); + + it('parses Unity 6000 and newer from ProjectVersion.txt', () => { + const projectVersionContents = `m_EditorVersion: 6000.0.0f1 + m_EditorVersionWithRevision: 6000.0.0f1 (cb45f9cae8b7)`; + expect(UnityVersioning.parse(projectVersionContents)).toBe('6000.0.0f1'); + }); }); describe('read', () => { diff --git a/src/model/unity-versioning.ts b/src/model/unity-versioning.ts index 098aee25..b2378b6e 100644 --- a/src/model/unity-versioning.ts +++ b/src/model/unity-versioning.ts @@ -2,10 +2,6 @@ import fs from 'node:fs'; import path from 'node:path'; export default class UnityVersioning { - static get versionPattern() { - return /20\d{2}\.\d\.\w{3,4}|3/; - } - static determineUnityVersion(projectPath: string, unityVersion: string) { if (unityVersion === 'auto') { return UnityVersioning.read(projectPath); @@ -24,11 +20,13 @@ export default class UnityVersioning { } static parse(projectVersionTxt: string) { - const matches = projectVersionTxt.match(UnityVersioning.versionPattern); - if (!matches || matches.length === 0) { - throw new Error(`Failed to parse version from "${projectVersionTxt}".`); + const versionRegex = /m_EditorVersion: (\d+\.\d+\.\d+[A-Za-z]?\d+)/; + const matches = projectVersionTxt.match(versionRegex); + + if (!matches || matches.length < 2) { + throw new Error(`Failed to extract version from "${projectVersionTxt}".`); } - return matches[0]; + return matches[1]; } } diff --git a/src/model/versioning.ts b/src/model/versioning.ts index 38176907..a0ac3675 100644 --- a/src/model/versioning.ts +++ b/src/model/versioning.ts @@ -207,7 +207,21 @@ export default class Versioning { * identifies the current commit. */ static async getVersionDescription() { - return this.git(['describe', '--long', '--tags', '--always', 'HEAD']); + const versionTags = (await this.git(['tag', '--list', '--merged', 'HEAD', '--sort=-creatordate'])) + .split('\n') + .filter((tag) => new RegExp(this.grepCompatibleInputVersionRegex).test(tag)); + + if (versionTags.length === 0) { + core.warning('No valid version tags found. Using fallback description.'); + + return this.git(['describe', '--long', '--tags', '--always', 'HEAD']); + } + + const latestVersionTag = versionTags[0]; + const commitsCount = (await this.git(['rev-list', `${latestVersionTag}..HEAD`, '--count'])).trim(); + const commitHash = (await this.git(['rev-parse', '--short', 'HEAD'])).trim(); + + return `${latestVersionTag}-${commitsCount}-g${commitHash}`; } /**