diff --git a/dist/platforms/windows/entrypoint.ps1 b/dist/platforms/windows/entrypoint.ps1 index b5255d11..01f666b5 100644 --- a/dist/platforms/windows/entrypoint.ps1 +++ b/dist/platforms/windows/entrypoint.ps1 @@ -1,13 +1,13 @@ -# Activate Unity -& "c:\steps\activate.ps1" - # Import any necessary registry keys, ie: location of windows 10 sdk # No guarantee that there will be any necessary registry keys, ie: tvOS -Get-ChildItem -Path c:\regkeys -File | Foreach {reg import $_.fullname} +Get-ChildItem -Path c:\registry-keys -File | Foreach {reg import $_.fullname} # Register the Visual Studio installation so Unity can find it regsvr32 C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll +# Activate Unity +& "c:\steps\activate.ps1" + # Build the project & "c:\steps\build.ps1" diff --git a/src/config/options.ts b/src/config/options.ts index 5c3f481d..1ebe0e0b 100644 --- a/src/config/options.ts +++ b/src/config/options.ts @@ -24,10 +24,4 @@ export class Options { return this; } - - registerCommand(command: CommandInterface) { - this.command = command; - - return this; - } } diff --git a/src/dependencies.ts b/src/dependencies.ts index e4e4efb4..d115c9ab 100644 --- a/src/dependencies.ts +++ b/src/dependencies.ts @@ -3,8 +3,8 @@ import * as assert from 'https://deno.land/std@0.144.0/testing/asserts.ts'; import * as aws from 'https://deno.land/x/aws_api/client/mod.ts'; import * as base64 from 'https://deno.land/std@0.145.0/encoding/base64.ts'; import * as compress from 'https://deno.land/x/compress@v0.3.3/mod.ts'; -import * as fs from 'https://deno.land/std@0.142.0/node/fs/promises.ts'; -import * as fsSync from 'https://deno.land/std@0.142.0/fs/mod.ts'; +import * as fs from 'https://deno.land/std@0.152.0/node/fs/promises.ts'; +import * as fsSync from 'https://deno.land/std@0.152.0/fs/mod.ts'; import * as k8s from 'https://deno.land/x/kubernetes_client/mod.ts'; import * as k8sTypes from 'https://deno.land/x/kubernetes_apis/builtin/core@v1/mod.ts'; import * as nanoid from 'https://deno.land/x/nanoid@v3.0.0/mod.ts'; diff --git a/src/index.ts b/src/index.ts index 6e4b1470..c96b0dbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,16 +20,18 @@ export class GameCI { const { commandName, subCommands, args, verbosity } = new ArgumentsParser().parse(this.args); await configureLogger(verbosity); - // Determine the command and its options + // Determine which command to run const { engine, engineVersion } = await new EngineDetector(subCommands, args).detect(); const command = new CommandFactory().selectEngine(engine, engineVersion).createCommand(commandName, subCommands); - const options = await new Options(command, this.env).registerCommand(command).generateParameters(args); + + // Provide the command with options + const options = await new Options(command, this.env).generateParameters(args); await command.configure(options).validate(); // Execute if (log.isVerbose) log.info('Executing', command.name); const success = await command.execute(); - if (!success) log.warning(`Command ${command.name} failed.`); + if (!success) log.info(`Command ${command.name} failed.`); } catch (error) { log.error(error); Deno.exit(1); diff --git a/src/logic/unity/platform-setup/setup-windows.ts b/src/logic/unity/platform-setup/setup-windows.ts index 78bfa86a..a5d5cce7 100644 --- a/src/logic/unity/platform-setup/setup-windows.ts +++ b/src/logic/unity/platform-setup/setup-windows.ts @@ -2,32 +2,20 @@ import { fsSync as fs, exec } from '../../../dependencies.ts'; import { Parameters } from '../../../model/index.ts'; class SetupWindows { - public static async setup(buildParameters: Parameters) { - const { targetPlatform } = buildParameters; - - await SetupWindows.setupWindowsRun(targetPlatform); + public static async setup(parameters: Parameters) { + await this.generateWinSdkRegistryKey(parameters); } - private static async setupWindowsRun(targetPlatform, silent = false) { - if (!fs.existsSync('c:/regkeys')) { - fs.mkdirSync('c:/regkeys'); - } + private static async generateWinSdkRegistryKey(parameters) { + const { targetPlatform, cliStoragePath } = parameters; - // These all need the Windows 10 SDK - switch (targetPlatform) { - case 'StandaloneWindows': - case 'StandaloneWindows64': - case 'WSAPlayer': - await this.generateWinSDKRegKeys(silent); - break; - } - } + if (!['StandaloneWindows', 'StandaloneWindows64', 'WSAPlayer'].includes(targetPlatform)) return; - private static async generateWinSDKRegKeys(silent = false) { - // Export registry keys that point to the Windows 10 SDK - const exportWinSDKRegKeysCommand = - 'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y'; - await exec(exportWinSDKRegKeysCommand, undefined, { silent }); + const registryKeysPath = `${cliStoragePath}/registry-keys`; + const copyWinSdkRegistryKeyCommand = `reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" ${registryKeysPath}/winsdk.reg /y`; + + await fs.ensureDir(registryKeysPath); + await exec(copyWinSdkRegistryKeyCommand); } } diff --git a/src/model/docker.ts b/src/model/docker.ts index 1b653f08..172a9249 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -43,7 +43,7 @@ class Docker { } static getWindowsCommand(image: any, parameters: any): string { - const { workspace, actionFolder, unitySerial, gitPrivateToken } = parameters; + const { workspace, actionFolder, unitySerial, gitPrivateToken, cliStoragePath } = parameters; return `docker run \ --workdir /github/workspace \ @@ -53,7 +53,7 @@ class Docker { --env GITHUB_WORKSPACE=c:/github/workspace \ ${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \ --volume "${workspace}":"c:/github/workspace" \ - --volume "c:/regkeys":"c:/regkeys" \ + --volume "${cliStoragePath}/registry-keys":"c:/registry-keys" \ --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \ diff --git a/src/model/parameters.ts b/src/model/parameters.ts index 79851962..15a95b76 100644 --- a/src/model/parameters.ts +++ b/src/model/parameters.ts @@ -1,14 +1,10 @@ -import { nanoid } from '../dependencies.ts'; +import { default as getHomeDir } from 'https://deno.land/x/dir@1.5.1/home_dir/mod.ts'; import AndroidVersioning from './android-versioning.ts'; -import CloudRunnerConstants from './cloud-runner/services/cloud-runner-constants.ts'; -import CloudRunnerBuildGuid from './cloud-runner/services/cloud-runner-guid.ts'; import Input from './input.ts'; import Platform from './platform.ts'; import UnityVersioning from './unity-versioning.ts'; import Versioning from './versioning.ts'; import { GitRepoReader } from './input-readers/git-repo.ts'; -import { GithubCliReader } from './input-readers/github-cli.ts'; -import { Cli } from './cli/cli.ts'; import { CommandInterface } from '../commands/command/command-interface.ts'; import { Environment } from '../core/env/environment.ts'; @@ -77,6 +73,8 @@ class Parameters { } public async parse(): Promise { + const cliStoragePath = `${getHomeDir()}/.game-ci`; + const buildFile = Parameters.parseBuildFile( this.input.buildName, this.input.targetPlatform, @@ -131,6 +129,7 @@ class Parameters { log.info(`targetPlatform: "${targetPlatform}"`); const parameters = { + cliStoragePath, editorVersion, customImage: this.input.customImage, unityEmail,