【工具】自动打包工具GIT操作加入
parent
3e12b64118
commit
70bc51f319
|
|
@ -3,6 +3,7 @@ using UnityEditor;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
using GameEditor.FrameTool;
|
using GameEditor.FrameTool;
|
||||||
|
using GameEditor.Util;
|
||||||
|
|
||||||
public class AutoPack : EditorWindow
|
public class AutoPack : EditorWindow
|
||||||
{
|
{
|
||||||
|
|
@ -31,6 +32,8 @@ public class AutoPack : EditorWindow
|
||||||
static string ExportPackPath;
|
static string ExportPackPath;
|
||||||
static string ScenePath;
|
static string ScenePath;
|
||||||
static string ABPath;
|
static string ABPath;
|
||||||
|
static string APKPath;
|
||||||
|
static string PackTime;
|
||||||
|
|
||||||
// 判断是否要重新导出工程
|
// 判断是否要重新导出工程
|
||||||
static string[] ExportTypeList =
|
static string[] ExportTypeList =
|
||||||
|
|
@ -178,15 +181,18 @@ public class AutoPack : EditorWindow
|
||||||
ExportAS(i);
|
ExportAS(i);
|
||||||
ReplaceFromProject(i);
|
ReplaceFromProject(i);
|
||||||
ReplaceConfigAndVersion(i);
|
ReplaceConfigAndVersion(i);
|
||||||
|
CreateLogFile(i);
|
||||||
StartGradleBuild(i);
|
StartGradleBuild(i);
|
||||||
break;
|
break;
|
||||||
case 1: // 只替换AB
|
case 1: // 只替换AB
|
||||||
ReplaceFromAB(i);
|
ReplaceFromAB(i);
|
||||||
ReplaceConfigAndVersion(i);
|
ReplaceConfigAndVersion(i);
|
||||||
|
CreateLogFile(i);
|
||||||
StartGradleBuild(i);
|
StartGradleBuild(i);
|
||||||
break;
|
break;
|
||||||
case 2: // 只重新打包
|
case 2: // 只重新打包
|
||||||
ReplaceConfigAndVersion(i);
|
ReplaceConfigAndVersion(i);
|
||||||
|
CreateLogFile(i);
|
||||||
StartGradleBuild(i);
|
StartGradleBuild(i);
|
||||||
break;
|
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 工程
|
// 导出android 工程
|
||||||
public static void ExportAS(int index)
|
public static void ExportAS(int index)
|
||||||
{
|
{
|
||||||
|
|
@ -333,29 +354,34 @@ public class AutoPack : EditorWindow
|
||||||
// 开始生成apk
|
// 开始生成apk
|
||||||
private static void StartGradleBuild(int index)
|
private static void StartGradleBuild(int index)
|
||||||
{
|
{
|
||||||
EditorUtility.DisplayProgressBar("正在生成APK", "", 0.5f);
|
EditorUtility.DisplayProgressBar("正在生成APK", "", 0f);
|
||||||
string apkPath = _MomPackPath + PackConfig[index][2] + "/APK/";
|
GameEditor.Util.ProcessUtil.ProcessCommand(_MomPackPath + PackConfig[index][2], "gradlew assembleRelease>" + APKPath + "/_log.txt");
|
||||||
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", "", 0.5f);
|
EditorUtility.DisplayProgressBar("正在导出APK", "", 1f);
|
||||||
string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk";
|
string apkFilePath = _MomPackPath + PackConfig[index][2] + "/build/outputs/apk/release/" + PackConfig[index][2] + "-release.apk";
|
||||||
if (File.Exists(apkFilePath))
|
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] + ":打包完成");
|
Debug.Log(PackConfig[index][0] + ":打包完成");
|
||||||
EditorUtility.ClearProgressBar();
|
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)
|
//private static void ExportXcode(string _sceneName)
|
||||||
//{
|
//{
|
||||||
// PlayerSettings.productName = "太初行";
|
// PlayerSettings.productName = "太初行";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue