自动设置版本号
This commit is contained in:
parent
e4446afdec
commit
4316bca531
@ -13,6 +13,8 @@ namespace BFEditor.Build
|
|||||||
|
|
||||||
public class BuildProjectWindow : EditorWindow
|
public class BuildProjectWindow : EditorWindow
|
||||||
{
|
{
|
||||||
|
private static int versionCode = 13;
|
||||||
|
private static string versionName = "1.2.0";
|
||||||
BFPlatformOptions platform = BFPlatformOptions.AndroidDev;
|
BFPlatformOptions platform = BFPlatformOptions.AndroidDev;
|
||||||
const string ANDROID_DEV_PACKAGE_NAME = "com.juzu.b6.dev.android";
|
const string ANDROID_DEV_PACKAGE_NAME = "com.juzu.b6.dev.android";
|
||||||
const string ANDROID_RELEASE_PACKAGE_NAME = "com.juzu.b6.release.android";
|
const string ANDROID_RELEASE_PACKAGE_NAME = "com.juzu.b6.release.android";
|
||||||
@ -34,7 +36,7 @@ namespace BFEditor.Build
|
|||||||
platform = (BFPlatformOptions)EditorGUILayout.EnumPopup("", platform);
|
platform = (BFPlatformOptions)EditorGUILayout.EnumPopup("", platform);
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
EditorGUILayout.LabelField("版本: 0.1.0");
|
EditorGUILayout.LabelField("版本: " + versionName);
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
string packageName;
|
string packageName;
|
||||||
@ -70,7 +72,8 @@ namespace BFEditor.Build
|
|||||||
if (GUILayout.Button("一键打包"))
|
if (GUILayout.Button("一键打包"))
|
||||||
{
|
{
|
||||||
var buildInfo = new BuildInfo();
|
var buildInfo = new BuildInfo();
|
||||||
buildInfo.version = "0.1.0";
|
buildInfo.version = versionName;
|
||||||
|
buildInfo.version_code = versionCode;
|
||||||
buildInfo.mode = mode;
|
buildInfo.mode = mode;
|
||||||
buildInfo.bundleName = packageName;
|
buildInfo.bundleName = packageName;
|
||||||
buildInfo.skipVersion = skipVersion;
|
buildInfo.skipVersion = skipVersion;
|
||||||
|
|||||||
@ -29,6 +29,7 @@ namespace BFEditor.Build
|
|||||||
static string GoogleCommonProjectPath = Application.dataPath + "/../BFVersions/android/google_common";
|
static string GoogleCommonProjectPath = Application.dataPath + "/../BFVersions/android/google_common";
|
||||||
static string GPAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-gp"; // gp删档测试渠道
|
static string GPAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-gp"; // gp删档测试渠道
|
||||||
static string GPOfficialAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-google"; // gp正式渠道
|
static string GPOfficialAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-google"; // gp正式渠道
|
||||||
|
static string PublishAsProjectPath = Application.dataPath + "/../BFVersions/android/publish_release";
|
||||||
static string SignShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
static string SignShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
||||||
static string GpAlginShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
static string GpAlginShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
||||||
|
|
||||||
@ -282,6 +283,7 @@ namespace BFEditor.Build
|
|||||||
else if(buildInfo.IsGPChannel())
|
else if(buildInfo.IsGPChannel())
|
||||||
{
|
{
|
||||||
MergeProject(buildInfo, GoogleAsProjectPath);
|
MergeProject(buildInfo, GoogleAsProjectPath);
|
||||||
|
FixGradleVersion(buildInfo.version_code, buildInfo.version);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -391,13 +393,19 @@ namespace BFEditor.Build
|
|||||||
static void FixGradleVersion(int versionCode, string versionName)
|
static void FixGradleVersion(int versionCode, string versionName)
|
||||||
{
|
{
|
||||||
Debug.Log("[bfinfo]修正build.gradle: VersionCode " + versionCode + " VersionName " + versionName);
|
Debug.Log("[bfinfo]修正build.gradle: VersionCode " + versionCode + " VersionName " + versionName);
|
||||||
var gradleFilePath = Path.Combine(GradleExcuteProjectPath, "build.gradle");
|
var gradleFilePath = Path.Combine(PublishAsProjectPath, "launcher", "build.gradle");
|
||||||
var text = File.ReadAllText(gradleFilePath);
|
var text = File.ReadAllText(gradleFilePath);
|
||||||
var regex = new Regex("versionCode 1");
|
var regex = new Regex("versionCode 1");
|
||||||
text = regex.Replace(text, string.Format("versionCode {0}", versionCode));
|
text = regex.Replace(text, string.Format("versionCode {0}", versionCode));
|
||||||
regex = new Regex("versionName '0.1'");
|
var regex2 = new Regex("versionName '0.1.0'");
|
||||||
text = regex.Replace(text, string.Format("versionName '{0}'", versionName));
|
text = regex2.Replace(text, string.Format("versionName '{0}'", versionName));
|
||||||
File.WriteAllText(gradleFilePath, text);
|
File.WriteAllText(gradleFilePath, text);
|
||||||
|
|
||||||
|
var gradleFilePath2 = Path.Combine(PublishAsProjectPath, "unityLibrary", "build.gradle");
|
||||||
|
var text2 = File.ReadAllText(gradleFilePath2);
|
||||||
|
text2 = regex.Replace(text2, string.Format("versionCode {0}", versionCode));
|
||||||
|
text2 = regex2.Replace(text, string.Format("versionName '{0}'", versionName));
|
||||||
|
File.WriteAllText(gradleFilePath2, text2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user