diff --git a/Assets/Editor/AutoPack.cs b/Assets/Editor/AutoPack.cs index 1eb4435c88..9e9208e8e0 100644 --- a/Assets/Editor/AutoPack.cs +++ b/Assets/Editor/AutoPack.cs @@ -415,15 +415,37 @@ public class AutoPack : EditorWindow GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>>" + APKPath + "/_log.txt"); EditorUtility.DisplayProgressBar("正在导出APK", "", 1f); + + string versionStr = GetAPKVersionStr(PackConfig[index][2]); string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk"; if (File.Exists(apkFilePath)) { - File.Copy(apkFilePath, APKPath + "/" + PackConfig[index][2] + ".apk"); + File.Copy(apkFilePath, APKPath + "/" + PackConfig[index][0] +"_"+ PackConfig[index][2] + "_" + versionStr + "_" + PackTime + ".apk"); } Debug.Log(PackConfig[index][0] + ":打包完成"); EditorUtility.ClearProgressBar(); } + private static string GetAPKVersionStr(string folder) + { + string tpath = _MomPackPath + folder + "/build.gradle"; + string[] lines = File.ReadAllLines(tpath); + string versionCode = ""; + string versionName = ""; + foreach (string l in lines) + { + string lt = l.Trim(); + if (lt.StartsWith("versionCode")) + { + versionCode = lt.Split(' ')[1]; + }else if (lt.StartsWith("versionName")) + { + versionName = lt.Split('\'')[1]; + } + } + return string.Format("{0}({1})", versionName, versionCode); + } + private static void GitUpdate(int index) { EditorUtility.DisplayProgressBar("正在更新母包", "", 0f); @@ -434,13 +456,14 @@ public class AutoPack : EditorWindow { if (CommitToGit) { + string versionStr = GetAPKVersionStr(PackConfig[index][2]); EditorUtility.DisplayProgressBar("正在提交修改", "", 0f); string printlog = ">>" + APKPath + "/_log.txt"; string[] commands = new string[]{ "echo git add ." + printlog, "git add ." + printlog, - "echo git commit -m 'AutoPack:" + PackConfig[index][0] + "-" + PackTime + "-" + PackConfig[index][2] + ".apk'" + printlog, - "git commit -m 'AutoPack:" + PackConfig[index][0] + "-" + PackTime + "-" + PackConfig[index][2] + ".apk'" + printlog, + "echo git commit -m 'AutoPack:" + PackConfig[index][0] +"_"+ PackConfig[index][2] + "_" + versionStr + "_" + PackTime + ".apk'" + printlog, + "git commit -m 'AutoPack:" + PackConfig[index][0] +"_"+ PackConfig[index][2] + "_" + versionStr + "_" + PackTime + ".apk'" + printlog, "git push", }; ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], commands);