steam deploy fix
parent
1939496bdc
commit
6518b248a1
|
|
@ -1631,6 +1631,7 @@ class RemoteBuilder {
|
||||||
var _a;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
this.SteamDeploy = process.env.STEAM_DEPLOY !== '' || false;
|
||||||
const nanoid = nanoid_1.customAlphabet(remote_builder_alphabet_1.default.alphabet, 4);
|
const nanoid = nanoid_1.customAlphabet(remote_builder_alphabet_1.default.alphabet, 4);
|
||||||
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform
|
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform
|
||||||
.replace('Standalone', '')
|
.replace('Standalone', '')
|
||||||
|
|
@ -1649,7 +1650,9 @@ class RemoteBuilder {
|
||||||
yield RemoteBuilder.BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray);
|
yield RemoteBuilder.BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray);
|
||||||
yield RemoteBuilder.CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
yield RemoteBuilder.CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
yield RemoteBuilder.UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray);
|
yield RemoteBuilder.UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
yield RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
if (this.SteamDeploy) {
|
||||||
|
yield RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error);
|
core.setFailed(error);
|
||||||
|
|
@ -1660,83 +1663,72 @@ class RemoteBuilder {
|
||||||
// static async ProvisionPlatformResources() {
|
// static async ProvisionPlatformResources() {
|
||||||
// await AWSBuildPlatform.setupPlatformResources();
|
// await AWSBuildPlatform.setupPlatformResources();
|
||||||
// }
|
// }
|
||||||
static DeployToSteam(buildUid, buildParameters, defaultSecretsArray) {
|
static SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info('Starting steam deployment');
|
core.info('Starting step 1/4 clone and restore cache)');
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'cm2network/steamcmd:root', [
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
||||||
'-c',
|
'-c',
|
||||||
`
|
`apk update;
|
||||||
ls
|
apk add unzip;
|
||||||
chmod -R +x ./entrypoint.sh;
|
apk add git-lfs;
|
||||||
chmod -R +x ./steps;
|
apk add jq;
|
||||||
./entrypoint.sh;
|
# Get source repo for project to be built and game-ci repo for utilties
|
||||||
`,
|
git clone https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/${repositoryDirectoryName} -q
|
||||||
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/steam/action/`, [
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git ${buildUid}/builder -q
|
||||||
{
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git ${buildUid}/steam -q
|
||||||
name: 'GITHUB_SHA',
|
cd /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
||||||
value: process.env.GITHUB_SHA || '',
|
git checkout $GITHUB_SHA
|
||||||
},
|
cd /${efsDirectoryName}/
|
||||||
], defaultSecretsArray);
|
# Look for usable cache
|
||||||
});
|
if [ ! -d ${cacheDirectoryName} ]; then
|
||||||
}
|
mkdir ${cacheDirectoryName}
|
||||||
static UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
fi
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
cd ${cacheDirectoryName}
|
||||||
core.info('Starting step 4/4 upload build to s3');
|
if [ ! -d "${branchName}" ]; then
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', [
|
mkdir "${branchName}"
|
||||||
'-c',
|
fi
|
||||||
`
|
cd "${branchName}"
|
||||||
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
echo " "
|
||||||
# no need to upload Library cache for now
|
echo "Cached Libraries for ${branchName} from previous builds:"
|
||||||
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
ls
|
||||||
# rm -r ${buildUid}
|
echo " "
|
||||||
`,
|
ls "/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}"
|
||||||
|
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
||||||
|
if [ -d "$libDir" ]; then
|
||||||
|
rm -r "$libDir"
|
||||||
|
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
||||||
|
fi
|
||||||
|
echo 'Checking cache'
|
||||||
|
# Restore cache
|
||||||
|
latest=$(ls -t | head -1)
|
||||||
|
if [ ! -z "$latest" ]; then
|
||||||
|
echo "Library cache exists from build $latest from ${branchName}"
|
||||||
|
echo 'Creating empty Library folder for cache'
|
||||||
|
mkdir $libDir
|
||||||
|
unzip -q $latest -d $libDir
|
||||||
|
# purge cache
|
||||||
|
# rm -r $libDir
|
||||||
|
else
|
||||||
|
echo 'Cache does not exist'
|
||||||
|
fi
|
||||||
|
# Print out important directories
|
||||||
|
echo ' '
|
||||||
|
echo 'Repo:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
||||||
|
echo ' '
|
||||||
|
echo 'Project:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}
|
||||||
|
echo ' '
|
||||||
|
echo 'Library:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/
|
||||||
|
echo ' '
|
||||||
|
`,
|
||||||
], `/${efsDirectoryName}`, `/${efsDirectoryName}/`, [
|
], `/${efsDirectoryName}`, `/${efsDirectoryName}/`, [
|
||||||
{
|
{
|
||||||
name: 'GITHUB_SHA',
|
name: 'GITHUB_SHA',
|
||||||
value: process.env.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 || '',
|
|
||||||
},
|
|
||||||
...defaultSecretsArray,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
core.info('Starting step 3/4 build compression');
|
|
||||||
// Cleanup
|
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine', [
|
|
||||||
'-c',
|
|
||||||
`
|
|
||||||
apk update
|
|
||||||
apk add zip
|
|
||||||
cd Library
|
|
||||||
zip -r lib-${buildUid}.zip .*
|
|
||||||
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
|
||||||
cd ../../
|
|
||||||
zip -r build-${buildUid}.zip ${buildParameters.buildPath}/*
|
|
||||||
mv build-${buildUid}.zip /${efsDirectoryName}/${buildUid}/build-${buildUid}.zip
|
|
||||||
`,
|
|
||||||
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}`, [
|
|
||||||
{
|
|
||||||
name: 'GITHUB_SHA',
|
|
||||||
value: process.env.GITHUB_SHA || '',
|
|
||||||
},
|
|
||||||
], defaultSecretsArray);
|
], defaultSecretsArray);
|
||||||
core.info('compression step complete');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray) {
|
static BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray) {
|
||||||
|
|
@ -1852,75 +1844,123 @@ class RemoteBuilder {
|
||||||
], buildSecrets);
|
], buildSecrets);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
static CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info('Starting step 1/4 clone and restore cache)');
|
core.info('Starting step 3/4 build compression');
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
// Cleanup
|
||||||
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine', [
|
||||||
'-c',
|
'-c',
|
||||||
`apk update;
|
`
|
||||||
apk add unzip;
|
apk update
|
||||||
apk add git-lfs;
|
apk add zip
|
||||||
apk add jq;
|
cd Library
|
||||||
# Get source repo for project to be built and game-ci repo for utilties
|
zip -r lib-${buildUid}.zip .*
|
||||||
git clone https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/${repositoryDirectoryName} -q
|
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
||||||
git clone https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git ${buildUid}/builder -q
|
cd ../../
|
||||||
git clone https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git ${buildUid}/steam -q
|
zip -r build-${buildUid}.zip ${buildParameters.buildPath}/*
|
||||||
cd /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
mv build-${buildUid}.zip /${efsDirectoryName}/${buildUid}/build-${buildUid}.zip
|
||||||
git checkout $GITHUB_SHA
|
`,
|
||||||
cd /${efsDirectoryName}/
|
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}`, [
|
||||||
# Look for usable cache
|
|
||||||
if [ ! -d ${cacheDirectoryName} ]; then
|
|
||||||
mkdir ${cacheDirectoryName}
|
|
||||||
fi
|
|
||||||
cd ${cacheDirectoryName}
|
|
||||||
if [ ! -d "${branchName}" ]; then
|
|
||||||
mkdir "${branchName}"
|
|
||||||
fi
|
|
||||||
cd "${branchName}"
|
|
||||||
echo " "
|
|
||||||
echo "Cached Libraries for ${branchName} from previous builds:"
|
|
||||||
ls
|
|
||||||
echo " "
|
|
||||||
ls "/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}"
|
|
||||||
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
|
||||||
if [ -d "$libDir" ]; then
|
|
||||||
rm -r "$libDir"
|
|
||||||
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
|
||||||
fi
|
|
||||||
echo 'Checking cache'
|
|
||||||
# Restore cache
|
|
||||||
latest=$(ls -t | head -1)
|
|
||||||
if [ ! -z "$latest" ]; then
|
|
||||||
echo "Library cache exists from build $latest from ${branchName}"
|
|
||||||
echo 'Creating empty Library folder for cache'
|
|
||||||
mkdir $libDir
|
|
||||||
unzip -q $latest -d $libDir
|
|
||||||
# purge cache
|
|
||||||
# rm -r $libDir
|
|
||||||
else
|
|
||||||
echo 'Cache does not exist'
|
|
||||||
fi
|
|
||||||
# Print out important directories
|
|
||||||
echo ' '
|
|
||||||
echo 'Repo:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
|
||||||
echo ' '
|
|
||||||
echo 'Project:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}
|
|
||||||
echo ' '
|
|
||||||
echo 'Library:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/
|
|
||||||
echo ' '
|
|
||||||
`,
|
|
||||||
], `/${efsDirectoryName}`, `/${efsDirectoryName}/`, [
|
|
||||||
{
|
{
|
||||||
name: 'GITHUB_SHA',
|
name: 'GITHUB_SHA',
|
||||||
value: process.env.GITHUB_SHA || '',
|
value: process.env.GITHUB_SHA || '',
|
||||||
},
|
},
|
||||||
], defaultSecretsArray);
|
], defaultSecretsArray);
|
||||||
|
core.info('compression step complete');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info('Starting step 4/4 upload build to s3');
|
||||||
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', [
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||||
|
# no need to upload Library cache for now
|
||||||
|
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||||
|
${this.SteamDeploy ? '#' : ''} rm -r ${buildUid}
|
||||||
|
`,
|
||||||
|
], `/${efsDirectoryName}`, `/${efsDirectoryName}/`, [
|
||||||
|
{
|
||||||
|
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 || '',
|
||||||
|
},
|
||||||
|
...defaultSecretsArray,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static DeployToSteam(buildUid, buildParameters, defaultSecretsArray) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info('Starting steam deployment');
|
||||||
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'cm2network/steamcmd:root', [
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
ls
|
||||||
|
ls /
|
||||||
|
cp -r /${efsDirectoryName}/${buildUid}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||||
|
cp -r /${efsDirectoryName}/${buildUid}/steam/action/steps/ /steps;
|
||||||
|
chmod -R +x /entrypoint.sh;
|
||||||
|
chmod -R +x /steps;
|
||||||
|
/entrypoint.sh;
|
||||||
|
rm -r /${efsDirectoryName}/${buildUid}
|
||||||
|
`,
|
||||||
|
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/steam/action/`, [
|
||||||
|
{
|
||||||
|
name: 'GITHUB_SHA',
|
||||||
|
value: process.env.GITHUB_SHA || '',
|
||||||
|
},
|
||||||
|
], [
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_APPID',
|
||||||
|
ParameterKey: 'appId',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
|
||||||
|
ParameterKey: 'buildDescription',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_ROOTPATH',
|
||||||
|
ParameterKey: 'rootPath',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
|
||||||
|
ParameterKey: 'releaseBranch',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
|
||||||
|
ParameterKey: 'localContentServer',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
|
||||||
|
ParameterKey: 'previewEnabled',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
...defaultSecretsArray,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RemoteBuilder.SteamDeploy = false;
|
||||||
exports.default = RemoteBuilder;
|
exports.default = RemoteBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -8,8 +8,10 @@ const efsDirectoryName = 'data';
|
||||||
const cacheDirectoryName = 'cache';
|
const cacheDirectoryName = 'cache';
|
||||||
|
|
||||||
class RemoteBuilder {
|
class RemoteBuilder {
|
||||||
|
static SteamDeploy: boolean = false;
|
||||||
static async build(buildParameters: BuildParameters, baseImage) {
|
static async build(buildParameters: BuildParameters, baseImage) {
|
||||||
try {
|
try {
|
||||||
|
this.SteamDeploy = process.env.STEAM_DEPLOY !== '' || false;
|
||||||
const nanoid = customAlphabet(RemoteBuilderAlphabet.alphabet, 4);
|
const nanoid = customAlphabet(RemoteBuilderAlphabet.alphabet, 4);
|
||||||
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform
|
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform
|
||||||
.replace('Standalone', '')
|
.replace('Standalone', '')
|
||||||
|
|
@ -28,7 +30,9 @@ class RemoteBuilder {
|
||||||
await RemoteBuilder.BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray);
|
await RemoteBuilder.BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray);
|
||||||
await RemoteBuilder.CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
await RemoteBuilder.CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
await RemoteBuilder.UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray);
|
await RemoteBuilder.UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
await RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
if (this.SteamDeploy) {
|
||||||
|
await RemoteBuilder.DeployToSteam(buildUid, buildParameters, defaultSecretsArray);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error);
|
core.setFailed(error);
|
||||||
core.error(error);
|
core.error(error);
|
||||||
|
|
@ -38,112 +42,77 @@ class RemoteBuilder {
|
||||||
// await AWSBuildPlatform.setupPlatformResources();
|
// await AWSBuildPlatform.setupPlatformResources();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static async DeployToSteam(
|
private static async SetupStep(
|
||||||
buildUid: string,
|
|
||||||
buildParameters: BuildParameters,
|
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
|
||||||
) {
|
|
||||||
core.info('Starting steam deployment');
|
|
||||||
await AWSBuildPlatform.runBuild(
|
|
||||||
buildUid,
|
|
||||||
buildParameters.awsStackName,
|
|
||||||
'cm2network/steamcmd:root',
|
|
||||||
[
|
|
||||||
'-c',
|
|
||||||
`
|
|
||||||
ls
|
|
||||||
chmod -R +x ./entrypoint.sh;
|
|
||||||
chmod -R +x ./steps;
|
|
||||||
./entrypoint.sh;
|
|
||||||
`,
|
|
||||||
],
|
|
||||||
`/${efsDirectoryName}`,
|
|
||||||
`/${efsDirectoryName}/${buildUid}/steam/action/`,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
name: 'GITHUB_SHA',
|
|
||||||
value: process.env.GITHUB_SHA || '',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
defaultSecretsArray,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async UploadArtifacts(
|
|
||||||
buildUid: string,
|
buildUid: string,
|
||||||
buildParameters: BuildParameters,
|
buildParameters: BuildParameters,
|
||||||
branchName: string | undefined,
|
branchName: string | undefined,
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {
|
) {
|
||||||
core.info('Starting step 4/4 upload build to s3');
|
core.info('Starting step 1/4 clone and restore cache)');
|
||||||
await AWSBuildPlatform.runBuild(
|
await AWSBuildPlatform.runBuild(
|
||||||
buildUid,
|
buildUid,
|
||||||
buildParameters.awsStackName,
|
buildParameters.awsStackName,
|
||||||
'amazon/aws-cli',
|
'alpine/git',
|
||||||
[
|
[
|
||||||
'-c',
|
'-c',
|
||||||
`
|
`apk update;
|
||||||
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
apk add unzip;
|
||||||
# no need to upload Library cache for now
|
apk add git-lfs;
|
||||||
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
apk add jq;
|
||||||
# rm -r ${buildUid}
|
# Get source repo for project to be built and game-ci repo for utilties
|
||||||
`,
|
git clone https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/${repositoryDirectoryName} -q
|
||||||
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git ${buildUid}/builder -q
|
||||||
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git ${buildUid}/steam -q
|
||||||
|
cd /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
||||||
|
git checkout $GITHUB_SHA
|
||||||
|
cd /${efsDirectoryName}/
|
||||||
|
# Look for usable cache
|
||||||
|
if [ ! -d ${cacheDirectoryName} ]; then
|
||||||
|
mkdir ${cacheDirectoryName}
|
||||||
|
fi
|
||||||
|
cd ${cacheDirectoryName}
|
||||||
|
if [ ! -d "${branchName}" ]; then
|
||||||
|
mkdir "${branchName}"
|
||||||
|
fi
|
||||||
|
cd "${branchName}"
|
||||||
|
echo " "
|
||||||
|
echo "Cached Libraries for ${branchName} from previous builds:"
|
||||||
|
ls
|
||||||
|
echo " "
|
||||||
|
ls "/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}"
|
||||||
|
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
||||||
|
if [ -d "$libDir" ]; then
|
||||||
|
rm -r "$libDir"
|
||||||
|
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
||||||
|
fi
|
||||||
|
echo 'Checking cache'
|
||||||
|
# Restore cache
|
||||||
|
latest=$(ls -t | head -1)
|
||||||
|
if [ ! -z "$latest" ]; then
|
||||||
|
echo "Library cache exists from build $latest from ${branchName}"
|
||||||
|
echo 'Creating empty Library folder for cache'
|
||||||
|
mkdir $libDir
|
||||||
|
unzip -q $latest -d $libDir
|
||||||
|
# purge cache
|
||||||
|
# rm -r $libDir
|
||||||
|
else
|
||||||
|
echo 'Cache does not exist'
|
||||||
|
fi
|
||||||
|
# Print out important directories
|
||||||
|
echo ' '
|
||||||
|
echo 'Repo:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
||||||
|
echo ' '
|
||||||
|
echo 'Project:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}
|
||||||
|
echo ' '
|
||||||
|
echo 'Library:'
|
||||||
|
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/
|
||||||
|
echo ' '
|
||||||
|
`,
|
||||||
],
|
],
|
||||||
`/${efsDirectoryName}`,
|
`/${efsDirectoryName}`,
|
||||||
`/${efsDirectoryName}/`,
|
`/${efsDirectoryName}/`,
|
||||||
[
|
|
||||||
{
|
|
||||||
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 || '',
|
|
||||||
},
|
|
||||||
...defaultSecretsArray,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async CompressionStep(
|
|
||||||
buildUid: string,
|
|
||||||
buildParameters: BuildParameters,
|
|
||||||
branchName: string | undefined,
|
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
|
||||||
) {
|
|
||||||
core.info('Starting step 3/4 build compression');
|
|
||||||
// Cleanup
|
|
||||||
await AWSBuildPlatform.runBuild(
|
|
||||||
buildUid,
|
|
||||||
buildParameters.awsStackName,
|
|
||||||
'alpine',
|
|
||||||
[
|
|
||||||
'-c',
|
|
||||||
`
|
|
||||||
apk update
|
|
||||||
apk add zip
|
|
||||||
cd Library
|
|
||||||
zip -r lib-${buildUid}.zip .*
|
|
||||||
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
|
||||||
cd ../../
|
|
||||||
zip -r build-${buildUid}.zip ${buildParameters.buildPath}/*
|
|
||||||
mv build-${buildUid}.zip /${efsDirectoryName}/${buildUid}/build-${buildUid}.zip
|
|
||||||
`,
|
|
||||||
],
|
|
||||||
`/${efsDirectoryName}`,
|
|
||||||
`/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}`,
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: 'GITHUB_SHA',
|
name: 'GITHUB_SHA',
|
||||||
|
|
@ -152,7 +121,6 @@ class RemoteBuilder {
|
||||||
],
|
],
|
||||||
defaultSecretsArray,
|
defaultSecretsArray,
|
||||||
);
|
);
|
||||||
core.info('compression step complete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async BuildStep(
|
private static async BuildStep(
|
||||||
|
|
@ -289,77 +257,33 @@ class RemoteBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async SetupStep(
|
private static async CompressionStep(
|
||||||
buildUid: string,
|
buildUid: string,
|
||||||
buildParameters: BuildParameters,
|
buildParameters: BuildParameters,
|
||||||
branchName: string | undefined,
|
branchName: string | undefined,
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {
|
) {
|
||||||
core.info('Starting step 1/4 clone and restore cache)');
|
core.info('Starting step 3/4 build compression');
|
||||||
|
// Cleanup
|
||||||
await AWSBuildPlatform.runBuild(
|
await AWSBuildPlatform.runBuild(
|
||||||
buildUid,
|
buildUid,
|
||||||
buildParameters.awsStackName,
|
buildParameters.awsStackName,
|
||||||
'alpine/git',
|
'alpine',
|
||||||
[
|
[
|
||||||
'-c',
|
'-c',
|
||||||
`apk update;
|
`
|
||||||
apk add unzip;
|
apk update
|
||||||
apk add git-lfs;
|
apk add zip
|
||||||
apk add jq;
|
cd Library
|
||||||
# Get source repo for project to be built and game-ci repo for utilties
|
zip -r lib-${buildUid}.zip .*
|
||||||
git clone https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/${repositoryDirectoryName} -q
|
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
||||||
git clone https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git ${buildUid}/builder -q
|
cd ../../
|
||||||
git clone https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git ${buildUid}/steam -q
|
zip -r build-${buildUid}.zip ${buildParameters.buildPath}/*
|
||||||
cd /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
mv build-${buildUid}.zip /${efsDirectoryName}/${buildUid}/build-${buildUid}.zip
|
||||||
git checkout $GITHUB_SHA
|
`,
|
||||||
cd /${efsDirectoryName}/
|
|
||||||
# Look for usable cache
|
|
||||||
if [ ! -d ${cacheDirectoryName} ]; then
|
|
||||||
mkdir ${cacheDirectoryName}
|
|
||||||
fi
|
|
||||||
cd ${cacheDirectoryName}
|
|
||||||
if [ ! -d "${branchName}" ]; then
|
|
||||||
mkdir "${branchName}"
|
|
||||||
fi
|
|
||||||
cd "${branchName}"
|
|
||||||
echo " "
|
|
||||||
echo "Cached Libraries for ${branchName} from previous builds:"
|
|
||||||
ls
|
|
||||||
echo " "
|
|
||||||
ls "/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}"
|
|
||||||
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
|
||||||
if [ -d "$libDir" ]; then
|
|
||||||
rm -r "$libDir"
|
|
||||||
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
|
||||||
fi
|
|
||||||
echo 'Checking cache'
|
|
||||||
# Restore cache
|
|
||||||
latest=$(ls -t | head -1)
|
|
||||||
if [ ! -z "$latest" ]; then
|
|
||||||
echo "Library cache exists from build $latest from ${branchName}"
|
|
||||||
echo 'Creating empty Library folder for cache'
|
|
||||||
mkdir $libDir
|
|
||||||
unzip -q $latest -d $libDir
|
|
||||||
# purge cache
|
|
||||||
# rm -r $libDir
|
|
||||||
else
|
|
||||||
echo 'Cache does not exist'
|
|
||||||
fi
|
|
||||||
# Print out important directories
|
|
||||||
echo ' '
|
|
||||||
echo 'Repo:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
|
||||||
echo ' '
|
|
||||||
echo 'Project:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}
|
|
||||||
echo ' '
|
|
||||||
echo 'Library:'
|
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/
|
|
||||||
echo ' '
|
|
||||||
`,
|
|
||||||
],
|
],
|
||||||
`/${efsDirectoryName}`,
|
`/${efsDirectoryName}`,
|
||||||
`/${efsDirectoryName}/`,
|
`/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}`,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: 'GITHUB_SHA',
|
name: 'GITHUB_SHA',
|
||||||
|
|
@ -368,6 +292,122 @@ class RemoteBuilder {
|
||||||
],
|
],
|
||||||
defaultSecretsArray,
|
defaultSecretsArray,
|
||||||
);
|
);
|
||||||
|
core.info('compression step complete');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async UploadArtifacts(
|
||||||
|
buildUid: string,
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
branchName: string | undefined,
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {
|
||||||
|
core.info('Starting step 4/4 upload build to s3');
|
||||||
|
await AWSBuildPlatform.runBuild(
|
||||||
|
buildUid,
|
||||||
|
buildParameters.awsStackName,
|
||||||
|
'amazon/aws-cli',
|
||||||
|
[
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||||
|
# no need to upload Library cache for now
|
||||||
|
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||||
|
${this.SteamDeploy ? '#' : ''} rm -r ${buildUid}
|
||||||
|
`,
|
||||||
|
],
|
||||||
|
`/${efsDirectoryName}`,
|
||||||
|
`/${efsDirectoryName}/`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
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 || '',
|
||||||
|
},
|
||||||
|
...defaultSecretsArray,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async DeployToSteam(
|
||||||
|
buildUid: string,
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {
|
||||||
|
core.info('Starting steam deployment');
|
||||||
|
await AWSBuildPlatform.runBuild(
|
||||||
|
buildUid,
|
||||||
|
buildParameters.awsStackName,
|
||||||
|
'cm2network/steamcmd:root',
|
||||||
|
[
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
ls
|
||||||
|
ls /
|
||||||
|
cp -r /${efsDirectoryName}/${buildUid}/steam/action/entrypoint.sh /entrypoint.sh;
|
||||||
|
cp -r /${efsDirectoryName}/${buildUid}/steam/action/steps/ /steps;
|
||||||
|
chmod -R +x /entrypoint.sh;
|
||||||
|
chmod -R +x /steps;
|
||||||
|
/entrypoint.sh;
|
||||||
|
rm -r /${efsDirectoryName}/${buildUid}
|
||||||
|
`,
|
||||||
|
],
|
||||||
|
`/${efsDirectoryName}`,
|
||||||
|
`/${efsDirectoryName}/${buildUid}/steam/action/`,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 'GITHUB_SHA',
|
||||||
|
value: process.env.GITHUB_SHA || '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_APPID',
|
||||||
|
ParameterKey: 'appId',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_BUILDDESCRIPTION',
|
||||||
|
ParameterKey: 'buildDescription',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_ROOTPATH',
|
||||||
|
ParameterKey: 'rootPath',
|
||||||
|
ParameterValue: 'XX',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_RELEASEBRANCH',
|
||||||
|
ParameterKey: 'releaseBranch',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_LOCALCONTENTSERVER',
|
||||||
|
ParameterKey: 'localContentServer',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
EnvironmentVariable: 'INPUT_PREVIEWENABLED',
|
||||||
|
ParameterKey: 'previewEnabled',
|
||||||
|
ParameterValue: '',
|
||||||
|
},
|
||||||
|
...defaultSecretsArray,
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default RemoteBuilder;
|
export default RemoteBuilder;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue