mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00

* Enable noImplicitAny Add types to all implicit any variables Bump target to ES2020 for recent language features (optional chaining) Code cleanup Add debug configuration for vscode Remove autorun flag from jest to remove warning Bump packages to fix dependency version mismatch warning Changed @arkweid/lefthook to @evilmartians/lefthook as @arkweid/lefthook has been deprecated in favor of @evilmartians/lefthook Added concurrency groups to integrity check and build workflows. New commits to branches will cancel superseded runs on the same branch/pr Update imports to not use require syntax Use node packages (ie node:fs rather than fs) AndroidVersionCode is now a string rather than a number as it gets converted to a string when passed out of the system Reduce timeout for windows builds Remove 2020.1.17f1 from windows builds due to repeated license activation errors Update naming scheme of workflows for consistency Update build names so target platform and unity version aren't cut off by github actions UI * Add exclude to test matrix for 2022.2 on android until Unity bug is fixed --------- Co-authored-by: AndrewKahr <AndrewKahr@users.noreply.github.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import * as core from '@actions/core';
|
|
import * as semver from 'semver';
|
|
|
|
export default class AndroidVersioning {
|
|
static determineVersionCode(version: string, inputVersionCode: string): string {
|
|
if (inputVersionCode === '') {
|
|
return AndroidVersioning.versionToVersionCode(version);
|
|
}
|
|
|
|
return inputVersionCode;
|
|
}
|
|
|
|
static versionToVersionCode(version: string): string {
|
|
if (version === 'none') {
|
|
core.info(`Versioning strategy is set to ${version}, so android version code should not be applied.`);
|
|
|
|
return '0';
|
|
}
|
|
|
|
const parsedVersion = semver.parse(version);
|
|
|
|
if (!parsedVersion) {
|
|
core.warning(`Could not parse "${version}" to semver, defaulting android version code to 1`);
|
|
|
|
return '1';
|
|
}
|
|
|
|
// The greatest value Google Plays allows is 2100000000.
|
|
// Allow for 3 patch digits, 3 minor digits and 3 major digits.
|
|
const versionCode = parsedVersion.major * 1000000 + parsedVersion.minor * 1000 + parsedVersion.patch;
|
|
|
|
if (versionCode >= 2050000000) {
|
|
throw new Error(
|
|
`Generated versionCode ${versionCode} is dangerously close to the maximum allowed number 2100000000. Consider a different versioning scheme to be able to continue updating your application.`,
|
|
);
|
|
}
|
|
core.info(`Using android versionCode ${versionCode}`);
|
|
|
|
return versionCode.toString();
|
|
}
|
|
|
|
static determineSdkManagerParameters(targetSdkVersion: string) {
|
|
const parsedVersion = Number.parseInt(targetSdkVersion.slice(-2), 10);
|
|
|
|
return Number.isNaN(parsedVersion) ? '' : `platforms;android-${parsedVersion}`;
|
|
}
|
|
}
|