Refactor (extract remote-builder steps into methods)
parent
98acf5c011
commit
13aa04b7eb
|
|
@ -1644,68 +1644,93 @@ class RemoteBuilder {
|
||||||
ParameterValue: token,
|
ParameterValue: token,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
core.info('Starting part 1/4 (clone from github and restore cache)');
|
yield RemoteBuilder.SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
yield RemoteBuilder.BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray);
|
||||||
|
yield RemoteBuilder.CompressionStep(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
|
yield RemoteBuilder.UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray);
|
||||||
|
yield RemoteBuilder.DeployToSteam(buildUid, buildParameters);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.setFailed(error);
|
||||||
|
core.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static DeployToSteam(buildUid, buildParameters) {
|
||||||
|
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',
|
'-c',
|
||||||
`apk update;
|
`
|
||||||
apk add unzip;
|
|
||||||
apk add git-lfs;
|
|
||||||
apk add jq;
|
|
||||||
# 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
|
ls
|
||||||
echo " "
|
chmod -R +x /entrypoint.sh;
|
||||||
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
chmod -R +x /steps;
|
||||||
if [ -d "$libDir" ]; then
|
/entrypoint.sh;
|
||||||
rm -r "$libDir"
|
`,
|
||||||
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/steam/action/`, [], []);
|
||||||
fi
|
});
|
||||||
echo 'Checking cache'
|
}
|
||||||
# Restore cache
|
static UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||||
latest=$(ls -t | head -1)
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if [ ! -z "$latest" ]; then
|
core.info('Starting part 4/4 (upload build to s3)');
|
||||||
echo "Library cache exists from build $latest from ${branchName}"
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', [
|
||||||
echo 'Creating empty Library folder for cache'
|
'-c',
|
||||||
mkdir "$libDir"
|
`
|
||||||
unzip -q $latest -d '/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/.'
|
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||||
else
|
# no need to upload Library cache for now
|
||||||
echo 'Cache does not exist'
|
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||||
fi
|
rm -r ${buildUid}
|
||||||
# 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 part 3/4 (zip unity build and Library for caching)');
|
||||||
|
// Cleanup
|
||||||
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine', [
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
apk update
|
||||||
|
apk add zip
|
||||||
|
cd Library
|
||||||
|
zip -q -r lib-${buildUid}.zip .*
|
||||||
|
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
||||||
|
cd ../../
|
||||||
|
zip -q -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('Starting part 2/4 (build unity project)');
|
});
|
||||||
|
}
|
||||||
|
static BuildStep(buildUid, buildParameters, baseImage, defaultSecretsArray) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const buildSecrets = new Array();
|
const buildSecrets = new Array();
|
||||||
buildSecrets.push(...defaultSecretsArray);
|
buildSecrets.push(...defaultSecretsArray);
|
||||||
if (process.env.UNITY_LICENSE)
|
if (process.env.UNITY_LICENSE)
|
||||||
|
|
@ -1750,6 +1775,7 @@ class RemoteBuilder {
|
||||||
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
||||||
ParameterValue: buildParameters.androidKeyaliasPass,
|
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||||
});
|
});
|
||||||
|
core.info('Starting part 2/4 (build unity project)');
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, baseImage.toString(), [
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, baseImage.toString(), [
|
||||||
'-c',
|
'-c',
|
||||||
`
|
`
|
||||||
|
|
@ -1814,72 +1840,71 @@ class RemoteBuilder {
|
||||||
value: buildParameters.androidKeyaliasName,
|
value: buildParameters.androidKeyaliasName,
|
||||||
},
|
},
|
||||||
], buildSecrets);
|
], buildSecrets);
|
||||||
core.info('Starting part 3/4 (zip unity build and Library for caching)');
|
});
|
||||||
// Cleanup
|
}
|
||||||
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine', [
|
static SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info('Starting part 1/4 (clone from github and restore cache)');
|
||||||
|
yield aws_build_platform_1.default.runBuild(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
||||||
'-c',
|
'-c',
|
||||||
`
|
`apk update;
|
||||||
apk update
|
apk add unzip;
|
||||||
apk add zip
|
apk add git-lfs;
|
||||||
cd Library
|
apk add jq;
|
||||||
zip -q -r lib-${buildUid}.zip .*
|
# Get source repo for project to be built and game-ci repo for utilties
|
||||||
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
git clone https://${buildParameters.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git ${buildUid}/${repositoryDirectoryName} -q
|
||||||
cd ../../
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/unity-builder.git ${buildUid}/builder -q
|
||||||
zip -q -r build-${buildUid}.zip ${buildParameters.buildPath}/*
|
git clone https://${buildParameters.githubToken}@github.com/game-ci/steam-deploy.git ${buildUid}/steam -q
|
||||||
mv build-${buildUid}.zip /${efsDirectoryName}/${buildUid}/build-${buildUid}.zip
|
cd /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
||||||
`,
|
git checkout $GITHUB_SHA
|
||||||
], `/${efsDirectoryName}`, `/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}`, [
|
cd /${efsDirectoryName}/
|
||||||
{
|
# Look for usable cache
|
||||||
name: 'GITHUB_SHA',
|
if [ ! -d ${cacheDirectoryName} ]; then
|
||||||
value: process.env.GITHUB_SHA || '',
|
mkdir ${cacheDirectoryName}
|
||||||
},
|
fi
|
||||||
], defaultSecretsArray);
|
cd ${cacheDirectoryName}
|
||||||
core.info('Starting part 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 " "
|
||||||
|
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 '/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/.'
|
||||||
|
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 || '',
|
||||||
},
|
},
|
||||||
{
|
], defaultSecretsArray);
|
||||||
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,
|
|
||||||
]);
|
|
||||||
core.info('Starting steam deployment');
|
|
||||||
yield aws_build_platform_1.default.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/`, [], []);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error);
|
|
||||||
core.error(error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -23,69 +23,114 @@ class RemoteBuilder {
|
||||||
ParameterValue: token,
|
ParameterValue: token,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
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.DeployToSteam(buildUid, buildParameters);
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error);
|
||||||
|
core.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.info('Starting part 1/4 (clone from github and restore cache)');
|
private static async DeployToSteam(buildUid: string, buildParameters: BuildParameters) {
|
||||||
|
core.info('Starting steam deployment');
|
||||||
await AWSBuildPlatform.runBuild(
|
await AWSBuildPlatform.runBuild(
|
||||||
buildUid,
|
buildUid,
|
||||||
buildParameters.awsStackName,
|
buildParameters.awsStackName,
|
||||||
'alpine/git',
|
'cm2network/steamcmd:root',
|
||||||
[
|
[
|
||||||
'-c',
|
'-c',
|
||||||
`apk update;
|
`
|
||||||
apk add unzip;
|
|
||||||
apk add git-lfs;
|
|
||||||
apk add jq;
|
|
||||||
# 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
|
ls
|
||||||
echo " "
|
chmod -R +x /entrypoint.sh;
|
||||||
libDir="/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library"
|
chmod -R +x /steps;
|
||||||
if [ -d "$libDir" ]; then
|
/entrypoint.sh;
|
||||||
rm -r "$libDir"
|
`,
|
||||||
echo "Setup .gitignore to ignore Library folder and remove it from builds"
|
],
|
||||||
fi
|
`/${efsDirectoryName}`,
|
||||||
echo 'Checking cache'
|
`/${efsDirectoryName}/${buildUid}/steam/action/`,
|
||||||
# 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"
|
private static async UploadArtifacts(
|
||||||
unzip -q $latest -d '/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/.'
|
buildUid: string,
|
||||||
else
|
buildParameters: BuildParameters,
|
||||||
echo 'Cache does not exist'
|
branchName: string | undefined,
|
||||||
fi
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
# Print out important directories
|
) {
|
||||||
echo ' '
|
core.info('Starting part 4/4 (upload build to s3)');
|
||||||
echo 'Repo:'
|
await AWSBuildPlatform.runBuild(
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/
|
buildUid,
|
||||||
echo ' '
|
buildParameters.awsStackName,
|
||||||
echo 'Project:'
|
'amazon/aws-cli',
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}
|
[
|
||||||
echo ' '
|
'-c',
|
||||||
echo 'Library:'
|
`
|
||||||
ls /${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/
|
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||||
echo ' '
|
# no need to upload Library cache for now
|
||||||
|
# aws s3 cp /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip s3://game-ci-storage/
|
||||||
|
rm -r ${buildUid}
|
||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
`/${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 part 3/4 (zip unity build and Library for caching)');
|
||||||
|
// Cleanup
|
||||||
|
await AWSBuildPlatform.runBuild(
|
||||||
|
buildUid,
|
||||||
|
buildParameters.awsStackName,
|
||||||
|
'alpine',
|
||||||
|
[
|
||||||
|
'-c',
|
||||||
|
`
|
||||||
|
apk update
|
||||||
|
apk add zip
|
||||||
|
cd Library
|
||||||
|
zip -q -r lib-${buildUid}.zip .*
|
||||||
|
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
||||||
|
cd ../../
|
||||||
|
zip -q -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',
|
||||||
|
|
@ -94,9 +139,14 @@ class RemoteBuilder {
|
||||||
],
|
],
|
||||||
defaultSecretsArray,
|
defaultSecretsArray,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
core.info('Starting part 2/4 (build unity project)');
|
private static async BuildStep(
|
||||||
|
buildUid: string,
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
baseImage: any,
|
||||||
|
defaultSecretsArray: any[],
|
||||||
|
) {
|
||||||
const buildSecrets = new Array();
|
const buildSecrets = new Array();
|
||||||
|
|
||||||
buildSecrets.push(...defaultSecretsArray);
|
buildSecrets.push(...defaultSecretsArray);
|
||||||
|
|
@ -149,7 +199,7 @@ class RemoteBuilder {
|
||||||
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
EnvironmentVariable: 'AWS_ACCESS_KEY_ALIAS_PASS',
|
||||||
ParameterValue: buildParameters.androidKeyaliasPass,
|
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||||
});
|
});
|
||||||
|
core.info('Starting part 2/4 (build unity project)');
|
||||||
await AWSBuildPlatform.runBuild(
|
await AWSBuildPlatform.runBuild(
|
||||||
buildUid,
|
buildUid,
|
||||||
buildParameters.awsStackName,
|
buildParameters.awsStackName,
|
||||||
|
|
@ -223,48 +273,72 @@ class RemoteBuilder {
|
||||||
],
|
],
|
||||||
buildSecrets,
|
buildSecrets,
|
||||||
);
|
);
|
||||||
core.info('Starting part 3/4 (zip unity build and Library for caching)');
|
}
|
||||||
// Cleanup
|
|
||||||
await AWSBuildPlatform.runBuild(
|
|
||||||
buildUid,
|
|
||||||
buildParameters.awsStackName,
|
|
||||||
'alpine',
|
|
||||||
[
|
|
||||||
'-c',
|
|
||||||
`
|
|
||||||
apk update
|
|
||||||
apk add zip
|
|
||||||
cd Library
|
|
||||||
zip -q -r lib-${buildUid}.zip .*
|
|
||||||
mv lib-${buildUid}.zip /${efsDirectoryName}/${cacheDirectoryName}/${branchName}/lib-${buildUid}.zip
|
|
||||||
cd ../../
|
|
||||||
zip -q -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,
|
|
||||||
);
|
|
||||||
|
|
||||||
core.info('Starting part 4/4 (upload build to s3)');
|
private static async SetupStep(
|
||||||
|
buildUid: string,
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
branchName: string | undefined,
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {
|
||||||
|
core.info('Starting part 1/4 (clone from github 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 " "
|
||||||
|
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 '/${efsDirectoryName}/${buildUid}/${repositoryDirectoryName}/${buildParameters.projectPath}/Library/.'
|
||||||
|
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}`,
|
||||||
|
|
@ -274,49 +348,9 @@ class RemoteBuilder {
|
||||||
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,
|
|
||||||
],
|
],
|
||||||
|
defaultSecretsArray,
|
||||||
);
|
);
|
||||||
|
|
||||||
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/`,
|
|
||||||
[],
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error);
|
|
||||||
core.error(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default RemoteBuilder;
|
export default RemoteBuilder;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue