Add Android Build Settings
This commit is contained in:
committed by
Webber Takken
parent
3523c6a934
commit
6ece6447b2
@@ -29,6 +29,10 @@ namespace UnityBuilderAction
|
||||
// Set version for this build
|
||||
VersionApplicator.SetVersion(options["version"]);
|
||||
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);
|
||||
|
||||
// Apply Android settings
|
||||
if (buildOptions.target == BuildTarget.Android)
|
||||
AndroidSettings.Apply(options);
|
||||
|
||||
// Perform build
|
||||
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityBuilderAction.Input
|
||||
{
|
||||
public class AndroidSettings
|
||||
{
|
||||
public static void Apply(Dictionary<string, string> options)
|
||||
{
|
||||
EditorUserBuildSettings.buildAppBundle = options["customBuildPath"].EndsWith(".aab");
|
||||
if (options.TryGetValue("androidKeystoreName", out string keystoreName) && !string.IsNullOrEmpty(keystoreName))
|
||||
PlayerSettings.Android.keystoreName = keystoreName;
|
||||
if (options.TryGetValue("androidKeystorePass", out string keystorePass) && !string.IsNullOrEmpty(keystorePass))
|
||||
PlayerSettings.Android.keystorePass = keystorePass;
|
||||
if (options.TryGetValue("androidKeyaliasName", out string keyaliasName) && !string.IsNullOrEmpty(keyaliasName))
|
||||
PlayerSettings.Android.keyaliasName = keyaliasName;
|
||||
if (options.TryGetValue("androidKeyaliasPass", out string keyaliasPass) && !string.IsNullOrEmpty(keyaliasPass))
|
||||
PlayerSettings.Android.keyaliasPass = keyaliasPass;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d51cf8acfff8c941bb753e82750b60a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityBuilderAction.Input
|
||||
@@ -7,6 +8,7 @@ namespace UnityBuilderAction.Input
|
||||
public class ArgumentsParser
|
||||
{
|
||||
static string EOL = Environment.NewLine;
|
||||
static readonly string[] Secrets = { "androidKeystorePass", "androidKeyaliasName", "androidKeyaliasPass" };
|
||||
|
||||
public static Dictionary<string, string> GetValidatedOptions()
|
||||
{
|
||||
@@ -66,9 +68,11 @@ namespace UnityBuilderAction.Input
|
||||
// Parse optional value
|
||||
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
|
||||
string value = flagHasValue ? args[next].TrimStart('-') : "";
|
||||
bool secret = Secrets.Contains(flag);
|
||||
string displayValue = secret ? "*HIDDEN*" : "\"" + value + "\"";
|
||||
|
||||
// Assign
|
||||
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
|
||||
Console.WriteLine($"Found flag \"{flag}\" with value {displayValue}.");
|
||||
providedArguments.Add(flag, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace UnityBuilderAction.Versioning
|
||||
static void Apply(string version)
|
||||
{
|
||||
PlayerSettings.bundleVersion = version;
|
||||
PlayerSettings.macOS.buildNumber = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -62,6 +62,16 @@ else
|
||||
#
|
||||
fi
|
||||
|
||||
#
|
||||
# Create Android keystore, if needed
|
||||
#
|
||||
if [[ -z $ANDROID_KEYSTORE_NAME || -z $ANDROID_KEYSTORE_BASE64 ]]; then
|
||||
echo "Not creating Android keystore."
|
||||
else
|
||||
echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_NAME"
|
||||
echo "Created Android keystore."
|
||||
fi
|
||||
|
||||
#
|
||||
# Display custom parameters
|
||||
#
|
||||
@@ -111,6 +121,10 @@ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
|
||||
-executeMethod "$BUILD_METHOD" \
|
||||
-version "$VERSION" \
|
||||
-androidVersionCode "$ANDROID_VERSION_CODE" \
|
||||
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
|
||||
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
|
||||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
|
||||
Reference in New Issue
Block a user