Allow versioning and version parameters.

This commit is contained in:
Webber 2020-04-22 22:12:04 +02:00 committed by Webber Takken
parent e8a2eaad72
commit 39a160b789
8 changed files with 38 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -109,6 +109,8 @@ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
-customBuildTarget "$BUILD_TARGET" \
-customBuildPath "$CUSTOM_BUILD_PATH" \
-executeMethod "$BUILD_METHOD" \
-versioning "$VERSIONING" \
-version "$VERSION" \
$CUSTOM_PARAMETERS
# Catch exit code

View File

@ -8,7 +8,7 @@ async function action() {
const { dockerfile, workspace, actionFolder } = Action;
const buildParameters = BuildParameters.create(Input.getFromUser());
const baseImage = new ImageTag(buildParameters);
const baseImage = new ImageTag({ ...buildParameters, version: buildParameters.unityVersion });
// Build docker image
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });

View File

@ -9,17 +9,21 @@ class BuildParameters {
buildName,
buildsPath,
buildMethod,
versioning,
version,
customParameters,
} = parameters;
return {
version: unityVersion,
unityVersion,
platform: targetPlatform,
projectPath,
buildName,
buildPath: `${buildsPath}/${targetPlatform}`,
buildFile: this.parseBuildFile(buildName, targetPlatform),
buildMethod,
versioning,
version,
customParameters,
};
}

View File

@ -18,7 +18,7 @@ describe('BuildParameters', () => {
});
it('returns the version', () => {
expect(BuildParameters.create(someParameters).version).toStrictEqual(
expect(BuildParameters.create(someParameters).unityVersion).toStrictEqual(
someParameters.unityVersion,
);
});

View File

@ -19,7 +19,7 @@ class Docker {
static async run(image, parameters, silent = false) {
const {
version,
unityVersion,
workspace,
platform,
projectPath,
@ -27,6 +27,8 @@ class Docker {
buildPath,
buildFile,
buildMethod,
versioning,
version,
customParameters,
} = parameters;
@ -38,13 +40,15 @@ class Docker {
--env UNITY_EMAIL \
--env UNITY_PASSWORD \
--env UNITY_SERIAL \
--env UNITY_VERSION="${version}" \
--env UNITY_VERSION="${unityVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env BUILD_TARGET="${platform}" \
--env BUILD_NAME="${buildName}" \
--env BUILD_PATH="${buildPath}" \
--env BUILD_FILE="${buildFile}" \
--env BUILD_METHOD="${buildMethod}" \
--env VERSIONING="${versioning}" \
--env VERSION="${version}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env HOME=/github/home \
--env GITHUB_REF \

View File

@ -0,0 +1,8 @@
class ValidationError extends Error {
constructor(message) {
super(message);
this.name = 'ValidationError';
}
}
export default ValidationError;

View File

@ -1,7 +1,10 @@
import Platform from './platform';
import ValidationError from './error/validation-error';
const core = require('@actions/core');
const versioningStrategies = ['None', 'Semantic', 'Tag', 'Custom'];
class Input {
static getFromUser() {
// Input variables specified in workflows using "with" prop.
@ -11,11 +14,20 @@ class Input {
const buildName = core.getInput('buildName') || targetPlatform;
const buildsPath = core.getInput('buildsPath') || 'build';
const buildMethod = core.getInput('buildMethod'); // processed in docker file
const versioning = core.getInput('versioning') || 'Semantic';
const version = core.getInput('version') || '';
const customParameters = core.getInput('customParameters') || '';
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
// Validate input
if (!versioningStrategies.includes(versioning)) {
throw new ValidationError(
`Versioning strategy should be one of ${versioningStrategies.join(', ')}.`,
);
}
// Return sanitised input
return {
unityVersion,
@ -24,6 +36,8 @@ class Input {
buildName,
buildsPath,
buildMethod,
versioning,
version,
customParameters,
};
}