From 70bc51f319f9cd6518f016d85eb4be863e13ff23 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 1 Jun 2021 10:41:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E5=85=B7=E3=80=91=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=89=93=E5=8C=85=E5=B7=A5=E5=85=B7GIT=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=8A=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Editor/AutoPack.cs | 54 +++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/Assets/Editor/AutoPack.cs b/Assets/Editor/AutoPack.cs index 4a07af5fba..c06b410a53 100644 --- a/Assets/Editor/AutoPack.cs +++ b/Assets/Editor/AutoPack.cs @@ -3,6 +3,7 @@ using UnityEditor; using System.IO; using System; using GameEditor.FrameTool; +using GameEditor.Util; public class AutoPack : EditorWindow { @@ -31,6 +32,8 @@ public class AutoPack : EditorWindow static string ExportPackPath; static string ScenePath; static string ABPath; + static string APKPath; + static string PackTime; // 判断是否要重新导出工程 static string[] ExportTypeList = @@ -178,15 +181,18 @@ public class AutoPack : EditorWindow ExportAS(i); ReplaceFromProject(i); ReplaceConfigAndVersion(i); + CreateLogFile(i); StartGradleBuild(i); break; case 1: // 只替换AB ReplaceFromAB(i); ReplaceConfigAndVersion(i); + CreateLogFile(i); StartGradleBuild(i); break; case 2: // 只重新打包 ReplaceConfigAndVersion(i); + CreateLogFile(i); StartGradleBuild(i); break; } @@ -194,6 +200,21 @@ public class AutoPack : EditorWindow } + public static void CreateLogFile(int index) + { + APKPath = _MomPackPath + PackConfig[index][2] + "/APK/"; + if (!Directory.Exists(APKPath)) + { + Directory.CreateDirectory(APKPath); + } + PackTime = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); + APKPath += PackTime; + if (!Directory.Exists(APKPath)) + { + Directory.CreateDirectory(APKPath); + } + + } // 导出android 工程 public static void ExportAS(int index) { @@ -333,29 +354,34 @@ public class AutoPack : EditorWindow // 开始生成apk private static void StartGradleBuild(int index) { - EditorUtility.DisplayProgressBar("正在生成APK", "", 0.5f); - string apkPath = _MomPackPath + PackConfig[index][2] + "/APK/"; - if (!Directory.Exists(apkPath)) - { - Directory.CreateDirectory(apkPath); - } - string time = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); - if (!Directory.Exists(apkPath + time)) - { - Directory.CreateDirectory(apkPath + time); - } - GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>" + apkPath + time +"/_log.txt"); + EditorUtility.DisplayProgressBar("正在生成APK", "", 0f); + GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>" + APKPath + "/_log.txt"); - EditorUtility.DisplayProgressBar("正在导出APK", "", 0.5f); + EditorUtility.DisplayProgressBar("正在导出APK", "", 1f); string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk"; if (File.Exists(apkFilePath)) { - File.Copy(apkFilePath, apkPath + time + "/" + PackConfig[index][2] + ".apk"); + File.Copy(apkFilePath, APKPath + "/" + PackConfig[index][2] + ".apk"); } Debug.Log(PackConfig[index][0] + ":打包完成"); EditorUtility.ClearProgressBar(); } + private static void GitUpdate(int index) + { + EditorUtility.DisplayProgressBar("正在更新母包", "", 0f); + ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "git pull>" + APKPath + "/_log.txt"); + EditorUtility.ClearProgressBar(); + } + private static void GitCommit(int index) + { + EditorUtility.DisplayProgressBar("正在提交修改", "", 0f); + ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "git add .>" + APKPath + "/_log.txt"); + ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "git commit 'AutoPack:"+ PackConfig[index][0]+" "+PackTime+"/"+ PackConfig[index][2] +".apk'"); + EditorUtility.ClearProgressBar(); + + } + //private static void ExportXcode(string _sceneName) //{ // PlayerSettings.productName = "太初行";