pull/289/head
Frostebite 2021-08-02 00:38:30 +01:00
parent fd8599c0ac
commit 2a1d36b928
3 changed files with 492 additions and 423 deletions

429
dist/index.js vendored
View File

@ -2093,67 +2093,35 @@ const cacheFolder = 'cache';
const cacheFolderFull = `/${buildVolumeFolder}/${cacheFolder}`;
class RemoteBuilder {
static build(buildParameters, baseImage) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const runNumber = process.env.GITHUB_RUN_NUMBER;
if (!runNumber || runNumber === '') {
throw new Error('no run number found, exiting');
}
RemoteBuilder.buildId = remote_builder_namespace_1.default.generateBuildName(RemoteBuilder.readRunNumber(), buildParameters.platform);
RemoteBuilder.buildParams = buildParameters;
RemoteBuilder.buildId = remote_builder_namespace_1.default.generateBuildName(runNumber, buildParameters.platform);
const defaultBranchName = ((_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').filter((x) => {
x = x[0].toUpperCase() + x.slice(1);
return x;
}).join('')) || '';
const branchName = process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
this.SteamDeploy = process.env.STEAM_DEPLOY !== undefined || false;
const token = this.buildParams.githubToken;
RemoteBuilder.newMethod(token);
RemoteBuilder.readBranchNameSetting();
RemoteBuilder.setupDefaultSecrets();
try {
switch (this.buildParams.remoteBuildCluster) {
case 'aws':
core.info('Building with AWS');
this.RemoteBuilderProviderPlatform = new aws_build_platform_1.default(this.buildParams);
break;
default:
case 'k8s':
core.info('Building with Kubernetes');
this.RemoteBuilderProviderPlatform = new kubernetes_build_platform_1.default(this.buildParams);
break;
}
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(this.buildId, this.buildParams, branchName, this.defaultSecrets);
RemoteBuilder.setupBuildPlatform();
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(this.buildId, this.buildParams, this.branchName, this.defaultSecrets);
this.buildPathFull = `/${buildVolumeFolder}/${this.buildId}`;
this.builderPathFull = `${this.buildPathFull}/builder`;
this.steamPathFull = `${this.buildPathFull}/steam`;
this.repoPathFull = `${this.buildPathFull}/${repositoryFolder}`;
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
this.libraryFolderFull = `${this.projectPathFull}/Library`;
yield RemoteBuilder.SetupStep(branchName);
yield RemoteBuilder.SetupStep(this.branchName);
yield RemoteBuilder.BuildStep(baseImage);
yield RemoteBuilder.CompressionStep();
yield RemoteBuilder.UploadArtifacts(branchName);
yield RemoteBuilder.UploadArtifacts(this.branchName);
if (this.SteamDeploy) {
yield RemoteBuilder.DeployToSteam();
}
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, branchName, this.defaultSecrets);
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, this.branchName, this.defaultSecrets);
}
catch (error) {
core.error(JSON.stringify(error, undefined, 4));
core.setFailed('Remote Builder failed');
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, branchName, this.defaultSecrets);
yield RemoteBuilder.handleException(error);
throw error;
}
});
}
static newMethod(token) {
this.defaultSecrets = [
{
ParameterKey: 'GithubToken',
EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: token,
},
];
}
static SetupStep(branchName) {
return __awaiter(this, void 0, void 0, function* () {
core.info('Starting step 1/4 clone and restore cache)');
@ -2206,60 +2174,13 @@ class RemoteBuilder {
echo ' '
#
`,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
], this.defaultSecrets);
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, RemoteBuilder.defaultGitShaEnvironmentVariable, this.defaultSecrets);
});
}
static BuildStep(baseImage) {
return __awaiter(this, void 0, void 0, function* () {
const buildSecrets = new Array();
buildSecrets.push(...this.defaultSecrets);
if (process.env.UNITY_LICENSE)
buildSecrets.push({
ParameterKey: 'UnityLicense',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE,
});
if (process.env.UNITY_EMAIL)
buildSecrets.push({
ParameterKey: 'UnityEmail',
EnvironmentVariable: 'UNITY_EMAIL',
ParameterValue: process.env.UNITY_EMAIL,
});
if (process.env.UNITY_PASSWORD)
buildSecrets.push({
ParameterKey: 'UnityPassword',
EnvironmentVariable: 'UNITY_PASSWORD',
ParameterValue: process.env.UNITY_PASSWORD,
});
if (process.env.UNITY_SERIAL)
buildSecrets.push({
ParameterKey: 'UnitySerial',
EnvironmentVariable: 'UNITY_SERIAL',
ParameterValue: process.env.UNITY_SERIAL,
});
if (this.buildParams.androidKeystoreBase64)
buildSecrets.push({
ParameterKey: 'AndroidKeystoreBase64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParams.androidKeystoreBase64,
});
if (this.buildParams.androidKeystorePass)
buildSecrets.push({
ParameterKey: 'AndroidKeystorePass',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParams.androidKeystorePass,
});
if (this.buildParams.androidKeyaliasPass)
buildSecrets.push({
ParameterKey: 'AndroidKeyAliasPass',
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
ParameterValue: this.buildParams.androidKeyaliasPass,
});
RemoteBuilder.setupBuildSecrets(buildSecrets);
core.info('Starting part 2/4 (build unity project)');
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, baseImage.toString(), [
`
@ -2270,60 +2191,7 @@ class RemoteBuilder {
chmod -R +x "/steps"
/entrypoint.sh
`,
], `/${buildVolumeFolder}`, `/${this.repoPathFull}`, [
{
name: 'ContainerMemory',
value: this.buildParams.remoteBuildMemory,
},
{
name: 'ContainerCpu',
value: this.buildParams.remoteBuildCpu,
},
{
name: 'GITHUB_WORKSPACE',
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
},
{
name: 'PROJECT_PATH',
value: this.buildParams.projectPath,
},
{
name: 'BUILD_PATH',
value: this.buildParams.buildPath,
},
{
name: 'BUILD_FILE',
value: this.buildParams.buildFile,
},
{
name: 'BUILD_NAME',
value: this.buildParams.buildName,
},
{
name: 'BUILD_METHOD',
value: this.buildParams.buildMethod,
},
{
name: 'CUSTOM_PARAMETERS',
value: this.buildParams.customParameters,
},
{
name: 'BUILD_TARGET',
value: this.buildParams.platform,
},
{
name: 'ANDROID_VERSION_CODE',
value: this.buildParams.androidVersionCode.toString(),
},
{
name: 'ANDROID_KEYSTORE_NAME',
value: this.buildParams.androidKeystoreName,
},
{
name: 'ANDROID_KEYALIAS_NAME',
value: this.buildParams.androidKeyaliasName,
},
], buildSecrets);
], `/${buildVolumeFolder}`, `/${this.repoPathFull}`, RemoteBuilder.readBuildEnvironmentVariables(), buildSecrets);
});
}
static CompressionStep() {
@ -2361,28 +2229,7 @@ class RemoteBuilder {
# aws s3 cp /${buildVolumeFolder}/${cacheFolder}/${branchName}/lib-${this.buildId}.zip s3://game-ci-storage/
${this.SteamDeploy ? '#' : ''} rm -r ${this.buildId}
`,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
{
name: 'AWS_DEFAULT_REGION',
value: process.env.AWS_DEFAULT_REGION || '',
},
], [
{
ParameterKey: 'AWSAccessKeyID',
EnvironmentVariable: 'AWS_ACCESS_KEY_ID',
ParameterValue: process.env.AWS_ACCESS_KEY_ID || '',
},
{
ParameterKey: 'AWSSecretAccessKey',
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
},
...this.defaultSecrets,
]);
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, RemoteBuilder.readUploadArtifactEnvironmentVariables(), RemoteBuilder.readUploadArtifactsSecrets());
});
}
static DeployToSteam() {
@ -2404,43 +2251,225 @@ class RemoteBuilder {
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
], [
{
EnvironmentVariable: 'INPUT_APPID',
ParameterKey: 'appId',
ParameterValue: process.env.APP_ID || '',
},
{
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
ParameterKey: 'buildDescription',
ParameterValue: process.env.BUILD_DESCRIPTION || '',
},
{
EnvironmentVariable: 'INPUT_ROOTPATH',
ParameterKey: 'rootPath',
ParameterValue: RemoteBuilder.buildParams.buildPath,
},
{
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
ParameterKey: 'releaseBranch',
ParameterValue: process.env.RELEASE_BRANCH || '',
},
{
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
ParameterKey: 'localContentServer',
ParameterValue: process.env.LOCAL_CONTENT_SERVER || '',
},
{
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
ParameterKey: 'previewEnabled',
ParameterValue: process.env.PREVIEW_ENABLED || '',
},
...this.defaultSecrets,
]);
], RemoteBuilder.readDeployToSteamSecrets());
});
}
static setupBuildPlatform() {
switch (this.buildParams.remoteBuildCluster) {
case 'aws':
core.info('Building with AWS');
this.RemoteBuilderProviderPlatform = new aws_build_platform_1.default(this.buildParams);
break;
default:
case 'k8s':
core.info('Building with Kubernetes');
this.RemoteBuilderProviderPlatform = new kubernetes_build_platform_1.default(this.buildParams);
break;
}
}
static readRunNumber() {
const runNumber = process.env.GITHUB_RUN_NUMBER;
if (!runNumber || runNumber === '') {
throw new Error('no run number found, exiting');
}
return runNumber;
}
static readBranchNameSetting() {
var _a;
const defaultBranchName = ((_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').filter((x) => {
x = x[0].toUpperCase() + x.slice(1);
return x;
}).join('')) || '';
this.branchName =
process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
}
static setupDefaultSecrets() {
this.defaultSecrets = [
{
ParameterKey: 'GithubToken',
EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: this.buildParams.githubToken,
},
];
}
static setupBuildSecrets(buildSecrets) {
buildSecrets.push(...this.defaultSecrets);
if (process.env.UNITY_LICENSE)
buildSecrets.push({
ParameterKey: 'UnityLicense',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE,
});
if (process.env.UNITY_EMAIL)
buildSecrets.push({
ParameterKey: 'UnityEmail',
EnvironmentVariable: 'UNITY_EMAIL',
ParameterValue: process.env.UNITY_EMAIL,
});
if (process.env.UNITY_PASSWORD)
buildSecrets.push({
ParameterKey: 'UnityPassword',
EnvironmentVariable: 'UNITY_PASSWORD',
ParameterValue: process.env.UNITY_PASSWORD,
});
if (process.env.UNITY_SERIAL)
buildSecrets.push({
ParameterKey: 'UnitySerial',
EnvironmentVariable: 'UNITY_SERIAL',
ParameterValue: process.env.UNITY_SERIAL,
});
if (this.buildParams.androidKeystoreBase64)
buildSecrets.push({
ParameterKey: 'AndroidKeystoreBase64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParams.androidKeystoreBase64,
});
if (this.buildParams.androidKeystorePass)
buildSecrets.push({
ParameterKey: 'AndroidKeystorePass',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParams.androidKeystorePass,
});
if (this.buildParams.androidKeyaliasPass)
buildSecrets.push({
ParameterKey: 'AndroidKeyAliasPass',
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
ParameterValue: this.buildParams.androidKeyaliasPass,
});
}
static readUploadArtifactsSecrets() {
return [
{
ParameterKey: 'AWSAccessKeyID',
EnvironmentVariable: 'AWS_ACCESS_KEY_ID',
ParameterValue: process.env.AWS_ACCESS_KEY_ID || '',
},
{
ParameterKey: 'AWSSecretAccessKey',
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
},
...this.defaultSecrets,
];
}
static readDeployToSteamSecrets() {
return [
{
EnvironmentVariable: 'INPUT_APPID',
ParameterKey: 'appId',
ParameterValue: process.env.APP_ID || '',
},
{
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
ParameterKey: 'buildDescription',
ParameterValue: process.env.BUILD_DESCRIPTION || '',
},
{
EnvironmentVariable: 'INPUT_ROOTPATH',
ParameterKey: 'rootPath',
ParameterValue: RemoteBuilder.buildParams.buildPath,
},
{
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
ParameterKey: 'releaseBranch',
ParameterValue: process.env.RELEASE_BRANCH || '',
},
{
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
ParameterKey: 'localContentServer',
ParameterValue: process.env.LOCAL_CONTENT_SERVER || '',
},
{
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
ParameterKey: 'previewEnabled',
ParameterValue: process.env.PREVIEW_ENABLED || '',
},
...this.defaultSecrets,
];
}
static readUploadArtifactEnvironmentVariables() {
return [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
{
name: 'AWS_DEFAULT_REGION',
value: process.env.AWS_DEFAULT_REGION || '',
},
];
}
static readBuildEnvironmentVariables() {
return [
{
name: 'ContainerMemory',
value: this.buildParams.remoteBuildMemory,
},
{
name: 'ContainerCpu',
value: this.buildParams.remoteBuildCpu,
},
{
name: 'GITHUB_WORKSPACE',
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
},
{
name: 'PROJECT_PATH',
value: this.buildParams.projectPath,
},
{
name: 'BUILD_PATH',
value: this.buildParams.buildPath,
},
{
name: 'BUILD_FILE',
value: this.buildParams.buildFile,
},
{
name: 'BUILD_NAME',
value: this.buildParams.buildName,
},
{
name: 'BUILD_METHOD',
value: this.buildParams.buildMethod,
},
{
name: 'CUSTOM_PARAMETERS',
value: this.buildParams.customParameters,
},
{
name: 'BUILD_TARGET',
value: this.buildParams.platform,
},
{
name: 'ANDROID_VERSION_CODE',
value: this.buildParams.androidVersionCode.toString(),
},
{
name: 'ANDROID_KEYSTORE_NAME',
value: this.buildParams.androidKeystoreName,
},
{
name: 'ANDROID_KEYALIAS_NAME',
value: this.buildParams.androidKeyaliasName,
},
];
}
static handleException(error) {
return __awaiter(this, void 0, void 0, function* () {
core.error(JSON.stringify(error, undefined, 4));
core.setFailed('Remote Builder failed');
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, this.branchName, this.defaultSecrets);
});
}
}
RemoteBuilder.SteamDeploy = false;
RemoteBuilder.SteamDeploy = process.env.STEAM_DEPLOY !== undefined || false;
RemoteBuilder.defaultGitShaEnvironmentVariable = [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
];
exports.default = RemoteBuilder;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -5,59 +5,47 @@ import RemoteBuilderNamespace from './remote-builder-namespace';
import RemoteBuilderSecret from './remote-builder-secret';
import { RemoteBuilderProviderInterface } from './remote-builder-provider-interface';
import Kubernetes from './kubernetes-build-platform';
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
const repositoryFolder = 'repo';
const buildVolumeFolder = 'data';
const cacheFolder = 'cache';
const cacheFolderFull = `/${buildVolumeFolder}/${cacheFolder}`;
class RemoteBuilder {
static SteamDeploy: boolean = false;
private static buildId: string;
private static branchName: string;
private static buildParams: BuildParameters;
static RemoteBuilderProviderPlatform: RemoteBuilderProviderInterface;
private static defaultSecrets: RemoteBuilderSecret[];
static SteamDeploy: boolean = process.env.STEAM_DEPLOY !== undefined || false;
private static buildPathFull: string;
private static builderPathFull: string;
private static steamPathFull: string;
private static repoPathFull: string;
private static projectPathFull: string;
private static libraryFolderFull: string;
private static buildId: string;
private static buildParams: BuildParameters;
private static defaultSecrets: RemoteBuilderSecret[];
static RemoteBuilderProviderPlatform: RemoteBuilderProviderInterface;
private static readonly defaultGitShaEnvironmentVariable = [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
];
static async build(buildParameters: BuildParameters, baseImage) {
const runNumber = process.env.GITHUB_RUN_NUMBER;
if (!runNumber || runNumber === '') {
throw new Error('no run number found, exiting');
}
RemoteBuilder.buildId = RemoteBuilderNamespace.generateBuildName(
RemoteBuilder.readRunNumber(),
buildParameters.platform,
);
RemoteBuilder.buildParams = buildParameters;
RemoteBuilder.buildId = RemoteBuilderNamespace.generateBuildName(runNumber, buildParameters.platform);
const defaultBranchName =
process.env.GITHUB_REF?.split('/')
.filter((x) => {
x = x[0].toUpperCase() + x.slice(1);
return x;
})
.join('') || '';
const branchName =
process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
this.SteamDeploy = process.env.STEAM_DEPLOY !== undefined || false;
const token: string = this.buildParams.githubToken;
RemoteBuilder.newMethod(token);
RemoteBuilder.readBranchNameSetting();
RemoteBuilder.setupDefaultSecrets();
try {
switch (this.buildParams.remoteBuildCluster) {
case 'aws':
core.info('Building with AWS');
this.RemoteBuilderProviderPlatform = new AWSBuildPlatform(this.buildParams);
break;
default:
case 'k8s':
core.info('Building with Kubernetes');
this.RemoteBuilderProviderPlatform = new Kubernetes(this.buildParams);
break;
}
RemoteBuilder.setupBuildPlatform();
await this.RemoteBuilderProviderPlatform.setupSharedBuildResources(
this.buildId,
this.buildParams,
branchName,
this.branchName,
this.defaultSecrets,
);
@ -68,42 +56,25 @@ class RemoteBuilder {
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
this.libraryFolderFull = `${this.projectPathFull}/Library`;
await RemoteBuilder.SetupStep(branchName);
await RemoteBuilder.SetupStep(this.branchName);
await RemoteBuilder.BuildStep(baseImage);
await RemoteBuilder.CompressionStep();
await RemoteBuilder.UploadArtifacts(branchName);
await RemoteBuilder.UploadArtifacts(this.branchName);
if (this.SteamDeploy) {
await RemoteBuilder.DeployToSteam();
}
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
this.buildId,
this.buildParams,
branchName,
this.branchName,
this.defaultSecrets,
);
} catch (error) {
core.error(JSON.stringify(error, undefined, 4));
core.setFailed('Remote Builder failed');
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
this.buildId,
this.buildParams,
branchName,
this.defaultSecrets,
);
await RemoteBuilder.handleException(error);
throw error;
}
}
private static newMethod(token: string) {
this.defaultSecrets = [
{
ParameterKey: 'GithubToken',
EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: token,
},
];
}
private static async SetupStep(branchName: string | undefined) {
core.info('Starting step 1/4 clone and restore cache)');
@ -164,69 +135,14 @@ class RemoteBuilder {
],
`/${buildVolumeFolder}`,
`/${buildVolumeFolder}/`,
[
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
],
RemoteBuilder.defaultGitShaEnvironmentVariable,
this.defaultSecrets,
);
}
private static async BuildStep(baseImage: any) {
const buildSecrets = new Array();
buildSecrets.push(...this.defaultSecrets);
if (process.env.UNITY_LICENSE)
buildSecrets.push({
ParameterKey: 'UnityLicense',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE,
});
if (process.env.UNITY_EMAIL)
buildSecrets.push({
ParameterKey: 'UnityEmail',
EnvironmentVariable: 'UNITY_EMAIL',
ParameterValue: process.env.UNITY_EMAIL,
});
if (process.env.UNITY_PASSWORD)
buildSecrets.push({
ParameterKey: 'UnityPassword',
EnvironmentVariable: 'UNITY_PASSWORD',
ParameterValue: process.env.UNITY_PASSWORD,
});
if (process.env.UNITY_SERIAL)
buildSecrets.push({
ParameterKey: 'UnitySerial',
EnvironmentVariable: 'UNITY_SERIAL',
ParameterValue: process.env.UNITY_SERIAL,
});
if (this.buildParams.androidKeystoreBase64)
buildSecrets.push({
ParameterKey: 'AndroidKeystoreBase64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParams.androidKeystoreBase64,
});
if (this.buildParams.androidKeystorePass)
buildSecrets.push({
ParameterKey: 'AndroidKeystorePass',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParams.androidKeystorePass,
});
if (this.buildParams.androidKeyaliasPass)
buildSecrets.push({
ParameterKey: 'AndroidKeyAliasPass',
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
ParameterValue: this.buildParams.androidKeyaliasPass,
});
RemoteBuilder.setupBuildSecrets(buildSecrets);
core.info('Starting part 2/4 (build unity project)');
await this.RemoteBuilderProviderPlatform.runBuildTask(
this.buildId,
@ -243,60 +159,7 @@ class RemoteBuilder {
],
`/${buildVolumeFolder}`,
`/${this.repoPathFull}`,
[
{
name: 'ContainerMemory',
value: this.buildParams.remoteBuildMemory,
},
{
name: 'ContainerCpu',
value: this.buildParams.remoteBuildCpu,
},
{
name: 'GITHUB_WORKSPACE',
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
},
{
name: 'PROJECT_PATH',
value: this.buildParams.projectPath,
},
{
name: 'BUILD_PATH',
value: this.buildParams.buildPath,
},
{
name: 'BUILD_FILE',
value: this.buildParams.buildFile,
},
{
name: 'BUILD_NAME',
value: this.buildParams.buildName,
},
{
name: 'BUILD_METHOD',
value: this.buildParams.buildMethod,
},
{
name: 'CUSTOM_PARAMETERS',
value: this.buildParams.customParameters,
},
{
name: 'BUILD_TARGET',
value: this.buildParams.platform,
},
{
name: 'ANDROID_VERSION_CODE',
value: this.buildParams.androidVersionCode.toString(),
},
{
name: 'ANDROID_KEYSTORE_NAME',
value: this.buildParams.androidKeystoreName,
},
{
name: 'ANDROID_KEYALIAS_NAME',
value: this.buildParams.androidKeyaliasName,
},
],
RemoteBuilder.readBuildEnvironmentVariables(),
buildSecrets,
);
}
@ -348,29 +211,8 @@ class RemoteBuilder {
],
`/${buildVolumeFolder}`,
`/${buildVolumeFolder}/`,
[
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
{
name: 'AWS_DEFAULT_REGION',
value: process.env.AWS_DEFAULT_REGION || '',
},
],
[
{
ParameterKey: 'AWSAccessKeyID',
EnvironmentVariable: 'AWS_ACCESS_KEY_ID',
ParameterValue: process.env.AWS_ACCESS_KEY_ID || '',
},
{
ParameterKey: 'AWSSecretAccessKey',
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
},
...this.defaultSecrets,
],
RemoteBuilder.readUploadArtifactEnvironmentVariables(),
RemoteBuilder.readUploadArtifactsSecrets(),
);
}
@ -399,39 +241,237 @@ class RemoteBuilder {
value: process.env.GITHUB_SHA || '',
},
],
[
{
EnvironmentVariable: 'INPUT_APPID',
ParameterKey: 'appId',
ParameterValue: process.env.APP_ID || '',
},
{
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
ParameterKey: 'buildDescription',
ParameterValue: process.env.BUILD_DESCRIPTION || '',
},
{
EnvironmentVariable: 'INPUT_ROOTPATH',
ParameterKey: 'rootPath',
ParameterValue: RemoteBuilder.buildParams.buildPath,
},
{
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
ParameterKey: 'releaseBranch',
ParameterValue: process.env.RELEASE_BRANCH || '',
},
{
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
ParameterKey: 'localContentServer',
ParameterValue: process.env.LOCAL_CONTENT_SERVER || '',
},
{
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
ParameterKey: 'previewEnabled',
ParameterValue: process.env.PREVIEW_ENABLED || '',
},
...this.defaultSecrets,
],
RemoteBuilder.readDeployToSteamSecrets(),
);
}
private static setupBuildPlatform() {
switch (this.buildParams.remoteBuildCluster) {
case 'aws':
core.info('Building with AWS');
this.RemoteBuilderProviderPlatform = new AWSBuildPlatform(this.buildParams);
break;
default:
case 'k8s':
core.info('Building with Kubernetes');
this.RemoteBuilderProviderPlatform = new Kubernetes(this.buildParams);
break;
}
}
private static readRunNumber() {
const runNumber = process.env.GITHUB_RUN_NUMBER;
if (!runNumber || runNumber === '') {
throw new Error('no run number found, exiting');
}
return runNumber;
}
private static readBranchNameSetting() {
const defaultBranchName =
process.env.GITHUB_REF?.split('/')
.filter((x) => {
x = x[0].toUpperCase() + x.slice(1);
return x;
})
.join('') || '';
this.branchName =
process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
}
private static setupDefaultSecrets() {
this.defaultSecrets = [
{
ParameterKey: 'GithubToken',
EnvironmentVariable: 'GITHUB_TOKEN',
ParameterValue: this.buildParams.githubToken,
},
];
}
private static setupBuildSecrets(buildSecrets: any[]) {
buildSecrets.push(...this.defaultSecrets);
if (process.env.UNITY_LICENSE)
buildSecrets.push({
ParameterKey: 'UnityLicense',
EnvironmentVariable: 'UNITY_LICENSE',
ParameterValue: process.env.UNITY_LICENSE,
});
if (process.env.UNITY_EMAIL)
buildSecrets.push({
ParameterKey: 'UnityEmail',
EnvironmentVariable: 'UNITY_EMAIL',
ParameterValue: process.env.UNITY_EMAIL,
});
if (process.env.UNITY_PASSWORD)
buildSecrets.push({
ParameterKey: 'UnityPassword',
EnvironmentVariable: 'UNITY_PASSWORD',
ParameterValue: process.env.UNITY_PASSWORD,
});
if (process.env.UNITY_SERIAL)
buildSecrets.push({
ParameterKey: 'UnitySerial',
EnvironmentVariable: 'UNITY_SERIAL',
ParameterValue: process.env.UNITY_SERIAL,
});
if (this.buildParams.androidKeystoreBase64)
buildSecrets.push({
ParameterKey: 'AndroidKeystoreBase64',
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
ParameterValue: this.buildParams.androidKeystoreBase64,
});
if (this.buildParams.androidKeystorePass)
buildSecrets.push({
ParameterKey: 'AndroidKeystorePass',
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
ParameterValue: this.buildParams.androidKeystorePass,
});
if (this.buildParams.androidKeyaliasPass)
buildSecrets.push({
ParameterKey: 'AndroidKeyAliasPass',
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
ParameterValue: this.buildParams.androidKeyaliasPass,
});
}
private static readUploadArtifactsSecrets() {
return [
{
ParameterKey: 'AWSAccessKeyID',
EnvironmentVariable: 'AWS_ACCESS_KEY_ID',
ParameterValue: process.env.AWS_ACCESS_KEY_ID || '',
},
{
ParameterKey: 'AWSSecretAccessKey',
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
},
...this.defaultSecrets,
];
}
private static readDeployToSteamSecrets(): RemoteBuilderSecret[] {
return [
{
EnvironmentVariable: 'INPUT_APPID',
ParameterKey: 'appId',
ParameterValue: process.env.APP_ID || '',
},
{
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
ParameterKey: 'buildDescription',
ParameterValue: process.env.BUILD_DESCRIPTION || '',
},
{
EnvironmentVariable: 'INPUT_ROOTPATH',
ParameterKey: 'rootPath',
ParameterValue: RemoteBuilder.buildParams.buildPath,
},
{
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
ParameterKey: 'releaseBranch',
ParameterValue: process.env.RELEASE_BRANCH || '',
},
{
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
ParameterKey: 'localContentServer',
ParameterValue: process.env.LOCAL_CONTENT_SERVER || '',
},
{
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
ParameterKey: 'previewEnabled',
ParameterValue: process.env.PREVIEW_ENABLED || '',
},
...this.defaultSecrets,
];
}
private static readUploadArtifactEnvironmentVariables() {
return [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
{
name: 'AWS_DEFAULT_REGION',
value: process.env.AWS_DEFAULT_REGION || '',
},
];
}
private static readBuildEnvironmentVariables(): RemoteBuilderEnvironmentVariable[] {
return [
{
name: 'ContainerMemory',
value: this.buildParams.remoteBuildMemory,
},
{
name: 'ContainerCpu',
value: this.buildParams.remoteBuildCpu,
},
{
name: 'GITHUB_WORKSPACE',
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
},
{
name: 'PROJECT_PATH',
value: this.buildParams.projectPath,
},
{
name: 'BUILD_PATH',
value: this.buildParams.buildPath,
},
{
name: 'BUILD_FILE',
value: this.buildParams.buildFile,
},
{
name: 'BUILD_NAME',
value: this.buildParams.buildName,
},
{
name: 'BUILD_METHOD',
value: this.buildParams.buildMethod,
},
{
name: 'CUSTOM_PARAMETERS',
value: this.buildParams.customParameters,
},
{
name: 'BUILD_TARGET',
value: this.buildParams.platform,
},
{
name: 'ANDROID_VERSION_CODE',
value: this.buildParams.androidVersionCode.toString(),
},
{
name: 'ANDROID_KEYSTORE_NAME',
value: this.buildParams.androidKeystoreName,
},
{
name: 'ANDROID_KEYALIAS_NAME',
value: this.buildParams.androidKeyaliasName,
},
];
}
private static async handleException(error: unknown) {
core.error(JSON.stringify(error, undefined, 4));
core.setFailed('Remote Builder failed');
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
this.buildId,
this.buildParams,
this.branchName,
this.defaultSecrets,
);
}
}