Skip to content

Commit 9c368ff

Browse files
authored
Merge branch 'main' into fix/dotnet-3-5-support
2 parents bf8ada8 + b11b6a6 commit 9c368ff

12 files changed

+107
-38
lines changed

dist/index.js

+24-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/windows/activate.ps1

+24
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ if ( ($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($
5050
Start-Sleep -Seconds 3
5151
}
5252
}
53+
elseif( ($null -ne ${env:UNITY_LICENSING_SERVER}))
54+
{
55+
#
56+
# Custom Unity License Server
57+
#
58+
59+
Write-Output "Adding licensing server config"
60+
61+
$ACTIVATION_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" `
62+
-ArgumentList "--acquire-floating" `
63+
-NoNewWindow `
64+
-PassThru `
65+
-Wait `
66+
-RedirectStandardOutput "license.txt"
67+
68+
$PARSEDFILE = (Get-Content "license.txt" | Select-String -AllMatches -Pattern '\".*?\"' | ForEach-Object { $_.Matches.Value }) -replace '"'
69+
70+
$env:FLOATING_LICENSE = $PARSEDFILE[1]
71+
$FLOATING_LICENSE_TIMEOUT = $PARSEDFILE[3]
72+
73+
Write-Output "Acquired floating license: ""$env:FLOATING_LICENSE"" with timeout $FLOATING_LICENSE_TIMEOUT"
74+
# Store the exit code from the verify command
75+
$ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode
76+
}
5377
else
5478
{
5579
#

dist/platforms/windows/return_license.ps1

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ Write-Output "# Return License #"
66
Write-Output "###########################"
77
Write-Output ""
88

9-
if (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}))
9+
if (($null -ne ${env:UNITY_LICENSING_SERVER}))
10+
{
11+
Write-Output "Returning floating license: ""$env:FLOATING_LICENSE"""
12+
Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" `
13+
-ArgumentList "--return-floating ""$env:FLOATING_LICENSE"" " `
14+
-NoNewWindow `
15+
-Wait
16+
}
17+
18+
elseif (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}))
1019
{
1120
#
1221
# SERIAL LICENSE MODE

dist/platforms/windows/set_gitcredential.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ else {
55
Write-Host "GIT_PRIVATE_TOKEN is set configuring git credentials"
66

77
git config --global credential.helper store
8-
git config --global --replace-all "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://[email protected]/"
9-
git config --global --add "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "[email protected]"
10-
git config --global --add "url.https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/"
8+
git config --global --replace-all url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://[email protected]/"
9+
git config --global --add url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "[email protected]"
10+
git config --global --add url."https://token:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/"
1111

12-
git config --global "url.https://ssh:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://[email protected]/"
13-
git config --global "url.https://git:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "[email protected]:"
12+
git config --global url."https://ssh:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://[email protected]/"
13+
git config --global url."https://git:$env:GIT_PRIVATE_TOKEN@github.com/".insteadOf "[email protected]:"
1414
}
1515

1616
Write-Host "---------- git config --list -------------"

src/model/docker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class Docker {
113113
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
114114
--volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \
115115
--volume "${actionFolder}/platforms/windows":"c:/steps" \
116+
--volume "${actionFolder}/unity-config":"C:/ProgramData/Unity/config" \
116117
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \
117118
--cpus=${dockerCpuLimit} \
118119
--memory=${dockerMemoryLimit} \

src/model/image-tag.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ImageTag from './image-tag';
22

33
describe('ImageTag', () => {
44
const testImageParameters = {
5-
editorVersion: '2099.9.f9f9',
5+
editorVersion: '2099.9.9f9',
66
targetPlatform: 'Test',
77
builderPlatform: '',
88
containerRegistryRepository: 'unityci/editor',
@@ -27,7 +27,7 @@ describe('ImageTag', () => {
2727
expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform);
2828
});
2929

30-
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
30+
test.each(['2000.0.0f0', '2011.1.11f1', '6000.0.0f1'])('accepts %p version format', (version) => {
3131
expect(
3232
() =>
3333
new ImageTag({
@@ -50,23 +50,23 @@ describe('ImageTag', () => {
5050
describe('toString', () => {
5151
it('returns the correct version', () => {
5252
const image = new ImageTag({
53-
editorVersion: '2099.1.1111',
53+
editorVersion: '2099.1.1111f1',
5454
targetPlatform: testImageParameters.targetPlatform,
5555
containerRegistryRepository: 'unityci/editor',
5656
containerRegistryImageVersion: '3',
5757
});
5858
switch (process.platform) {
5959
case 'win32':
60-
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-3`);
60+
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111f1-3`);
6161
break;
6262
case 'linux':
63-
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-3`);
63+
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111f1-3`);
6464
break;
6565
}
6666
});
6767
it('returns customImage if given', () => {
6868
const image = new ImageTag({
69-
editorVersion: '2099.1.1111',
69+
editorVersion: '2099.1.1111f1',
7070
targetPlatform: testImageParameters.targetPlatform,
7171
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
7272
containerRegistryRepository: 'unityci/editor',

src/model/image-tag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ImageTag {
4242
}
4343

4444
static get versionPattern(): RegExp {
45-
return /^(20\d{2}\.\d\.\w{3,4}|3)$/;
45+
return /^\d+\.\d+\.\d+[a-z]\d+$/;
4646
}
4747

4848
static get targetPlatformSuffixes() {

src/model/platform-validation/validate-windows.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import { BuildParameters } from '..';
44
class ValidateWindows {
55
public static validate(buildParameters: BuildParameters) {
66
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
7-
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
8-
throw new Error(`Unity email and password must be set for Windows based builds to
9-
authenticate the license. Make sure to set them inside UNITY_EMAIL
7+
8+
const { unityLicensingServer } = buildParameters;
9+
const hasLicensingCredentials = process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD;
10+
const hasValidLicensingStrategy = hasLicensingCredentials || unityLicensingServer;
11+
12+
if (!hasValidLicensingStrategy) {
13+
throw new Error(`Unity email and password or alternatively a Unity licensing server url must be set for
14+
Windows based builds to authenticate the license. Make sure to set them inside UNITY_EMAIL
1015
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
1116
}
1217
}

src/model/unity-versioning.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ describe('Unity Versioning', () => {
1111
m_EditorVersionWithRevision: 2021.3.4f1 (cb45f9cae8b7)`;
1212
expect(UnityVersioning.parse(projectVersionContents)).toBe('2021.3.4f1');
1313
});
14+
15+
it('parses Unity 6000 and newer from ProjectVersion.txt', () => {
16+
const projectVersionContents = `m_EditorVersion: 6000.0.0f1
17+
m_EditorVersionWithRevision: 6000.0.0f1 (cb45f9cae8b7)`;
18+
expect(UnityVersioning.parse(projectVersionContents)).toBe('6000.0.0f1');
19+
});
1420
});
1521

1622
describe('read', () => {

src/model/unity-versioning.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import fs from 'node:fs';
22
import path from 'node:path';
33

44
export default class UnityVersioning {
5-
static get versionPattern() {
6-
return /20\d{2}\.\d\.\w{3,4}|3/;
7-
}
8-
95
static determineUnityVersion(projectPath: string, unityVersion: string) {
106
if (unityVersion === 'auto') {
117
return UnityVersioning.read(projectPath);
@@ -24,11 +20,13 @@ export default class UnityVersioning {
2420
}
2521

2622
static parse(projectVersionTxt: string) {
27-
const matches = projectVersionTxt.match(UnityVersioning.versionPattern);
28-
if (!matches || matches.length === 0) {
29-
throw new Error(`Failed to parse version from "${projectVersionTxt}".`);
23+
const versionRegex = /m_EditorVersion: (\d+\.\d+\.\d+[A-Za-z]?\d+)/;
24+
const matches = projectVersionTxt.match(versionRegex);
25+
26+
if (!matches || matches.length < 2) {
27+
throw new Error(`Failed to extract version from "${projectVersionTxt}".`);
3028
}
3129

32-
return matches[0];
30+
return matches[1];
3331
}
3432
}

src/model/versioning.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,21 @@ export default class Versioning {
207207
* identifies the current commit.
208208
*/
209209
static async getVersionDescription() {
210-
return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
210+
const versionTags = (await this.git(['tag', '--list', '--merged', 'HEAD', '--sort=-creatordate']))
211+
.split('\n')
212+
.filter((tag) => new RegExp(this.grepCompatibleInputVersionRegex).test(tag));
213+
214+
if (versionTags.length === 0) {
215+
core.warning('No valid version tags found. Using fallback description.');
216+
217+
return this.git(['describe', '--long', '--tags', '--always', 'HEAD']);
218+
}
219+
220+
const latestVersionTag = versionTags[0];
221+
const commitsCount = (await this.git(['rev-list', `${latestVersionTag}..HEAD`, '--count'])).trim();
222+
const commitHash = (await this.git(['rev-parse', '--short', 'HEAD'])).trim();
223+
224+
return `${latestVersionTag}-${commitsCount}-g${commitHash}`;
211225
}
212226

213227
/**

0 commit comments

Comments
 (0)