From 5f9bc0caae5a770483c3edbf87e6726822628254 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 5 Aug 2021 14:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=89=93=E5=8C=85=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E3=80=91=E4=BF=AE=E6=94=B9=E5=87=BA=E5=8C=85=E7=9A=84=E5=8C=85?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=97=A5=E5=BF=97=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Editor/AutoPack.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) 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);