mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
Allow versioning
and version
parameters.
This commit is contained in:
parent
e8a2eaad72
commit
39a160b789
File diff suppressed because one or more lines are too long
@ -109,6 +109,8 @@ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
|||||||
-customBuildTarget "$BUILD_TARGET" \
|
-customBuildTarget "$BUILD_TARGET" \
|
||||||
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
-customBuildPath "$CUSTOM_BUILD_PATH" \
|
||||||
-executeMethod "$BUILD_METHOD" \
|
-executeMethod "$BUILD_METHOD" \
|
||||||
|
-versioning "$VERSIONING" \
|
||||||
|
-version "$VERSION" \
|
||||||
$CUSTOM_PARAMETERS
|
$CUSTOM_PARAMETERS
|
||||||
|
|
||||||
# Catch exit code
|
# Catch exit code
|
||||||
|
@ -8,7 +8,7 @@ async function action() {
|
|||||||
|
|
||||||
const { dockerfile, workspace, actionFolder } = Action;
|
const { dockerfile, workspace, actionFolder } = Action;
|
||||||
const buildParameters = BuildParameters.create(Input.getFromUser());
|
const buildParameters = BuildParameters.create(Input.getFromUser());
|
||||||
const baseImage = new ImageTag(buildParameters);
|
const baseImage = new ImageTag({ ...buildParameters, version: buildParameters.unityVersion });
|
||||||
|
|
||||||
// Build docker image
|
// Build docker image
|
||||||
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
const builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
|
@ -9,17 +9,21 @@ class BuildParameters {
|
|||||||
buildName,
|
buildName,
|
||||||
buildsPath,
|
buildsPath,
|
||||||
buildMethod,
|
buildMethod,
|
||||||
|
versioning,
|
||||||
|
version,
|
||||||
customParameters,
|
customParameters,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
version: unityVersion,
|
unityVersion,
|
||||||
platform: targetPlatform,
|
platform: targetPlatform,
|
||||||
projectPath,
|
projectPath,
|
||||||
buildName,
|
buildName,
|
||||||
buildPath: `${buildsPath}/${targetPlatform}`,
|
buildPath: `${buildsPath}/${targetPlatform}`,
|
||||||
buildFile: this.parseBuildFile(buildName, targetPlatform),
|
buildFile: this.parseBuildFile(buildName, targetPlatform),
|
||||||
buildMethod,
|
buildMethod,
|
||||||
|
versioning,
|
||||||
|
version,
|
||||||
customParameters,
|
customParameters,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ describe('BuildParameters', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns the version', () => {
|
it('returns the version', () => {
|
||||||
expect(BuildParameters.create(someParameters).version).toStrictEqual(
|
expect(BuildParameters.create(someParameters).unityVersion).toStrictEqual(
|
||||||
someParameters.unityVersion,
|
someParameters.unityVersion,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,7 @@ class Docker {
|
|||||||
|
|
||||||
static async run(image, parameters, silent = false) {
|
static async run(image, parameters, silent = false) {
|
||||||
const {
|
const {
|
||||||
version,
|
unityVersion,
|
||||||
workspace,
|
workspace,
|
||||||
platform,
|
platform,
|
||||||
projectPath,
|
projectPath,
|
||||||
@ -27,6 +27,8 @@ class Docker {
|
|||||||
buildPath,
|
buildPath,
|
||||||
buildFile,
|
buildFile,
|
||||||
buildMethod,
|
buildMethod,
|
||||||
|
versioning,
|
||||||
|
version,
|
||||||
customParameters,
|
customParameters,
|
||||||
} = parameters;
|
} = parameters;
|
||||||
|
|
||||||
@ -38,13 +40,15 @@ class Docker {
|
|||||||
--env UNITY_EMAIL \
|
--env UNITY_EMAIL \
|
||||||
--env UNITY_PASSWORD \
|
--env UNITY_PASSWORD \
|
||||||
--env UNITY_SERIAL \
|
--env UNITY_SERIAL \
|
||||||
--env UNITY_VERSION="${version}" \
|
--env UNITY_VERSION="${unityVersion}" \
|
||||||
--env PROJECT_PATH="${projectPath}" \
|
--env PROJECT_PATH="${projectPath}" \
|
||||||
--env BUILD_TARGET="${platform}" \
|
--env BUILD_TARGET="${platform}" \
|
||||||
--env BUILD_NAME="${buildName}" \
|
--env BUILD_NAME="${buildName}" \
|
||||||
--env BUILD_PATH="${buildPath}" \
|
--env BUILD_PATH="${buildPath}" \
|
||||||
--env BUILD_FILE="${buildFile}" \
|
--env BUILD_FILE="${buildFile}" \
|
||||||
--env BUILD_METHOD="${buildMethod}" \
|
--env BUILD_METHOD="${buildMethod}" \
|
||||||
|
--env VERSIONING="${versioning}" \
|
||||||
|
--env VERSION="${version}" \
|
||||||
--env CUSTOM_PARAMETERS="${customParameters}" \
|
--env CUSTOM_PARAMETERS="${customParameters}" \
|
||||||
--env HOME=/github/home \
|
--env HOME=/github/home \
|
||||||
--env GITHUB_REF \
|
--env GITHUB_REF \
|
||||||
|
8
src/model/error/validation-error.js
Normal file
8
src/model/error/validation-error.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class ValidationError extends Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'ValidationError';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ValidationError;
|
@ -1,7 +1,10 @@
|
|||||||
import Platform from './platform';
|
import Platform from './platform';
|
||||||
|
import ValidationError from './error/validation-error';
|
||||||
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
|
const versioningStrategies = ['None', 'Semantic', 'Tag', 'Custom'];
|
||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
static getFromUser() {
|
static getFromUser() {
|
||||||
// Input variables specified in workflows using "with" prop.
|
// Input variables specified in workflows using "with" prop.
|
||||||
@ -11,11 +14,20 @@ class Input {
|
|||||||
const buildName = core.getInput('buildName') || targetPlatform;
|
const buildName = core.getInput('buildName') || targetPlatform;
|
||||||
const buildsPath = core.getInput('buildsPath') || 'build';
|
const buildsPath = core.getInput('buildsPath') || 'build';
|
||||||
const buildMethod = core.getInput('buildMethod'); // processed in docker file
|
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') || '';
|
const customParameters = core.getInput('customParameters') || '';
|
||||||
|
|
||||||
// Sanitise input
|
// Sanitise input
|
||||||
const projectPath = rawProjectPath.replace(/\/$/, '');
|
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 sanitised input
|
||||||
return {
|
return {
|
||||||
unityVersion,
|
unityVersion,
|
||||||
@ -24,6 +36,8 @@ class Input {
|
|||||||
buildName,
|
buildName,
|
||||||
buildsPath,
|
buildsPath,
|
||||||
buildMethod,
|
buildMethod,
|
||||||
|
versioning,
|
||||||
|
version,
|
||||||
customParameters,
|
customParameters,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user