fix
parent
681513aec3
commit
8875b32f01
|
|
@ -2099,15 +2099,16 @@ class RemoteBuilder {
|
|||
if (!runNumber || runNumber === '') {
|
||||
throw new Error('no run number found, exiting');
|
||||
}
|
||||
const buildUid = remote_builder_namespace_1.default.generateBuildName(runNumber, 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 = buildParameters.githubToken;
|
||||
const defaultSecretsArray = [
|
||||
const token = this.buildParams.githubToken;
|
||||
this.defaultSecrets = [
|
||||
{
|
||||
ParameterKey: 'GithubToken',
|
||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||
|
|
@ -2115,53 +2116,53 @@ class RemoteBuilder {
|
|||
},
|
||||
];
|
||||
try {
|
||||
switch (buildParameters.remoteBuildCluster) {
|
||||
switch (this.buildParams.remoteBuildCluster) {
|
||||
case 'aws':
|
||||
core.info('Building with AWS');
|
||||
this.RemoteBuilderProviderPlatform = new aws_build_platform_1.default(buildParameters);
|
||||
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(buildParameters);
|
||||
this.RemoteBuilderProviderPlatform = new kubernetes_build_platform_1.default(this.buildParams);
|
||||
break;
|
||||
}
|
||||
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||
this.buildPathFull = `/${buildVolumeFolder}/${buildUid}`;
|
||||
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(this.buildId, this.buildParams, 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}/${buildParameters.projectPath}`;
|
||||
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
|
||||
this.libraryFolderFull = `${this.projectPathFull}/Library`;
|
||||
yield RemoteBuilder.SetupStep(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
yield RemoteBuilder.BuildStep(`${buildUid}`, buildParameters, baseImage, defaultSecretsArray);
|
||||
yield RemoteBuilder.CompressionStep(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
yield RemoteBuilder.UploadArtifacts(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
yield RemoteBuilder.SetupStep(branchName);
|
||||
yield RemoteBuilder.BuildStep(baseImage);
|
||||
yield RemoteBuilder.CompressionStep();
|
||||
yield RemoteBuilder.UploadArtifacts(branchName);
|
||||
if (this.SteamDeploy) {
|
||||
yield RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
||||
yield RemoteBuilder.DeployToSteam();
|
||||
}
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, branchName, this.defaultSecrets);
|
||||
}
|
||||
catch (error) {
|
||||
core.error(JSON.stringify(error, undefined, 4));
|
||||
core.setFailed('Remote Builder failed');
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildId, this.buildParams, branchName, this.defaultSecrets);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
static SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||
static SetupStep(branchName) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
const lfsDirectory = `${this.repoPathFull}/.git/lfs`;
|
||||
const testLFSFile = `${this.projectPathFull}/Assets/LFS_Test_File.jpg`;
|
||||
const repo = `https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const repo2 = `https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git`;
|
||||
const repo3 = `https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
const repo = `https://${this.buildParams.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const repo2 = `https://${this.buildParams.githubToken}@github.com/game-ci/steam-deploy.git`;
|
||||
const repo3 = `https://${this.buildParams.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
const purgeRemoteCache = process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined;
|
||||
const initializeSourceRepoForCaching = `${this.builderPathFull}/dist/remote-builder/cloneNoLFS.sh "${this.repoPathFull}" "${repo3}" "$GITHUB_SHA" "${testLFSFile}"`;
|
||||
const handleCaching = `${this.builderPathFull}/dist/remote-builder/handleCaching.sh "${cacheFolderFull}" "${branchName}" "${this.libraryFolderFull}" "${lfsDirectory}" "${purgeRemoteCache}"`;
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, 'alpine/git', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, 'alpine/git', [
|
||||
` apk update -q
|
||||
apk add unzip zip git-lfs jq tree -q
|
||||
#
|
||||
|
|
@ -2207,13 +2208,13 @@ class RemoteBuilder {
|
|||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], defaultSecretsArray);
|
||||
], this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
static BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray) {
|
||||
static BuildStep(baseImage) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const buildSecrets = new Array();
|
||||
buildSecrets.push(...defaultSecretsArray);
|
||||
buildSecrets.push(...this.defaultSecrets);
|
||||
if (process.env.UNITY_LICENSE)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'UnityLicense',
|
||||
|
|
@ -2238,26 +2239,26 @@ class RemoteBuilder {
|
|||
EnvironmentVariable: 'UNITY_SERIAL',
|
||||
ParameterValue: process.env.UNITY_SERIAL,
|
||||
});
|
||||
if (buildParameters.androidKeystoreBase64)
|
||||
if (this.buildParams.androidKeystoreBase64)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeystoreBase64',
|
||||
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
||||
ParameterValue: buildParameters.androidKeystoreBase64,
|
||||
ParameterValue: this.buildParams.androidKeystoreBase64,
|
||||
});
|
||||
if (buildParameters.androidKeystorePass)
|
||||
if (this.buildParams.androidKeystorePass)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeystorePass',
|
||||
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
||||
ParameterValue: buildParameters.androidKeystorePass,
|
||||
ParameterValue: this.buildParams.androidKeystorePass,
|
||||
});
|
||||
if (buildParameters.androidKeyaliasPass)
|
||||
if (this.buildParams.androidKeyaliasPass)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeyAliasPass',
|
||||
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
||||
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||
ParameterValue: this.buildParams.androidKeyaliasPass,
|
||||
});
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, baseImage.toString(), [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, baseImage.toString(), [
|
||||
`
|
||||
cp -r "${this.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${this.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
|
|
@ -2269,93 +2270,93 @@ class RemoteBuilder {
|
|||
], `/${buildVolumeFolder}`, `/${this.repoPathFull}`, [
|
||||
{
|
||||
name: 'ContainerMemory',
|
||||
value: buildParameters.remoteBuildMemory,
|
||||
value: this.buildParams.remoteBuildMemory,
|
||||
},
|
||||
{
|
||||
name: 'ContainerCpu',
|
||||
value: buildParameters.remoteBuildCpu,
|
||||
value: this.buildParams.remoteBuildCpu,
|
||||
},
|
||||
{
|
||||
name: 'GITHUB_WORKSPACE',
|
||||
value: `/${buildVolumeFolder}/${buildUid}/${repositoryFolder}/`,
|
||||
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
|
||||
},
|
||||
{
|
||||
name: 'PROJECT_PATH',
|
||||
value: buildParameters.projectPath,
|
||||
value: this.buildParams.projectPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_PATH',
|
||||
value: buildParameters.buildPath,
|
||||
value: this.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_FILE',
|
||||
value: buildParameters.buildFile,
|
||||
value: this.buildParams.buildFile,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_NAME',
|
||||
value: buildParameters.buildName,
|
||||
value: this.buildParams.buildName,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_METHOD',
|
||||
value: buildParameters.buildMethod,
|
||||
value: this.buildParams.buildMethod,
|
||||
},
|
||||
{
|
||||
name: 'CUSTOM_PARAMETERS',
|
||||
value: buildParameters.customParameters,
|
||||
value: this.buildParams.customParameters,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: buildParameters.platform,
|
||||
value: this.buildParams.platform,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_VERSION_CODE',
|
||||
value: buildParameters.androidVersionCode.toString(),
|
||||
value: this.buildParams.androidVersionCode.toString(),
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYSTORE_NAME',
|
||||
value: buildParameters.androidKeystoreName,
|
||||
value: this.buildParams.androidKeystoreName,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYALIAS_NAME',
|
||||
value: buildParameters.androidKeyaliasName,
|
||||
value: this.buildParams.androidKeyaliasName,
|
||||
},
|
||||
], buildSecrets);
|
||||
});
|
||||
}
|
||||
static CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||
static CompressionStep() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, 'alpine', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, 'alpine', [
|
||||
`
|
||||
apk update -q
|
||||
apk add zip -q
|
||||
cd "${this.libraryFolderFull}"
|
||||
zip -r "lib-${buildUid}.zip" "${this.libraryFolderFull}"
|
||||
mv "lib-${buildUid}.zip" "${cacheFolderFull}/lib/lib-${buildUid}.zip"
|
||||
zip -r "lib-${this.buildId}.zip" "${this.libraryFolderFull}"
|
||||
mv "lib-${this.buildId}.zip" "${cacheFolderFull}/lib/lib-${this.buildId}.zip"
|
||||
cd "${this.projectPathFull}"
|
||||
ls -lh "${buildParameters.buildPath}"
|
||||
zip -r "build-${buildUid}.zip" "${buildParameters.buildPath}"
|
||||
mv "build-${buildUid}.zip" "/${buildVolumeFolder}/${buildUid}/build-${buildUid}.zip"
|
||||
ls -lh "${RemoteBuilder.buildParams.buildPath}"
|
||||
zip -r "build-${this.buildId}.zip" "${RemoteBuilder.buildParams.buildPath}"
|
||||
mv "build-${this.buildId}.zip" "/${buildVolumeFolder}/${this.buildId}/build-${this.buildId}.zip"
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], defaultSecretsArray);
|
||||
], this.defaultSecrets);
|
||||
core.info('compression step complete');
|
||||
});
|
||||
}
|
||||
static UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||
static UploadArtifacts(branchName) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 4/4 upload build to s3');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, 'amazon/aws-cli', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, 'amazon/aws-cli', [
|
||||
`
|
||||
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||
aws s3 cp ${this.buildId}/build-${this.buildId}.zip s3://game-ci-storage/
|
||||
# no need to upload Library cache for now
|
||||
# aws s3 cp /${buildVolumeFolder}/${cacheFolder}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||
${this.SteamDeploy ? '#' : ''} rm -r ${buildUid}
|
||||
# aws s3 cp /${buildVolumeFolder}/${cacheFolder}/${branchName}/lib-${this.buildId}.zip s3://game-ci-storage/
|
||||
${this.SteamDeploy ? '#' : ''} rm -r ${this.buildId}
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, [
|
||||
{
|
||||
|
|
@ -2377,25 +2378,25 @@ class RemoteBuilder {
|
|||
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
|
||||
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
|
||||
},
|
||||
...defaultSecretsArray,
|
||||
...this.defaultSecrets,
|
||||
]);
|
||||
});
|
||||
}
|
||||
static DeployToSteam(buildUid, buildParameters, defaultSecretsArray) {
|
||||
static DeployToSteam() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting steam deployment');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, 'cm2network/steamcmd:root', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildId, 'cm2network/steamcmd:root', [
|
||||
`
|
||||
ls
|
||||
ls /
|
||||
cp -r /${buildVolumeFolder}/${buildUid}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /${buildVolumeFolder}/${buildUid}/steam/action/steps/ /steps;
|
||||
cp -r /${buildVolumeFolder}/${this.buildId}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /${buildVolumeFolder}/${this.buildId}/steam/action/steps/ /steps;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
rm -r /${buildVolumeFolder}/${buildUid}
|
||||
rm -r /${buildVolumeFolder}/${this.buildId}
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/${buildUid}/steam/action/`, [
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/${this.buildId}/steam/action/`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
|
|
@ -2414,7 +2415,7 @@ class RemoteBuilder {
|
|||
{
|
||||
EnvironmentVariable: 'INPUT_ROOTPATH',
|
||||
ParameterKey: 'rootPath',
|
||||
ParameterValue: buildParameters.buildPath,
|
||||
ParameterValue: RemoteBuilder.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
|
||||
|
|
@ -2431,7 +2432,7 @@ class RemoteBuilder {
|
|||
ParameterKey: 'previewEnabled',
|
||||
ParameterValue: process.env.PREVIEW_ENABLED || '',
|
||||
},
|
||||
...defaultSecretsArray,
|
||||
...this.defaultSecrets,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,6 @@ import AWSBuildPlatform from './aws-build-platform';
|
|||
import * as core from '@actions/core';
|
||||
import { BuildParameters } from '..';
|
||||
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';
|
||||
const repositoryFolder = 'repo';
|
||||
|
|
@ -18,13 +17,17 @@ class RemoteBuilder {
|
|||
private static repoPathFull: string;
|
||||
private static projectPathFull: string;
|
||||
private static libraryFolderFull: string;
|
||||
private static buildId: string;
|
||||
private static buildParams: BuildParameters;
|
||||
private static defaultSecrets;
|
||||
static RemoteBuilderProviderPlatform: RemoteBuilderProviderInterface;
|
||||
static async build(buildParameters: BuildParameters, baseImage) {
|
||||
const runNumber = process.env.GITHUB_RUN_NUMBER;
|
||||
if (!runNumber || runNumber === '') {
|
||||
throw new Error('no run number found, exiting');
|
||||
}
|
||||
const buildUid = RemoteBuilderNamespace.generateBuildName(runNumber, buildParameters.platform);
|
||||
RemoteBuilder.buildParams = buildParameters;
|
||||
RemoteBuilder.buildId = RemoteBuilderNamespace.generateBuildName(runNumber, buildParameters.platform);
|
||||
const defaultBranchName =
|
||||
process.env.GITHUB_REF?.split('/')
|
||||
.filter((x) => {
|
||||
|
|
@ -35,8 +38,8 @@ class RemoteBuilder {
|
|||
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 = buildParameters.githubToken;
|
||||
const defaultSecretsArray = [
|
||||
const token: string = this.buildParams.githubToken;
|
||||
this.defaultSecrets = [
|
||||
{
|
||||
ParameterKey: 'GithubToken',
|
||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||
|
|
@ -44,77 +47,73 @@ class RemoteBuilder {
|
|||
},
|
||||
];
|
||||
try {
|
||||
switch (buildParameters.remoteBuildCluster) {
|
||||
switch (this.buildParams.remoteBuildCluster) {
|
||||
case 'aws':
|
||||
core.info('Building with AWS');
|
||||
this.RemoteBuilderProviderPlatform = new AWSBuildPlatform(buildParameters);
|
||||
this.RemoteBuilderProviderPlatform = new AWSBuildPlatform(this.buildParams);
|
||||
break;
|
||||
default:
|
||||
case 'k8s':
|
||||
core.info('Building with Kubernetes');
|
||||
this.RemoteBuilderProviderPlatform = new Kubernetes(buildParameters);
|
||||
this.RemoteBuilderProviderPlatform = new Kubernetes(this.buildParams);
|
||||
break;
|
||||
}
|
||||
|
||||
await this.RemoteBuilderProviderPlatform.setupSharedBuildResources(
|
||||
buildUid,
|
||||
buildParameters,
|
||||
this.buildId,
|
||||
this.buildParams,
|
||||
branchName,
|
||||
defaultSecretsArray,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
|
||||
this.buildPathFull = `/${buildVolumeFolder}/${buildUid}`;
|
||||
this.buildPathFull = `/${buildVolumeFolder}/${this.buildId}`;
|
||||
this.builderPathFull = `${this.buildPathFull}/builder`;
|
||||
this.steamPathFull = `${this.buildPathFull}/steam`;
|
||||
this.repoPathFull = `${this.buildPathFull}/${repositoryFolder}`;
|
||||
this.projectPathFull = `${this.repoPathFull}/${buildParameters.projectPath}`;
|
||||
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
|
||||
this.libraryFolderFull = `${this.projectPathFull}/Library`;
|
||||
|
||||
await RemoteBuilder.SetupStep(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
await RemoteBuilder.BuildStep(`${buildUid}`, buildParameters, baseImage, defaultSecretsArray);
|
||||
await RemoteBuilder.CompressionStep(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
await RemoteBuilder.UploadArtifacts(`${buildUid}`, buildParameters, branchName, defaultSecretsArray);
|
||||
await RemoteBuilder.SetupStep(branchName);
|
||||
await RemoteBuilder.BuildStep(baseImage);
|
||||
await RemoteBuilder.CompressionStep();
|
||||
await RemoteBuilder.UploadArtifacts(branchName);
|
||||
if (this.SteamDeploy) {
|
||||
await RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
||||
await RemoteBuilder.DeployToSteam();
|
||||
}
|
||||
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
|
||||
buildUid,
|
||||
buildParameters,
|
||||
this.buildId,
|
||||
this.buildParams,
|
||||
branchName,
|
||||
defaultSecretsArray,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
} catch (error) {
|
||||
core.error(JSON.stringify(error, undefined, 4));
|
||||
core.setFailed('Remote Builder failed');
|
||||
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
|
||||
buildUid,
|
||||
buildParameters,
|
||||
this.buildId,
|
||||
this.buildParams,
|
||||
branchName,
|
||||
defaultSecretsArray,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private static async SetupStep(
|
||||
buildUid: string,
|
||||
buildParameters: BuildParameters,
|
||||
branchName: string | undefined,
|
||||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
private static async SetupStep(branchName: string | undefined) {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
|
||||
const lfsDirectory = `${this.repoPathFull}/.git/lfs`;
|
||||
const testLFSFile = `${this.projectPathFull}/Assets/LFS_Test_File.jpg`;
|
||||
|
||||
const repo = `https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const repo2 = `https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git`;
|
||||
const repo3 = `https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
const repo = `https://${this.buildParams.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const repo2 = `https://${this.buildParams.githubToken}@github.com/game-ci/steam-deploy.git`;
|
||||
const repo3 = `https://${this.buildParams.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
|
||||
const purgeRemoteCache = process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined;
|
||||
const initializeSourceRepoForCaching = `${this.builderPathFull}/dist/remote-builder/cloneNoLFS.sh "${this.repoPathFull}" "${repo3}" "$GITHUB_SHA" "${testLFSFile}"`;
|
||||
const handleCaching = `${this.builderPathFull}/dist/remote-builder/handleCaching.sh "${cacheFolderFull}" "${branchName}" "${this.libraryFolderFull}" "${lfsDirectory}" "${purgeRemoteCache}"`;
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
this.buildId,
|
||||
'alpine/git',
|
||||
[
|
||||
` apk update -q
|
||||
|
|
@ -166,19 +165,14 @@ class RemoteBuilder {
|
|||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
],
|
||||
defaultSecretsArray,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
}
|
||||
|
||||
private static async BuildStep(
|
||||
buildUid: string,
|
||||
buildParameters: BuildParameters,
|
||||
baseImage: any,
|
||||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
private static async BuildStep(baseImage: any) {
|
||||
const buildSecrets = new Array();
|
||||
|
||||
buildSecrets.push(...defaultSecretsArray);
|
||||
buildSecrets.push(...this.defaultSecrets);
|
||||
|
||||
if (process.env.UNITY_LICENSE)
|
||||
buildSecrets.push({
|
||||
|
|
@ -208,29 +202,29 @@ class RemoteBuilder {
|
|||
ParameterValue: process.env.UNITY_SERIAL,
|
||||
});
|
||||
|
||||
if (buildParameters.androidKeystoreBase64)
|
||||
if (this.buildParams.androidKeystoreBase64)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeystoreBase64',
|
||||
EnvironmentVariable: 'ANDROID_KEYSTORE_BASE64',
|
||||
ParameterValue: buildParameters.androidKeystoreBase64,
|
||||
ParameterValue: this.buildParams.androidKeystoreBase64,
|
||||
});
|
||||
|
||||
if (buildParameters.androidKeystorePass)
|
||||
if (this.buildParams.androidKeystorePass)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeystorePass',
|
||||
EnvironmentVariable: 'ANDROID_KEYSTORE_PASS',
|
||||
ParameterValue: buildParameters.androidKeystorePass,
|
||||
ParameterValue: this.buildParams.androidKeystorePass,
|
||||
});
|
||||
|
||||
if (buildParameters.androidKeyaliasPass)
|
||||
if (this.buildParams.androidKeyaliasPass)
|
||||
buildSecrets.push({
|
||||
ParameterKey: 'AndroidKeyAliasPass',
|
||||
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
||||
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||
ParameterValue: this.buildParams.androidKeyaliasPass,
|
||||
});
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
this.buildId,
|
||||
baseImage.toString(),
|
||||
[
|
||||
`
|
||||
|
|
@ -247,83 +241,78 @@ class RemoteBuilder {
|
|||
[
|
||||
{
|
||||
name: 'ContainerMemory',
|
||||
value: buildParameters.remoteBuildMemory,
|
||||
value: this.buildParams.remoteBuildMemory,
|
||||
},
|
||||
{
|
||||
name: 'ContainerCpu',
|
||||
value: buildParameters.remoteBuildCpu,
|
||||
value: this.buildParams.remoteBuildCpu,
|
||||
},
|
||||
{
|
||||
name: 'GITHUB_WORKSPACE',
|
||||
value: `/${buildVolumeFolder}/${buildUid}/${repositoryFolder}/`,
|
||||
value: `/${buildVolumeFolder}/${this.buildId}/${repositoryFolder}/`,
|
||||
},
|
||||
{
|
||||
name: 'PROJECT_PATH',
|
||||
value: buildParameters.projectPath,
|
||||
value: this.buildParams.projectPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_PATH',
|
||||
value: buildParameters.buildPath,
|
||||
value: this.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_FILE',
|
||||
value: buildParameters.buildFile,
|
||||
value: this.buildParams.buildFile,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_NAME',
|
||||
value: buildParameters.buildName,
|
||||
value: this.buildParams.buildName,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_METHOD',
|
||||
value: buildParameters.buildMethod,
|
||||
value: this.buildParams.buildMethod,
|
||||
},
|
||||
{
|
||||
name: 'CUSTOM_PARAMETERS',
|
||||
value: buildParameters.customParameters,
|
||||
value: this.buildParams.customParameters,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: buildParameters.platform,
|
||||
value: this.buildParams.platform,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_VERSION_CODE',
|
||||
value: buildParameters.androidVersionCode.toString(),
|
||||
value: this.buildParams.androidVersionCode.toString(),
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYSTORE_NAME',
|
||||
value: buildParameters.androidKeystoreName,
|
||||
value: this.buildParams.androidKeystoreName,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYALIAS_NAME',
|
||||
value: buildParameters.androidKeyaliasName,
|
||||
value: this.buildParams.androidKeyaliasName,
|
||||
},
|
||||
],
|
||||
buildSecrets,
|
||||
);
|
||||
}
|
||||
|
||||
private static async CompressionStep(
|
||||
buildUid: string,
|
||||
buildParameters: BuildParameters,
|
||||
branchName: string | undefined,
|
||||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
private static async CompressionStep() {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
this.buildId,
|
||||
'alpine',
|
||||
[
|
||||
`
|
||||
apk update -q
|
||||
apk add zip -q
|
||||
cd "${this.libraryFolderFull}"
|
||||
zip -r "lib-${buildUid}.zip" "${this.libraryFolderFull}"
|
||||
mv "lib-${buildUid}.zip" "${cacheFolderFull}/lib/lib-${buildUid}.zip"
|
||||
zip -r "lib-${this.buildId}.zip" "${this.libraryFolderFull}"
|
||||
mv "lib-${this.buildId}.zip" "${cacheFolderFull}/lib/lib-${this.buildId}.zip"
|
||||
cd "${this.projectPathFull}"
|
||||
ls -lh "${buildParameters.buildPath}"
|
||||
zip -r "build-${buildUid}.zip" "${buildParameters.buildPath}"
|
||||
mv "build-${buildUid}.zip" "/${buildVolumeFolder}/${buildUid}/build-${buildUid}.zip"
|
||||
ls -lh "${RemoteBuilder.buildParams.buildPath}"
|
||||
zip -r "build-${this.buildId}.zip" "${RemoteBuilder.buildParams.buildPath}"
|
||||
mv "build-${this.buildId}.zip" "/${buildVolumeFolder}/${this.buildId}/build-${this.buildId}.zip"
|
||||
`,
|
||||
],
|
||||
`/${buildVolumeFolder}`,
|
||||
|
|
@ -334,27 +323,22 @@ class RemoteBuilder {
|
|||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
],
|
||||
defaultSecretsArray,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
core.info('compression step complete');
|
||||
}
|
||||
|
||||
private static async UploadArtifacts(
|
||||
buildUid: string,
|
||||
buildParameters: BuildParameters,
|
||||
branchName: string | undefined,
|
||||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
private static async UploadArtifacts(branchName: string | undefined) {
|
||||
core.info('Starting step 4/4 upload build to s3');
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
this.buildId,
|
||||
'amazon/aws-cli',
|
||||
[
|
||||
`
|
||||
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||
aws s3 cp ${this.buildId}/build-${this.buildId}.zip s3://game-ci-storage/
|
||||
# no need to upload Library cache for now
|
||||
# aws s3 cp /${buildVolumeFolder}/${cacheFolder}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||
${this.SteamDeploy ? '#' : ''} rm -r ${buildUid}
|
||||
# aws s3 cp /${buildVolumeFolder}/${cacheFolder}/${branchName}/lib-${this.buildId}.zip s3://game-ci-storage/
|
||||
${this.SteamDeploy ? '#' : ''} rm -r ${this.buildId}
|
||||
`,
|
||||
],
|
||||
`/${buildVolumeFolder}`,
|
||||
|
|
@ -380,34 +364,30 @@ class RemoteBuilder {
|
|||
EnvironmentVariable: 'AWS_SECRET_ACCESS_KEY',
|
||||
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY || '',
|
||||
},
|
||||
...defaultSecretsArray,
|
||||
...this.defaultSecrets,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
private static async DeployToSteam(
|
||||
buildUid: string,
|
||||
buildParameters: BuildParameters,
|
||||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
private static async DeployToSteam() {
|
||||
core.info('Starting steam deployment');
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
this.buildId,
|
||||
'cm2network/steamcmd:root',
|
||||
[
|
||||
`
|
||||
ls
|
||||
ls /
|
||||
cp -r /${buildVolumeFolder}/${buildUid}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /${buildVolumeFolder}/${buildUid}/steam/action/steps/ /steps;
|
||||
cp -r /${buildVolumeFolder}/${this.buildId}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /${buildVolumeFolder}/${this.buildId}/steam/action/steps/ /steps;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
rm -r /${buildVolumeFolder}/${buildUid}
|
||||
rm -r /${buildVolumeFolder}/${this.buildId}
|
||||
`,
|
||||
],
|
||||
`/${buildVolumeFolder}`,
|
||||
`/${buildVolumeFolder}/${buildUid}/steam/action/`,
|
||||
`/${buildVolumeFolder}/${this.buildId}/steam/action/`,
|
||||
[
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
|
|
@ -428,7 +408,7 @@ class RemoteBuilder {
|
|||
{
|
||||
EnvironmentVariable: 'INPUT_ROOTPATH',
|
||||
ParameterKey: 'rootPath',
|
||||
ParameterValue: buildParameters.buildPath,
|
||||
ParameterValue: RemoteBuilder.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
|
||||
|
|
@ -445,7 +425,7 @@ class RemoteBuilder {
|
|||
ParameterKey: 'previewEnabled',
|
||||
ParameterValue: process.env.PREVIEW_ENABLED || '',
|
||||
},
|
||||
...defaultSecretsArray,
|
||||
...this.defaultSecrets,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue