2020-01-20 23:06:14 +00:00
|
|
|
import Platform from './platform';
|
2020-04-22 20:12:04 +00:00
|
|
|
import ValidationError from './error/validation-error';
|
2020-01-20 23:06:14 +00:00
|
|
|
|
2019-12-22 14:05:15 +00:00
|
|
|
const core = require('@actions/core');
|
|
|
|
|
|
2020-04-22 20:12:04 +00:00
|
|
|
const versioningStrategies = ['None', 'Semantic', 'Tag', 'Custom'];
|
|
|
|
|
|
2020-01-20 23:06:14 +00:00
|
|
|
class Input {
|
2019-12-22 14:05:15 +00:00
|
|
|
static getFromUser() {
|
|
|
|
|
// Input variables specified in workflows using "with" prop.
|
2020-01-20 23:06:14 +00:00
|
|
|
const unityVersion = core.getInput('unityVersion');
|
|
|
|
|
const targetPlatform = core.getInput('targetPlatform') || Platform.default;
|
2020-01-27 22:03:29 +00:00
|
|
|
const rawProjectPath = core.getInput('projectPath') || '.';
|
2020-01-20 23:06:14 +00:00
|
|
|
const buildName = core.getInput('buildName') || targetPlatform;
|
|
|
|
|
const buildsPath = core.getInput('buildsPath') || 'build';
|
|
|
|
|
const buildMethod = core.getInput('buildMethod'); // processed in docker file
|
2020-04-22 20:12:04 +00:00
|
|
|
const versioning = core.getInput('versioning') || 'Semantic';
|
|
|
|
|
const version = core.getInput('version') || '';
|
2020-01-27 18:39:49 +00:00
|
|
|
const customParameters = core.getInput('customParameters') || '';
|
2019-12-22 14:05:15 +00:00
|
|
|
|
2020-01-27 22:03:29 +00:00
|
|
|
// Sanitise input
|
|
|
|
|
const projectPath = rawProjectPath.replace(/\/$/, '');
|
|
|
|
|
|
2020-04-22 20:12:04 +00:00
|
|
|
// Validate input
|
|
|
|
|
if (!versioningStrategies.includes(versioning)) {
|
|
|
|
|
throw new ValidationError(
|
|
|
|
|
`Versioning strategy should be one of ${versioningStrategies.join(', ')}.`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 22:03:29 +00:00
|
|
|
// Return sanitised input
|
2019-12-22 14:05:15 +00:00
|
|
|
return {
|
2020-01-20 23:06:14 +00:00
|
|
|
unityVersion,
|
|
|
|
|
targetPlatform,
|
2019-12-22 14:05:15 +00:00
|
|
|
projectPath,
|
|
|
|
|
buildName,
|
|
|
|
|
buildsPath,
|
2020-01-20 23:06:14 +00:00
|
|
|
buildMethod,
|
2020-04-22 20:12:04 +00:00
|
|
|
versioning,
|
|
|
|
|
version,
|
2020-01-27 18:39:49 +00:00
|
|
|
customParameters,
|
2019-12-22 14:05:15 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-20 23:06:14 +00:00
|
|
|
|
|
|
|
|
export default Input;
|