Move platform validation and setup out of docker and into its own layer, remove branching on docker run command
parent
6f7ae3b1c5
commit
396a2cfde8
|
|
@ -35,9 +35,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__webpack_require__(42186));
|
const core = __importStar(__webpack_require__(42186));
|
||||||
const model_1 = __webpack_require__(41359);
|
const model_1 = __webpack_require__(41359);
|
||||||
|
const platform_setup_1 = __importDefault(__webpack_require__(64423));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
|
@ -59,6 +63,7 @@ function run() {
|
||||||
// default and local case
|
// default and local case
|
||||||
default:
|
default:
|
||||||
core.info('Building locally');
|
core.info('Building locally');
|
||||||
|
platform_setup_1.default.setup(buildParameters);
|
||||||
builtImage = yield model_1.Docker.build({ path: actionFolder, dockerfile, baseImage });
|
builtImage = yield model_1.Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
yield model_1.Docker.run(builtImage, Object.assign({ workspace }, buildParameters));
|
yield model_1.Docker.run(builtImage, Object.assign({ workspace }, buildParameters));
|
||||||
break;
|
break;
|
||||||
|
|
@ -202,6 +207,25 @@ exports.default = AndroidVersioning;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
|
@ -215,6 +239,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const core = __importStar(__webpack_require__(42186));
|
||||||
const android_versioning_1 = __importDefault(__webpack_require__(43059));
|
const android_versioning_1 = __importDefault(__webpack_require__(43059));
|
||||||
const input_1 = __importDefault(__webpack_require__(91933));
|
const input_1 = __importDefault(__webpack_require__(91933));
|
||||||
const platform_1 = __importDefault(__webpack_require__(9707));
|
const platform_1 = __importDefault(__webpack_require__(9707));
|
||||||
|
|
@ -228,9 +253,25 @@ class BuildParameters {
|
||||||
const buildVersion = yield versioning_1.default.determineVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
|
const buildVersion = yield versioning_1.default.determineVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
|
||||||
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
|
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
|
||||||
const androidSdkManagerParameters = android_versioning_1.default.determineSdkManagerParameters(input_1.default.androidTargetSdkVersion);
|
const androidSdkManagerParameters = android_versioning_1.default.determineSdkManagerParameters(input_1.default.androidTargetSdkVersion);
|
||||||
|
let unitySerial = '';
|
||||||
|
if (!process.env.UNITY_SERIAL) {
|
||||||
|
//No serial was present so it is a personal license that we need to convert
|
||||||
|
if (!process.env.UNITY_LICENSE) {
|
||||||
|
throw new Error(`Missing Unity License File and no Serial was found. If this
|
||||||
|
is a personal license, make sure to follow the activation
|
||||||
|
steps and set the UNITY_LICENSE GitHub secret or enter a Unity
|
||||||
|
serial number inside the UNITY_SERIAL GitHub secret.`);
|
||||||
|
}
|
||||||
|
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unitySerial = process.env.UNITY_SERIAL;
|
||||||
|
}
|
||||||
|
core.setSecret(unitySerial);
|
||||||
return {
|
return {
|
||||||
version: unityVersion,
|
version: unityVersion,
|
||||||
customImage: input_1.default.customImage,
|
customImage: input_1.default.customImage,
|
||||||
|
unitySerial,
|
||||||
runnerTempPath: process.env.RUNNER_TEMP,
|
runnerTempPath: process.env.RUNNER_TEMP,
|
||||||
platform: input_1.default.targetPlatform,
|
platform: input_1.default.targetPlatform,
|
||||||
projectPath: input_1.default.projectPath,
|
projectPath: input_1.default.projectPath,
|
||||||
|
|
@ -271,6 +312,17 @@ class BuildParameters {
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
static getSerialFromLicenseFile(license) {
|
||||||
|
const startKey = `<DeveloperData Value="`;
|
||||||
|
const endKey = `"/>`;
|
||||||
|
const startIndex = license.indexOf(startKey) + startKey.length;
|
||||||
|
if (startIndex < 0) {
|
||||||
|
throw new Error(`License File was corrupted, unable to locate serial`);
|
||||||
|
}
|
||||||
|
const endIndex = license.indexOf(endKey, startIndex);
|
||||||
|
// Slice off the first 4 characters as they are garbage values
|
||||||
|
return Buffer.from(license.slice(startIndex, endIndex), 'base64').toString('binary').slice(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.default = BuildParameters;
|
exports.default = BuildParameters;
|
||||||
|
|
||||||
|
|
@ -336,25 +388,6 @@ exports.default = Cache;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
|
@ -368,10 +401,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__webpack_require__(42186));
|
|
||||||
const exec_1 = __webpack_require__(71514);
|
const exec_1 = __webpack_require__(71514);
|
||||||
const image_tag_1 = __importDefault(__webpack_require__(57648));
|
const image_tag_1 = __importDefault(__webpack_require__(57648));
|
||||||
const fs = __webpack_require__(35747);
|
|
||||||
class Docker {
|
class Docker {
|
||||||
static build(buildParameters, silent = false) {
|
static build(buildParameters, silent = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -388,217 +419,77 @@ class Docker {
|
||||||
}
|
}
|
||||||
static run(image, parameters, silent = false) {
|
static run(image, parameters, silent = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { version, workspace, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, androidTargetSdkVersion, androidSdkManagerParameters, customParameters, sshAgent, gitPrivateToken, chownFilesTo, } = parameters;
|
const { version, workspace, unitySerial, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, androidTargetSdkVersion, androidSdkManagerParameters, customParameters, sshAgent, gitPrivateToken, chownFilesTo, } = parameters;
|
||||||
switch (process.platform) {
|
const baseOSSpecificArgs = this.getBaseOSSpecificArgs(process.platform, parameters);
|
||||||
case 'linux': {
|
const runCommand = `docker run \
|
||||||
const linuxRunCommand = `docker run \
|
--workdir /github/workspace \
|
||||||
--workdir /github/workspace \
|
--rm \
|
||||||
--rm \
|
--env UNITY_LICENSE \
|
||||||
--env UNITY_LICENSE \
|
--env UNITY_LICENSE_FILE \
|
||||||
--env UNITY_LICENSE_FILE \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_EMAIL \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_VERSION="${version}" \
|
||||||
--env UNITY_SERIAL \
|
--env USYM_UPLOAD_AUTH_TOKEN \
|
||||||
--env UNITY_VERSION="${version}" \
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
--env USYM_UPLOAD_AUTH_TOKEN \
|
--env BUILD_TARGET="${platform}" \
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
--env BUILD_NAME="${buildName}" \
|
||||||
--env BUILD_TARGET="${platform}" \
|
--env BUILD_PATH="${buildPath}" \
|
||||||
--env BUILD_NAME="${buildName}" \
|
--env BUILD_FILE="${buildFile}" \
|
||||||
--env BUILD_PATH="${buildPath}" \
|
--env BUILD_METHOD="${buildMethod}" \
|
||||||
--env BUILD_FILE="${buildFile}" \
|
--env VERSION="${buildVersion}" \
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
||||||
--env VERSION="${buildVersion}" \
|
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
||||||
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
||||||
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
||||||
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
||||||
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
||||||
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
||||||
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
||||||
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env GITHUB_REF \
|
||||||
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
--env GITHUB_SHA \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REPOSITORY \
|
||||||
--env GITHUB_SHA \
|
--env GITHUB_ACTOR \
|
||||||
--env GITHUB_REPOSITORY \
|
--env GITHUB_WORKFLOW \
|
||||||
--env GITHUB_ACTOR \
|
--env GITHUB_HEAD_REF \
|
||||||
--env GITHUB_WORKFLOW \
|
--env GITHUB_BASE_REF \
|
||||||
--env GITHUB_HEAD_REF \
|
--env GITHUB_EVENT_NAME \
|
||||||
--env GITHUB_BASE_REF \
|
--env GITHUB_WORKSPACE=/github/workspace \
|
||||||
--env GITHUB_EVENT_NAME \
|
--env GITHUB_ACTION \
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
--env GITHUB_EVENT_PATH \
|
||||||
--env GITHUB_ACTION \
|
--env RUNNER_OS \
|
||||||
--env GITHUB_EVENT_PATH \
|
--env RUNNER_TOOL_CACHE \
|
||||||
--env RUNNER_OS \
|
--env RUNNER_TEMP \
|
||||||
--env RUNNER_TOOL_CACHE \
|
--env RUNNER_WORKSPACE \
|
||||||
--env RUNNER_TEMP \
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
--env RUNNER_WORKSPACE \
|
${baseOSSpecificArgs} \
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
${image}`;
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
yield exec_1.exec(runCommand, undefined, { silent });
|
||||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
|
||||||
--volume "${runnerTempPath}/_github_home":"/root" \
|
|
||||||
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
|
|
||||||
--volume "${workspace}":"/github/workspace" \
|
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
|
||||||
${image}`;
|
|
||||||
yield exec_1.exec(linuxRunCommand, undefined, { silent });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'win32': {
|
|
||||||
let unitySerial = '';
|
|
||||||
if (!process.env.UNITY_SERIAL) {
|
|
||||||
//No serial was present so it is a personal license that we need to convert
|
|
||||||
if (!process.env.UNITY_LICENSE) {
|
|
||||||
throw new Error(`Missing Unity License File and no Serial was found. If this
|
|
||||||
is a personal license, make sure to follow the activation
|
|
||||||
steps and set the UNITY_LICENSE GitHub secret or enter a Unity
|
|
||||||
serial number inside the UNITY_SERIAL GitHub secret.`);
|
|
||||||
}
|
|
||||||
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
unitySerial = process.env.UNITY_SERIAL;
|
|
||||||
}
|
|
||||||
core.setSecret(unitySerial);
|
|
||||||
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
|
|
||||||
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
|
|
||||||
}
|
|
||||||
yield this.setupWindowsRun(platform);
|
|
||||||
this.validateWindowsPlatformRequirements(platform);
|
|
||||||
const windowsRunCommand = `docker run \
|
|
||||||
--workdir c:/github/workspace \
|
|
||||||
--rm \
|
|
||||||
--env UNITY_LICENSE \
|
|
||||||
--env UNITY_LICENSE_FILE \
|
|
||||||
--env UNITY_EMAIL \
|
|
||||||
--env UNITY_PASSWORD \
|
|
||||||
--env UNITY_SERIAL="${unitySerial}" \
|
|
||||||
--env UNITY_VERSION="${version}" \
|
|
||||||
--env USYM_UPLOAD_AUTH_TOKEN \
|
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
|
||||||
--env BUILD_TARGET="${platform}" \
|
|
||||||
--env BUILD_NAME="${buildName}" \
|
|
||||||
--env BUILD_PATH="${buildPath}" \
|
|
||||||
--env BUILD_FILE="${buildFile}" \
|
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
|
||||||
--env VERSION="${buildVersion}" \
|
|
||||||
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
|
||||||
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
|
||||||
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
|
||||||
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
|
||||||
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
|
||||||
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
|
||||||
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
|
||||||
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
|
||||||
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
|
||||||
--env GITHUB_REF \
|
|
||||||
--env GITHUB_SHA \
|
|
||||||
--env GITHUB_REPOSITORY \
|
|
||||||
--env GITHUB_ACTOR \
|
|
||||||
--env GITHUB_WORKFLOW \
|
|
||||||
--env GITHUB_HEAD_REF \
|
|
||||||
--env GITHUB_BASE_REF \
|
|
||||||
--env GITHUB_EVENT_NAME \
|
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
|
||||||
--env GITHUB_ACTION \
|
|
||||||
--env GITHUB_EVENT_PATH \
|
|
||||||
--env RUNNER_OS \
|
|
||||||
--env RUNNER_TOOL_CACHE \
|
|
||||||
--env RUNNER_TEMP \
|
|
||||||
--env RUNNER_WORKSPACE \
|
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
|
||||||
--volume "${workspace}":"c:/github/workspace" \
|
|
||||||
--volume "c:/regkeys":"c:/regkeys" \
|
|
||||||
--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" \
|
|
||||||
${image}`;
|
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
|
||||||
yield exec_1.exec(windowsRunCommand, undefined, { silent });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new Error(`Can't run docker on unsupported host platform`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Setup prerequisite files/folders for a windows-based docker run
|
static getBaseOSSpecificArgs(baseOS, parameters) {
|
||||||
static setupWindowsRun(platform, silent = false) {
|
const { version, workspace, unitySerial, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, androidTargetSdkVersion, androidSdkManagerParameters, customParameters, sshAgent, gitPrivateToken, chownFilesTo, } = parameters;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
switch (baseOS) {
|
||||||
if (!fs.existsSync('c:/regkeys')) {
|
case 'win32':
|
||||||
fs.mkdirSync('c:/regkeys');
|
return `--env UNITY_SERIAL="${unitySerial} \
|
||||||
}
|
--volume "${workspace}":"c:/github/workspace" \
|
||||||
switch (platform) {
|
--volume "c:/regkeys":"c:/regkeys" \
|
||||||
//These all need the Windows 10 SDK
|
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
|
||||||
case 'StandaloneWindows':
|
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
|
||||||
this.generateWinSDKRegKeys(silent);
|
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
|
||||||
break;
|
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||||
case 'StandaloneWindows64':
|
case 'linux':
|
||||||
this.generateWinSDKRegKeys(silent);
|
return `--env UNITY_SERIAL
|
||||||
break;
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
case 'WSAPlayer':
|
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
||||||
this.generateWinSDKRegKeys(silent);
|
--volume "${runnerTempPath}/_github_home":"/root" \
|
||||||
break;
|
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
|
||||||
}
|
--volume "${workspace}":"/github/workspace" \
|
||||||
});
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
}
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
||||||
static generateWinSDKRegKeys(silent = false) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Export registry keys that point to the location of the windows 10 sdk
|
|
||||||
const exportWinSDKRegKeysCommand = 'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y';
|
|
||||||
yield exec_1.exec(exportWinSDKRegKeysCommand, undefined, { silent });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static validateWindowsPlatformRequirements(platform) {
|
|
||||||
switch (platform) {
|
|
||||||
case 'StandaloneWindows':
|
|
||||||
this.checkForVisualStudio();
|
|
||||||
this.checkForWin10SDK();
|
|
||||||
break;
|
|
||||||
case 'StandaloneWindows64':
|
|
||||||
this.checkForVisualStudio();
|
|
||||||
this.checkForWin10SDK();
|
|
||||||
break;
|
|
||||||
case 'WSAPlayer':
|
|
||||||
this.checkForVisualStudio();
|
|
||||||
this.checkForWin10SDK();
|
|
||||||
break;
|
|
||||||
case 'tvOS':
|
|
||||||
this.checkForVisualStudio();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return '';
|
||||||
static checkForWin10SDK() {
|
|
||||||
//Check for Windows 10 SDK on runner
|
|
||||||
if (!fs.existsSync('C:/Program Files (x86)/Windows Kits')) {
|
|
||||||
throw new Error(`Windows 10 SDK not found in default location. Make sure
|
|
||||||
the runner has a Windows 10 SDK installed in the default
|
|
||||||
location.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static checkForVisualStudio() {
|
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
|
||||||
if (!(fs.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') &&
|
|
||||||
fs.existsSync('C:/ProgramData/Microsoft/VisualStudio'))) {
|
|
||||||
throw new Error(`Visual Studio not found at the default location.
|
|
||||||
Make sure the runner has Visual Studio installed in the
|
|
||||||
default location`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static getSerialFromLicenseFile(license) {
|
|
||||||
const startKey = `<DeveloperData Value="`;
|
|
||||||
const endKey = `"/>`;
|
|
||||||
const startIndex = license.indexOf(startKey) + startKey.length;
|
|
||||||
if (startIndex < 0) {
|
|
||||||
throw new Error(`License File was corrupted, unable to locate serial`);
|
|
||||||
}
|
|
||||||
const endIndex = license.indexOf(endKey, startIndex);
|
|
||||||
// Slice off the first 4 characters as they are garbage values
|
|
||||||
return Buffer.from(license.slice(startIndex, endIndex), 'base64').toString('binary').slice(4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.default = Docker;
|
exports.default = Docker;
|
||||||
|
|
@ -1338,6 +1229,160 @@ class Output {
|
||||||
exports.default = Output;
|
exports.default = Output;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 64423:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const setup_windows_1 = __importDefault(__webpack_require__(37449));
|
||||||
|
const validate_windows_1 = __importDefault(__webpack_require__(41563));
|
||||||
|
class PlatformSetup {
|
||||||
|
static setup(buildParameters) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'win32':
|
||||||
|
validate_windows_1.default.validate(buildParameters);
|
||||||
|
setup_windows_1.default.setup(buildParameters);
|
||||||
|
break;
|
||||||
|
//Add other baseOS's here
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.default = PlatformSetup;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 37449:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const exec_1 = __webpack_require__(71514);
|
||||||
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
|
class SetupWindows {
|
||||||
|
static setup(buildParameters) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield SetupWindows.setupWindowsRun(buildParameters.platform);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//Setup prerequisite files/folders for a windows-based docker run
|
||||||
|
static setupWindowsRun(platform, silent = false) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!fs_1.default.existsSync('c:/regkeys')) {
|
||||||
|
fs_1.default.mkdirSync('c:/regkeys');
|
||||||
|
}
|
||||||
|
switch (platform) {
|
||||||
|
//These all need the Windows 10 SDK
|
||||||
|
case 'StandaloneWindows':
|
||||||
|
case 'StandaloneWindows64':
|
||||||
|
case 'WSAPlayer':
|
||||||
|
this.generateWinSDKRegKeys(silent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static generateWinSDKRegKeys(silent = false) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// Export registry keys that point to the location of the windows 10 sdk
|
||||||
|
const exportWinSDKRegKeysCommand = 'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y';
|
||||||
|
yield exec_1.exec(exportWinSDKRegKeysCommand, undefined, { silent });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.default = SetupWindows;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 41563:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
|
class ValidateWindows {
|
||||||
|
static validate(buildParameters) {
|
||||||
|
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.platform);
|
||||||
|
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
|
||||||
|
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static validateWindowsPlatformRequirements(platform) {
|
||||||
|
switch (platform) {
|
||||||
|
case 'StandaloneWindows':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'StandaloneWindows64':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'WSAPlayer':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'tvOS':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static checkForWin10SDK() {
|
||||||
|
//Check for Windows 10 SDK on runner
|
||||||
|
if (!fs_1.default.existsSync('C:/Program Files (x86)/Windows Kits')) {
|
||||||
|
throw new Error(`Windows 10 SDK not found in default location. Make sure
|
||||||
|
the runner has a Windows 10 SDK installed in the default
|
||||||
|
location.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static checkForVisualStudio() {
|
||||||
|
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||||
|
if (!(fs_1.default.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') &&
|
||||||
|
fs_1.default.existsSync('C:/ProgramData/Microsoft/VisualStudio'))) {
|
||||||
|
throw new Error(`Visual Studio not found at the default location.
|
||||||
|
Make sure the runner has Visual Studio installed in the
|
||||||
|
default location`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.default = ValidateWindows;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9707:
|
/***/ 9707:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,6 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output, RemoteBuilder } from './model';
|
import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output, RemoteBuilder } from './model';
|
||||||
|
import PlatformSetup from './model/platform-setup';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -26,6 +27,7 @@ async function run() {
|
||||||
// default and local case
|
// default and local case
|
||||||
default:
|
default:
|
||||||
core.info('Building locally');
|
core.info('Building locally');
|
||||||
|
PlatformSetup.setup(buildParameters);
|
||||||
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
await Docker.run(builtImage, { workspace, ...buildParameters });
|
await Docker.run(builtImage, { workspace, ...buildParameters });
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
import AndroidVersioning from './android-versioning';
|
import AndroidVersioning from './android-versioning';
|
||||||
import Input from './input';
|
import Input from './input';
|
||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
|
|
@ -7,6 +8,7 @@ import Versioning from './versioning';
|
||||||
class BuildParameters {
|
class BuildParameters {
|
||||||
public version!: string;
|
public version!: string;
|
||||||
public customImage!: string;
|
public customImage!: string;
|
||||||
|
public unitySerial!: string;
|
||||||
public runnerTempPath: string | undefined;
|
public runnerTempPath: string | undefined;
|
||||||
public platform!: string;
|
public platform!: string;
|
||||||
public projectPath!: string;
|
public projectPath!: string;
|
||||||
|
|
@ -47,9 +49,25 @@ class BuildParameters {
|
||||||
|
|
||||||
const androidSdkManagerParameters = AndroidVersioning.determineSdkManagerParameters(Input.androidTargetSdkVersion);
|
const androidSdkManagerParameters = AndroidVersioning.determineSdkManagerParameters(Input.androidTargetSdkVersion);
|
||||||
|
|
||||||
|
let unitySerial = '';
|
||||||
|
if (!process.env.UNITY_SERIAL) {
|
||||||
|
//No serial was present so it is a personal license that we need to convert
|
||||||
|
if (!process.env.UNITY_LICENSE) {
|
||||||
|
throw new Error(`Missing Unity License File and no Serial was found. If this
|
||||||
|
is a personal license, make sure to follow the activation
|
||||||
|
steps and set the UNITY_LICENSE GitHub secret or enter a Unity
|
||||||
|
serial number inside the UNITY_SERIAL GitHub secret.`);
|
||||||
|
}
|
||||||
|
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
||||||
|
} else {
|
||||||
|
unitySerial = process.env.UNITY_SERIAL!;
|
||||||
|
}
|
||||||
|
core.setSecret(unitySerial);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: unityVersion,
|
version: unityVersion,
|
||||||
customImage: Input.customImage,
|
customImage: Input.customImage,
|
||||||
|
unitySerial,
|
||||||
|
|
||||||
runnerTempPath: process.env.RUNNER_TEMP,
|
runnerTempPath: process.env.RUNNER_TEMP,
|
||||||
platform: Input.targetPlatform,
|
platform: Input.targetPlatform,
|
||||||
|
|
@ -93,6 +111,18 @@ class BuildParameters {
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getSerialFromLicenseFile(license) {
|
||||||
|
const startKey = `<DeveloperData Value="`;
|
||||||
|
const endKey = `"/>`;
|
||||||
|
const startIndex = license.indexOf(startKey) + startKey.length;
|
||||||
|
if (startIndex < 0) {
|
||||||
|
throw new Error(`License File was corrupted, unable to locate serial`);
|
||||||
|
}
|
||||||
|
const endIndex = license.indexOf(endKey, startIndex);
|
||||||
|
// Slice off the first 4 characters as they are garbage values
|
||||||
|
return Buffer.from(license.slice(startIndex, endIndex), 'base64').toString('binary').slice(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BuildParameters;
|
export default BuildParameters;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import * as core from '@actions/core';
|
|
||||||
import { exec } from '@actions/exec';
|
import { exec } from '@actions/exec';
|
||||||
import ImageTag from './image-tag';
|
import ImageTag from './image-tag';
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
class Docker {
|
class Docker {
|
||||||
static async build(buildParameters, silent = false) {
|
static async build(buildParameters, silent = false) {
|
||||||
|
|
@ -23,6 +21,7 @@ class Docker {
|
||||||
const {
|
const {
|
||||||
version,
|
version,
|
||||||
workspace,
|
workspace,
|
||||||
|
unitySerial,
|
||||||
runnerTempPath,
|
runnerTempPath,
|
||||||
platform,
|
platform,
|
||||||
projectPath,
|
projectPath,
|
||||||
|
|
@ -45,227 +44,103 @@ class Docker {
|
||||||
chownFilesTo,
|
chownFilesTo,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
switch (process.platform) {
|
const baseOSSpecificArgs = this.getBaseOSSpecificArgs(process.platform, parameters);
|
||||||
case 'linux': {
|
|
||||||
const linuxRunCommand = `docker run \
|
|
||||||
--workdir /github/workspace \
|
|
||||||
--rm \
|
|
||||||
--env UNITY_LICENSE \
|
|
||||||
--env UNITY_LICENSE_FILE \
|
|
||||||
--env UNITY_EMAIL \
|
|
||||||
--env UNITY_PASSWORD \
|
|
||||||
--env UNITY_SERIAL \
|
|
||||||
--env UNITY_VERSION="${version}" \
|
|
||||||
--env USYM_UPLOAD_AUTH_TOKEN \
|
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
|
||||||
--env BUILD_TARGET="${platform}" \
|
|
||||||
--env BUILD_NAME="${buildName}" \
|
|
||||||
--env BUILD_PATH="${buildPath}" \
|
|
||||||
--env BUILD_FILE="${buildFile}" \
|
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
|
||||||
--env VERSION="${buildVersion}" \
|
|
||||||
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
|
||||||
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
|
||||||
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
|
||||||
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
|
||||||
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
|
||||||
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
|
||||||
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
|
||||||
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
|
||||||
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
|
||||||
--env GITHUB_REF \
|
|
||||||
--env GITHUB_SHA \
|
|
||||||
--env GITHUB_REPOSITORY \
|
|
||||||
--env GITHUB_ACTOR \
|
|
||||||
--env GITHUB_WORKFLOW \
|
|
||||||
--env GITHUB_HEAD_REF \
|
|
||||||
--env GITHUB_BASE_REF \
|
|
||||||
--env GITHUB_EVENT_NAME \
|
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
|
||||||
--env GITHUB_ACTION \
|
|
||||||
--env GITHUB_EVENT_PATH \
|
|
||||||
--env RUNNER_OS \
|
|
||||||
--env RUNNER_TOOL_CACHE \
|
|
||||||
--env RUNNER_TEMP \
|
|
||||||
--env RUNNER_WORKSPACE \
|
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
|
||||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
|
||||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
|
||||||
--volume "${runnerTempPath}/_github_home":"/root" \
|
|
||||||
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
|
|
||||||
--volume "${workspace}":"/github/workspace" \
|
|
||||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
|
||||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
|
||||||
${image}`;
|
|
||||||
|
|
||||||
await exec(linuxRunCommand, undefined, { silent });
|
const runCommand = `docker run \
|
||||||
break;
|
--workdir /github/workspace \
|
||||||
}
|
--rm \
|
||||||
case 'win32': {
|
--env UNITY_LICENSE \
|
||||||
let unitySerial = '';
|
--env UNITY_LICENSE_FILE \
|
||||||
if (!process.env.UNITY_SERIAL) {
|
--env UNITY_EMAIL \
|
||||||
//No serial was present so it is a personal license that we need to convert
|
--env UNITY_PASSWORD \
|
||||||
if (!process.env.UNITY_LICENSE) {
|
--env UNITY_VERSION="${version}" \
|
||||||
throw new Error(`Missing Unity License File and no Serial was found. If this
|
--env USYM_UPLOAD_AUTH_TOKEN \
|
||||||
is a personal license, make sure to follow the activation
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
steps and set the UNITY_LICENSE GitHub secret or enter a Unity
|
--env BUILD_TARGET="${platform}" \
|
||||||
serial number inside the UNITY_SERIAL GitHub secret.`);
|
--env BUILD_NAME="${buildName}" \
|
||||||
}
|
--env BUILD_PATH="${buildPath}" \
|
||||||
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
--env BUILD_FILE="${buildFile}" \
|
||||||
} else {
|
--env BUILD_METHOD="${buildMethod}" \
|
||||||
unitySerial = process.env.UNITY_SERIAL!;
|
--env VERSION="${buildVersion}" \
|
||||||
}
|
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
||||||
core.setSecret(unitySerial);
|
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
||||||
|
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
||||||
|
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
||||||
|
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
||||||
|
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
||||||
|
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
||||||
|
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
||||||
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
|
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
||||||
|
--env GITHUB_REF \
|
||||||
|
--env GITHUB_SHA \
|
||||||
|
--env GITHUB_REPOSITORY \
|
||||||
|
--env GITHUB_ACTOR \
|
||||||
|
--env GITHUB_WORKFLOW \
|
||||||
|
--env GITHUB_HEAD_REF \
|
||||||
|
--env GITHUB_BASE_REF \
|
||||||
|
--env GITHUB_EVENT_NAME \
|
||||||
|
--env GITHUB_WORKSPACE=/github/workspace \
|
||||||
|
--env GITHUB_ACTION \
|
||||||
|
--env GITHUB_EVENT_PATH \
|
||||||
|
--env RUNNER_OS \
|
||||||
|
--env RUNNER_TOOL_CACHE \
|
||||||
|
--env RUNNER_TEMP \
|
||||||
|
--env RUNNER_WORKSPACE \
|
||||||
|
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||||
|
${baseOSSpecificArgs} \
|
||||||
|
${image}`;
|
||||||
|
|
||||||
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
|
await exec(runCommand, undefined, { silent });
|
||||||
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
|
|
||||||
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.setupWindowsRun(platform);
|
|
||||||
|
|
||||||
this.validateWindowsPlatformRequirements(platform);
|
|
||||||
|
|
||||||
const windowsRunCommand = `docker run \
|
|
||||||
--workdir c:/github/workspace \
|
|
||||||
--rm \
|
|
||||||
--env UNITY_LICENSE \
|
|
||||||
--env UNITY_LICENSE_FILE \
|
|
||||||
--env UNITY_EMAIL \
|
|
||||||
--env UNITY_PASSWORD \
|
|
||||||
--env UNITY_SERIAL="${unitySerial}" \
|
|
||||||
--env UNITY_VERSION="${version}" \
|
|
||||||
--env USYM_UPLOAD_AUTH_TOKEN \
|
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
|
||||||
--env BUILD_TARGET="${platform}" \
|
|
||||||
--env BUILD_NAME="${buildName}" \
|
|
||||||
--env BUILD_PATH="${buildPath}" \
|
|
||||||
--env BUILD_FILE="${buildFile}" \
|
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
|
||||||
--env VERSION="${buildVersion}" \
|
|
||||||
--env ANDROID_VERSION_CODE="${androidVersionCode}" \
|
|
||||||
--env ANDROID_KEYSTORE_NAME="${androidKeystoreName}" \
|
|
||||||
--env ANDROID_KEYSTORE_BASE64="${androidKeystoreBase64}" \
|
|
||||||
--env ANDROID_KEYSTORE_PASS="${androidKeystorePass}" \
|
|
||||||
--env ANDROID_KEYALIAS_NAME="${androidKeyaliasName}" \
|
|
||||||
--env ANDROID_KEYALIAS_PASS="${androidKeyaliasPass}" \
|
|
||||||
--env ANDROID_TARGET_SDK_VERSION="${androidTargetSdkVersion}" \
|
|
||||||
--env ANDROID_SDK_MANAGER_PARAMETERS="${androidSdkManagerParameters}" \
|
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
|
||||||
--env CHOWN_FILES_TO="${chownFilesTo}" \
|
|
||||||
--env GITHUB_REF \
|
|
||||||
--env GITHUB_SHA \
|
|
||||||
--env GITHUB_REPOSITORY \
|
|
||||||
--env GITHUB_ACTOR \
|
|
||||||
--env GITHUB_WORKFLOW \
|
|
||||||
--env GITHUB_HEAD_REF \
|
|
||||||
--env GITHUB_BASE_REF \
|
|
||||||
--env GITHUB_EVENT_NAME \
|
|
||||||
--env GITHUB_WORKSPACE=/github/workspace \
|
|
||||||
--env GITHUB_ACTION \
|
|
||||||
--env GITHUB_EVENT_PATH \
|
|
||||||
--env RUNNER_OS \
|
|
||||||
--env RUNNER_TOOL_CACHE \
|
|
||||||
--env RUNNER_TEMP \
|
|
||||||
--env RUNNER_WORKSPACE \
|
|
||||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
|
||||||
--volume "${workspace}":"c:/github/workspace" \
|
|
||||||
--volume "c:/regkeys":"c:/regkeys" \
|
|
||||||
--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" \
|
|
||||||
${image}`;
|
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
|
||||||
|
|
||||||
await exec(windowsRunCommand, undefined, { silent });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new Error(`Can't run docker on unsupported host platform`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Setup prerequisite files/folders for a windows-based docker run
|
static getBaseOSSpecificArgs(baseOS: NodeJS.Platform, parameters): string {
|
||||||
static async setupWindowsRun(platform, silent = false) {
|
const {
|
||||||
if (!fs.existsSync('c:/regkeys')) {
|
version,
|
||||||
fs.mkdirSync('c:/regkeys');
|
workspace,
|
||||||
}
|
unitySerial,
|
||||||
switch (platform) {
|
runnerTempPath,
|
||||||
//These all need the Windows 10 SDK
|
platform,
|
||||||
case 'StandaloneWindows':
|
projectPath,
|
||||||
this.generateWinSDKRegKeys(silent);
|
buildName,
|
||||||
break;
|
buildPath,
|
||||||
case 'StandaloneWindows64':
|
buildFile,
|
||||||
this.generateWinSDKRegKeys(silent);
|
buildMethod,
|
||||||
break;
|
buildVersion,
|
||||||
case 'WSAPlayer':
|
androidVersionCode,
|
||||||
this.generateWinSDKRegKeys(silent);
|
androidKeystoreName,
|
||||||
break;
|
androidKeystoreBase64,
|
||||||
}
|
androidKeystorePass,
|
||||||
}
|
androidKeyaliasName,
|
||||||
|
androidKeyaliasPass,
|
||||||
|
androidTargetSdkVersion,
|
||||||
|
androidSdkManagerParameters,
|
||||||
|
customParameters,
|
||||||
|
sshAgent,
|
||||||
|
gitPrivateToken,
|
||||||
|
chownFilesTo,
|
||||||
|
} = parameters;
|
||||||
|
|
||||||
static async generateWinSDKRegKeys(silent = false) {
|
switch(baseOS) {
|
||||||
// Export registry keys that point to the location of the windows 10 sdk
|
case 'win32':
|
||||||
const exportWinSDKRegKeysCommand =
|
return `--env UNITY_SERIAL="${unitySerial} \
|
||||||
'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y';
|
--volume "${workspace}":"c:/github/workspace" \
|
||||||
await exec(exportWinSDKRegKeysCommand, undefined, { silent });
|
--volume "c:/regkeys":"c:/regkeys" \
|
||||||
}
|
--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" \
|
||||||
static validateWindowsPlatformRequirements(platform) {
|
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
|
||||||
switch (platform) {
|
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||||
case 'StandaloneWindows':
|
case 'linux':
|
||||||
this.checkForVisualStudio();
|
return `--env UNITY_SERIAL
|
||||||
this.checkForWin10SDK();
|
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||||
break;
|
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
||||||
case 'StandaloneWindows64':
|
--volume "${runnerTempPath}/_github_home":"/root" \
|
||||||
this.checkForVisualStudio();
|
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
|
||||||
this.checkForWin10SDK();
|
--volume "${workspace}":"/github/workspace" \
|
||||||
break;
|
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||||
case 'WSAPlayer':
|
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
||||||
this.checkForVisualStudio();
|
|
||||||
this.checkForWin10SDK();
|
|
||||||
break;
|
|
||||||
case 'tvOS':
|
|
||||||
this.checkForVisualStudio();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return '';
|
||||||
|
|
||||||
static checkForWin10SDK() {
|
|
||||||
//Check for Windows 10 SDK on runner
|
|
||||||
if (!fs.existsSync('C:/Program Files (x86)/Windows Kits')) {
|
|
||||||
throw new Error(`Windows 10 SDK not found in default location. Make sure
|
|
||||||
the runner has a Windows 10 SDK installed in the default
|
|
||||||
location.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static checkForVisualStudio() {
|
|
||||||
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
|
||||||
if (
|
|
||||||
!(
|
|
||||||
fs.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') &&
|
|
||||||
fs.existsSync('C:/ProgramData/Microsoft/VisualStudio')
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
throw new Error(`Visual Studio not found at the default location.
|
|
||||||
Make sure the runner has Visual Studio installed in the
|
|
||||||
default location`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static getSerialFromLicenseFile(license) {
|
|
||||||
const startKey = `<DeveloperData Value="`;
|
|
||||||
const endKey = `"/>`;
|
|
||||||
const startIndex = license.indexOf(startKey) + startKey.length;
|
|
||||||
if (startIndex < 0) {
|
|
||||||
throw new Error(`License File was corrupted, unable to locate serial`);
|
|
||||||
}
|
|
||||||
const endIndex = license.indexOf(endKey, startIndex);
|
|
||||||
// Slice off the first 4 characters as they are garbage values
|
|
||||||
return Buffer.from(license.slice(startIndex, endIndex), 'base64').toString('binary').slice(4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { BuildParameters } from '.';
|
||||||
|
import SetupWindows from './platform-setup/setup-windows';
|
||||||
|
import ValidateWindows from './platform-validation/validate-windows';
|
||||||
|
|
||||||
|
class PlatformSetup {
|
||||||
|
static async setup(buildParameters: BuildParameters) {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'win32':
|
||||||
|
ValidateWindows.validate(buildParameters);
|
||||||
|
SetupWindows.setup(buildParameters);
|
||||||
|
break;
|
||||||
|
//Add other baseOS's here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PlatformSetup;
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { exec } from '@actions/exec';
|
||||||
|
import fs from 'fs';
|
||||||
|
import { BuildParameters } from '..';
|
||||||
|
|
||||||
|
class SetupWindows {
|
||||||
|
public static async setup(buildParameters: BuildParameters) {
|
||||||
|
await SetupWindows.setupWindowsRun(buildParameters.platform);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setup prerequisite files/folders for a windows-based docker run
|
||||||
|
private static async setupWindowsRun(platform, silent = false) {
|
||||||
|
if (!fs.existsSync('c:/regkeys')) {
|
||||||
|
fs.mkdirSync('c:/regkeys');
|
||||||
|
}
|
||||||
|
switch (platform) {
|
||||||
|
//These all need the Windows 10 SDK
|
||||||
|
case 'StandaloneWindows':
|
||||||
|
case 'StandaloneWindows64':
|
||||||
|
case 'WSAPlayer':
|
||||||
|
this.generateWinSDKRegKeys(silent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async generateWinSDKRegKeys(silent = false) {
|
||||||
|
// Export registry keys that point to the location of 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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SetupWindows;
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
import fs from 'fs';
|
||||||
|
import { BuildParameters } from '..';
|
||||||
|
|
||||||
|
class ValidateWindows {
|
||||||
|
public static validate(buildParameters: BuildParameters) {
|
||||||
|
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.platform)
|
||||||
|
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
|
||||||
|
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static validateWindowsPlatformRequirements(platform) {
|
||||||
|
switch (platform) {
|
||||||
|
case 'StandaloneWindows':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'StandaloneWindows64':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'WSAPlayer':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
this.checkForWin10SDK();
|
||||||
|
break;
|
||||||
|
case 'tvOS':
|
||||||
|
this.checkForVisualStudio();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static checkForWin10SDK() {
|
||||||
|
//Check for Windows 10 SDK on runner
|
||||||
|
if (!fs.existsSync('C:/Program Files (x86)/Windows Kits')) {
|
||||||
|
throw new Error(`Windows 10 SDK not found in default location. Make sure
|
||||||
|
the runner has a Windows 10 SDK installed in the default
|
||||||
|
location.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static checkForVisualStudio() {
|
||||||
|
//Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
|
||||||
|
if (!(fs.existsSync('C:/Program Files (x86)/Microsoft Visual Studio') &&
|
||||||
|
fs.existsSync('C:/ProgramData/Microsoft/VisualStudio'))) {
|
||||||
|
throw new Error(`Visual Studio not found at the default location.
|
||||||
|
Make sure the runner has Visual Studio installed in the
|
||||||
|
default location`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ValidateWindows;
|
||||||
Loading…
Reference in New Issue