Improve androidVersionCode parsing and application (#297)

This commit is contained in:
David Finol
2021-11-15 11:12:37 -06:00
committed by GitHub
parent 13fdcad790
commit 11a0d0947e
5 changed files with 23 additions and 5 deletions

View File

@@ -15,7 +15,12 @@ namespace UnityBuilderAction.Versioning
}
public static void SetAndroidVersionCode(string androidVersionCode) {
PlayerSettings.Android.bundleVersionCode = Int32.Parse(androidVersionCode);
int bundleVersionCode = Int32.Parse(androidVersionCode);
if (bundleVersionCode <= 0) {
return;
}
PlayerSettings.Android.bundleVersionCode = bundleVersionCode;
}
static void Apply(string version)

6
dist/index.js generated vendored
View File

@@ -161,6 +161,10 @@ class AndroidVersioning {
return inputVersionCode;
}
static versionToVersionCode(version) {
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`);
@@ -169,7 +173,7 @@ class AndroidVersioning {
// 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 >= 1000000000) {
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}`);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long