From a2d6617a0fca66df5f07012ff12bb89c873970d1 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Sun, 8 May 2022 01:26:06 +0800 Subject: [PATCH 01/17] =?UTF-8?q?chore.=E4=BF=AE=E6=94=B9=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=96=87=E4=BB=B6=E4=BB=A5=E9=80=82=E9=85=8D=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + MeoAssistantArknights.sln | 55 +- src/MeoAssistant/MeoAssistant.vcxproj | 617 ++++++++++-------- src/MeoAsstGui/MeoAsstGui.csproj | 60 +- .../Properties/Resources.Designer.cs | 72 -- src/MeoAsstGui/Properties/Resources.resx | 117 ---- .../Properties/Settings.Designer.cs | 30 - src/MeoAsstGui/Properties/Settings.settings | 7 - 8 files changed, 393 insertions(+), 566 deletions(-) delete mode 100644 src/MeoAsstGui/Properties/Resources.Designer.cs delete mode 100644 src/MeoAsstGui/Properties/Resources.resx delete mode 100644 src/MeoAsstGui/Properties/Settings.Designer.cs delete mode 100644 src/MeoAsstGui/Properties/Settings.settings diff --git a/.gitignore b/.gitignore index 025aa6f8be..77f946f4f5 100644 --- a/.gitignore +++ b/.gitignore @@ -436,3 +436,4 @@ adb_screen.png tools/**/*.png resource/infrast .vscode +!3rdparty/tools/* diff --git a/MeoAssistantArknights.sln b/MeoAssistantArknights.sln index 513ca97847..a2deaf4e91 100644 --- a/MeoAssistantArknights.sln +++ b/MeoAssistantArknights.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31515.178 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32414.318 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{6C4B8D52-51D1-45F8-AAEC-808035443FD6}" EndProject @@ -11,9 +11,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCaller", "tools\TestCal EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MeoAsstGui", "src\MeoAsstGui\MeoAsstGui.csproj", "{FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}" - ProjectSection(ProjectDependencies) = postProject - {362D1E30-F5AE-4279-9985-65C27B3BA300} = {362D1E30-F5AE-4279-9985-65C27B3BA300} - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TransparentImageCvt", "tools\TransparentImageCvt\TransparentImageCvt.vcxproj", "{093A3174-A27E-4D23-B64E-16F9448AD5AC}" EndProject @@ -24,44 +21,52 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeoAssistantBuilder", "src\MeoAssistantBuilder\MeoAssistantBuilder.csproj", "{8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + CICD|x64 = CICD|x64 + Debug|x64 = Debug|x64 Release|x64 = Release|x64 - Release|x86 = Release|x86 RelWithDebInfo|x64 = RelWithDebInfo|x64 - RelWithDebInfo|x86 = RelWithDebInfo|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.CICD|x64.ActiveCfg = RelWithDebInfo|x64 + {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.CICD|x64.Build.0 = RelWithDebInfo|x64 + {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|x64.ActiveCfg = RelWithDebInfo|x64 + {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Debug|x64.Build.0 = RelWithDebInfo|x64 {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|x64.ActiveCfg = Release|x64 {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|x64.Build.0 = Release|x64 - {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.Release|x86.ActiveCfg = Release|x64 {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64 {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64 - {63B4F1A2-291C-4C85-91E1-A1F6DAE30D64}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64 - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.ActiveCfg = Release|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.Build.0 = Release|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x86.ActiveCfg = Release|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x86.Build.0 = Release|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|Any CPU - {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|Any CPU + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.CICD|x64.ActiveCfg = CICD|x64 + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.CICD|x64.Build.0 = CICD|x64 + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Debug|x64.ActiveCfg = Release|x64 + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.ActiveCfg = Release|x64 + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.Release|x64.Build.0 = Release|x64 + {FFDC8F49-8EAF-45BE-B0A8-7EF0DB9875A2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64 + {093A3174-A27E-4D23-B64E-16F9448AD5AC}.CICD|x64.ActiveCfg = Release|x64 + {093A3174-A27E-4D23-B64E-16F9448AD5AC}.CICD|x64.Build.0 = Release|x64 + {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Debug|x64.ActiveCfg = Release|x64 + {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Debug|x64.Build.0 = Release|x64 {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Release|x64.ActiveCfg = Release|x64 {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Release|x64.Build.0 = Release|x64 - {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Release|x86.ActiveCfg = Release|Win32 - {093A3174-A27E-4D23-B64E-16F9448AD5AC}.Release|x86.Build.0 = Release|Win32 {093A3174-A27E-4D23-B64E-16F9448AD5AC}.RelWithDebInfo|x64.ActiveCfg = Release|x64 {093A3174-A27E-4D23-B64E-16F9448AD5AC}.RelWithDebInfo|x64.Build.0 = Release|x64 - {093A3174-A27E-4D23-B64E-16F9448AD5AC}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 - {093A3174-A27E-4D23-B64E-16F9448AD5AC}.RelWithDebInfo|x86.Build.0 = Release|Win32 + {362D1E30-F5AE-4279-9985-65C27B3BA300}.CICD|x64.ActiveCfg = CICD|x64 + {362D1E30-F5AE-4279-9985-65C27B3BA300}.CICD|x64.Build.0 = CICD|x64 + {362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|x64.ActiveCfg = RelWithDebInfo|x64 + {362D1E30-F5AE-4279-9985-65C27B3BA300}.Debug|x64.Build.0 = RelWithDebInfo|x64 {362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x64.ActiveCfg = Release|x64 {362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x64.Build.0 = Release|x64 - {362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x86.ActiveCfg = Release|x64 - {362D1E30-F5AE-4279-9985-65C27B3BA300}.Release|x86.Build.0 = Release|x64 {362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64 {362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64 - {362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64 - {362D1E30-F5AE-4279-9985-65C27B3BA300}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.CICD|x64.ActiveCfg = Release|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.CICD|x64.Build.0 = Release|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.Debug|x64.ActiveCfg = Debug|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.Release|x64.ActiveCfg = Release|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.Release|x64.Build.0 = Release|x64 + {8D9036DD-75F1-4BD0-89E2-DFB37B925DA3}.RelWithDebInfo|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/MeoAssistant/MeoAssistant.vcxproj b/src/MeoAssistant/MeoAssistant.vcxproj index d3be7e62ce..bc44ff174b 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj +++ b/src/MeoAssistant/MeoAssistant.vcxproj @@ -1,280 +1,337 @@ - - - - - Release - x64 - - - RelWithDebInfo - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16.0 - Win32Proj - {362d1e30-f5ae-4279-9985-65c27b3ba300} - MeoAssistant - 10.0 - - - - DynamicLibrary - false - v143 - true - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - false - $(SolutionDir)include;$(SolutionDir)3rdparty\include;$(IncludePath) - $(TargetDir);$(SolutionDir)\3rdparty\lib;$(LibraryPath) - - - false - $(SolutionDir)include;$(SolutionDir)3rdparty\include;$(IncludePath) - $(TargetDir);$(SolutionDir)\3rdparty\lib;$(LibraryPath) - - - - Level4 - true - true - true - NDEBUG;_CONSOLE;ASST_DLL_EXPORTS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreaded - MaxSpeed - /utf-8 /MP %(AdditionalOptions) - - - Console - true - true - true - ppocr.lib;opencv_world453.lib;zlibstatic.lib;%(AdditionalDependencies) - RequireAdministrator - - - true - msvcrt.lib - - - - - - - xcopy /e /y /i /c $(SolutionDir)resource $(TargetDir)resource -xcopy /e /y /i /c $(SolutionDir)3rdparty\resource $(TargetDir)resource - - - copy resource - - - xcopy /e /y /i /c $(SolutionDir)3rdparty\bin $(TargetDir) - - - copy 3rd party dll - - - - - Level4 - - - false - true - NDEBUG;_CONSOLE;ASST_DLL_EXPORTS;ASST_DEBUG;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreaded - Disabled - true - EnableFastChecks - /utf-8 /MP %(AdditionalOptions) - - - Console - true - true - true - ppocr.lib;opencv_world453.lib;zlibstatic.lib;%(AdditionalDependencies) - RequireAdministrator - - - true - msvcrt.lib - - - - - - - xcopy /e /y /i /c $(SolutionDir)resource $(TargetDir)resource -xcopy /e /y /i /c $(SolutionDir)3rdparty\resource $(TargetDir)resource - - - copy resource - - - xcopy /e /y /i /c $(SolutionDir)3rdparty\bin $(TargetDir) - - - copy 3rd party dll - - - - - - - - - - - \ No newline at end of file + + + + + Release + x64 + + + RelWithDebInfo + x64 + + + CICD + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16.0 + Win32Proj + {362d1e30-f5ae-4279-9985-65c27b3ba300} + MeoAssistant + 10.0 + + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + false + $(ProjectDir)..\..\include;$(ProjectDir)..\..\3rdparty\include;$(IncludePath) + $(TargetDir);$(ProjectDir)..\..\3rdparty\lib;$(LibraryPath) + $(ProjectDir)..\..\$(Platform)\$(Configuration)\ + + + false + $(ProjectDir)..\..\include;$(ProjectDir)..\..\3rdparty\include;$(IncludePath) + $(TargetDir);$(ProjectDir)..\..\3rdparty\lib;$(LibraryPath) + $(ProjectDir)..\..\$(Platform)\$(Configuration)\ + + + false + $(ProjectDir)..\..\include;$(ProjectDir)..\..\3rdparty\include;$(IncludePath) + $(TargetDir);$(ProjectDir)..\..\3rdparty\lib;$(LibraryPath) + $(ProjectDir)..\..\$(Platform)\$(Configuration)\ + + + + Level4 + true + true + true + NDEBUG;_CONSOLE;ASST_DLL_EXPORTS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreaded + MaxSpeed + /utf-8 /MP %(AdditionalOptions) + + + Console + true + true + true + ppocr.lib;opencv_world453.lib;zlibstatic.lib;%(AdditionalDependencies) + RequireAdministrator + + + true + msvcrt.lib + + + + + + + + xcopy /e /y /i /c $(ProjectDir)..\..\resource $(TargetDir)resource + xcopy /e /y /i /c $(ProjectDir)..\..\3rdparty\resource $(TargetDir)resource + + + + Copy resource + + + + xcopy /e /y /i /c $(ProjectDir)..\..\3rdparty\bin $(TargetDir) + + + + Copy 3rd party dll + + + + + Level4 + true + true + true + NDEBUG;_CONSOLE;ASST_DLL_EXPORTS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreaded + MaxSpeed + /utf-8 /MP %(AdditionalOptions) + + + Console + true + true + true + ppocr.lib;opencv_world453.lib;zlibstatic.lib;%(AdditionalDependencies) + RequireAdministrator + + + true + msvcrt.lib + + + + + Level4 + + + false + true + NDEBUG;_CONSOLE;ASST_DLL_EXPORTS;ASST_DEBUG;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreaded + Disabled + true + EnableFastChecks + /utf-8 /MP %(AdditionalOptions) + + + Console + true + true + true + ppocr.lib;opencv_world453.lib;zlibstatic.lib;%(AdditionalDependencies) + RequireAdministrator + + + true + msvcrt.lib + + + + + + + + xcopy /e /y /i /c $(ProjectDir)..\..\resource $(TargetDir)resource + xcopy /e /y /i /c $(ProjectDir)..\..\3rdparty\resource $(TargetDir)resource + + + + Copy resource + + + + xcopy /e /y /i /c $(ProjectDir)..\..\3rdparty\bin $(TargetDir) + + + + Copy 3rd party dll + + + + + + + + + + + diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj index 7d8ee09952..500b1633c0 100644 --- a/src/MeoAsstGui/MeoAsstGui.csproj +++ b/src/MeoAsstGui/MeoAsstGui.csproj @@ -38,23 +38,25 @@ false true - - x64 - pdbonly - true - ..\..\x64\Release\ - TRACE - prompt - 4 - false - - Always + OnBuildSuccess newlogo.ico - + + MeoAsstGui.App + + + ..\..\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + + ..\..\x64\RelWithDebInfo\ DEBUG;TRACE false @@ -63,8 +65,15 @@ 7.3 prompt - - MeoAsstGui.App + + ..\..\x64\CICD\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true @@ -225,26 +234,7 @@ Code - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - @@ -252,7 +242,7 @@ False - Microsoft .NET Framework 4.7.2 %28x86 和 x64%29 + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 true @@ -417,6 +407,6 @@ - xcopy /e /y /i /c $(SolutionDir)resource $(TargetDir)resource + xcopy /e /y /i /c $(ProjectDir)..\..\3rdparty\tools $(TargetDir) \ No newline at end of file diff --git a/src/MeoAsstGui/Properties/Resources.Designer.cs b/src/MeoAsstGui/Properties/Resources.Designer.cs deleted file mode 100644 index 18701c716e..0000000000 --- a/src/MeoAsstGui/Properties/Resources.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace MeoAsstGui.Properties -{ - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if (object.ReferenceEquals(resourceMan, null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MeoAsstGui.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/src/MeoAsstGui/Properties/Resources.resx b/src/MeoAsstGui/Properties/Resources.resx deleted file mode 100644 index af7dbebbac..0000000000 --- a/src/MeoAsstGui/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/MeoAsstGui/Properties/Settings.Designer.cs b/src/MeoAsstGui/Properties/Settings.Designer.cs deleted file mode 100644 index af956e4392..0000000000 --- a/src/MeoAsstGui/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace MeoAsstGui.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/src/MeoAsstGui/Properties/Settings.settings b/src/MeoAsstGui/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9e..0000000000 --- a/src/MeoAsstGui/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From 311ce4d84969a41076cfd3fa64e0926ef5b69f4a Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 13:05:28 +0800 Subject: [PATCH 02/17] =?UTF-8?q?bump.=E6=B8=85=E7=90=86=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/MeoAsstGui.csproj | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/MeoAsstGui/MeoAsstGui.csproj b/src/MeoAsstGui/MeoAsstGui.csproj index 500b1633c0..9d8e758887 100644 --- a/src/MeoAsstGui/MeoAsstGui.csproj +++ b/src/MeoAsstGui/MeoAsstGui.csproj @@ -76,24 +76,9 @@ true - - ..\..\packages\Costura.Fody.5.6.0\lib\netstandard1.0\Costura.dll - - - ..\..\packages\gong-wpf-dragdrop.2.4.1\lib\net47\GongSolutions.WPF.DragDrop.dll - - - ..\..\packages\HandyControl.3.2.0\lib\net472\HandyControl.dll - - - ..\..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll - ..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - - ..\..\packages\Stylet.1.3.6\lib\net45\Stylet.dll - @@ -261,13 +246,13 @@ all - 2.4.3 + 3.1.1 3.3.0 - 5.0.4 + 6.0.3 4.3.0 @@ -279,7 +264,7 @@ 13.0.1 - 6.1.0.1 + 6.1.0.5 1.3.6 @@ -300,7 +285,7 @@ 4.3.0 - 5.0.1 + 6.0.0 4.3.0 From 4de65cc66ec0ac4b88d684fdb1e0bf5743f50393 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 13:05:46 +0800 Subject: [PATCH 03/17] =?UTF-8?q?feat.=E6=B7=BB=E5=8A=A0=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistantBuilder/Constants.cs | 23 ++++ .../Helper/BuildCoreHelper.cs | 17 +++ .../Helper/BuildWpfHelper.cs | 18 ++++ .../Helper/CleanDirectoryHelper.cs | 60 +++++++++++ .../Helper/FileCopyHelper.cs | 53 +++++++++ .../Helper/GetBuildInformationHelper.cs | 38 +++++++ src/MeoAssistantBuilder/MaaBuildContext.cs | 28 +++++ .../MeoAssistantBuilder.csproj | 17 +++ src/MeoAssistantBuilder/Program.cs | 15 +++ src/MeoAssistantBuilder/README.md | 23 ++++ src/MeoAssistantBuilder/Tasks/DevBuildTask.cs | 78 ++++++++++++++ .../Tasks/ReleaseCoreTask.cs | 102 ++++++++++++++++++ .../Tasks/ReleaseResourceTask.cs | 58 ++++++++++ .../Tasks/ReleaseWpfTask.cs | 61 +++++++++++ 14 files changed, 591 insertions(+) create mode 100644 src/MeoAssistantBuilder/Constants.cs create mode 100644 src/MeoAssistantBuilder/Helper/BuildCoreHelper.cs create mode 100644 src/MeoAssistantBuilder/Helper/BuildWpfHelper.cs create mode 100644 src/MeoAssistantBuilder/Helper/CleanDirectoryHelper.cs create mode 100644 src/MeoAssistantBuilder/Helper/FileCopyHelper.cs create mode 100644 src/MeoAssistantBuilder/Helper/GetBuildInformationHelper.cs create mode 100644 src/MeoAssistantBuilder/MaaBuildContext.cs create mode 100644 src/MeoAssistantBuilder/MeoAssistantBuilder.csproj create mode 100644 src/MeoAssistantBuilder/Program.cs create mode 100644 src/MeoAssistantBuilder/README.md create mode 100644 src/MeoAssistantBuilder/Tasks/DevBuildTask.cs create mode 100644 src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs create mode 100644 src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs create mode 100644 src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs diff --git a/src/MeoAssistantBuilder/Constants.cs b/src/MeoAssistantBuilder/Constants.cs new file mode 100644 index 0000000000..7b67b1daf4 --- /dev/null +++ b/src/MeoAssistantBuilder/Constants.cs @@ -0,0 +1,23 @@ +namespace MeoAssistantBuilder; + +public static class Constants +{ + public const string MaaProjectRootDirectory = "../../"; + public const string MaaProjectThirdPartyDirectory = "../../3rdparty"; + public const string MaaProjectResourceDirectory = "../../resource"; + public const string MaaProjectArtifactDirectory = "../../artifacts"; + + public const string MaaCoreProjectDirectory = "../MeoAssistant"; + public const string MaaWpfProjectDirectory = "../MeoAsstGui"; + + public const string MaaCoreProjectFilePath = $"{MaaCoreProjectDirectory}/MeoAssistant.vcxproj"; + public const string MaaWpfProjectFilePath = $"{MaaWpfProjectDirectory}/MeoAsstGui.csproj"; + + public const string MaaBuildOutputDirectory = $"{MaaProjectRootDirectory}/x64"; + + public const string MaaCoreBuildIntermediatOutputDirectory = $"{MaaCoreProjectDirectory}/x64"; + + public static readonly string[] MaaCoreExtraFiles = new [] { "MeoAssistant.pdb", "MeoAssistant.lib", "MeoAssistant.exp" }; + + public static readonly string[] MaaWpfExtraFiles = new[] { "MeoAsstGui.pdb", "MeoAsstGui.exe.config" }; +} diff --git a/src/MeoAssistantBuilder/Helper/BuildCoreHelper.cs b/src/MeoAssistantBuilder/Helper/BuildCoreHelper.cs new file mode 100644 index 0000000000..078a94f099 --- /dev/null +++ b/src/MeoAssistantBuilder/Helper/BuildCoreHelper.cs @@ -0,0 +1,17 @@ +using Cake.Common.Tools.MSBuild; + +namespace MeoAssistantBuilder.Helper; + +public static class BuildCoreHelper +{ + public static void BuildCore(this MaaBuildContext context, string configuration) + { + context.MSBuild(Constants.MaaCoreProjectFilePath, new MSBuildSettings + { + WorkingDirectory = Constants.MaaProjectRootDirectory, + ToolPath = context.MsBuildExecutable, + Configuration = configuration, + PlatformTarget = PlatformTarget.x64 + }); + } +} diff --git a/src/MeoAssistantBuilder/Helper/BuildWpfHelper.cs b/src/MeoAssistantBuilder/Helper/BuildWpfHelper.cs new file mode 100644 index 0000000000..d3ed8f052a --- /dev/null +++ b/src/MeoAssistantBuilder/Helper/BuildWpfHelper.cs @@ -0,0 +1,18 @@ +using Cake.Common.Tools.MSBuild; + +namespace MeoAssistantBuilder.Helper; + +public static class BuildWpfHelper +{ + public static void BuildWpf(this MaaBuildContext context, string configuration) + { + context.MSBuild(Constants.MaaWpfProjectFilePath, new MSBuildSettings + { + WorkingDirectory = Constants.MaaProjectRootDirectory, + Restore = true, + ToolPath = context.MsBuildExecutable, + Configuration = configuration, + PlatformTarget = PlatformTarget.x64 + }); + } +} diff --git a/src/MeoAssistantBuilder/Helper/CleanDirectoryHelper.cs b/src/MeoAssistantBuilder/Helper/CleanDirectoryHelper.cs new file mode 100644 index 0000000000..44611e9631 --- /dev/null +++ b/src/MeoAssistantBuilder/Helper/CleanDirectoryHelper.cs @@ -0,0 +1,60 @@ +using Cake.Common.Diagnostics; +using Cake.Common.IO; + +namespace MeoAssistantBuilder.Helper; +public static class CleanDirectoryHelper +{ + public static void CleanArtifacts(this MaaBuildContext context) + { + context.CleanDirectory(Constants.MaaProjectArtifactDirectory); + if (Directory.Exists(Constants.MaaProjectArtifactDirectory)) + { + Directory.CreateDirectory(Constants.MaaProjectArtifactDirectory); + } + } + + public static void CleanCore(this MaaBuildContext context) + { + context.CleanDirectory(Constants.MaaBuildOutputDirectory); + context.CleanDirectory(Constants.MaaCoreBuildIntermediatOutputDirectory); + } + + public static void CleanWpf(this MaaBuildContext context) + { + context.CleanDirectory(Constants.MaaBuildOutputDirectory); + context.CleanDirectory(Path.Combine(Constants.MaaWpfProjectDirectory, "bin")); + context.CleanDirectory(Path.Combine(Constants.MaaWpfProjectDirectory, "obj")); + } + + public static void CleanAll(this MaaBuildContext context) + { + CleanCore(context); + CleanWpf(context); + } + + public static void RemoveExtraCore(this MaaBuildContext context, string buildOutput) + { + foreach (var extra in Constants.MaaCoreExtraFiles) + { + var file = Path.Combine(buildOutput, extra); + if (File.Exists(file)) + { + File.Delete(file); + context.Information($"Delete file: {file}"); + } + } + } + + public static void RemoveExtraWpf(this MaaBuildContext context, string buildOutput) + { + foreach (var extra in Constants.MaaWpfExtraFiles) + { + var file = Path.Combine(buildOutput, extra); + if (File.Exists(file)) + { + File.Delete(file); + context.Information($"Delete file: {file}"); + } + } + } +} diff --git a/src/MeoAssistantBuilder/Helper/FileCopyHelper.cs b/src/MeoAssistantBuilder/Helper/FileCopyHelper.cs new file mode 100644 index 0000000000..be2e4dcd73 --- /dev/null +++ b/src/MeoAssistantBuilder/Helper/FileCopyHelper.cs @@ -0,0 +1,53 @@ +using Cake.Common.Diagnostics; +using Cake.Common.IO; + +namespace MeoAssistantBuilder.Helper +{ + public static class FileCopyHelper + { + public static void CopyThirdPartyDlls(this MaaBuildContext context, string outputDir) + { + var thirdPartyDlls = Directory.GetFiles(Path.Combine(Constants.MaaProjectThirdPartyDirectory, "bin")); + foreach (var f in thirdPartyDlls) + { + var fileName = new FileInfo(f).Name; + context.CopyFile(f, Path.Combine(outputDir, fileName)); + context.Information($"Copy file: FROM {f} to {Path.Combine(outputDir, fileName)}"); + } + } + + public static void CopyResources(this MaaBuildContext context, string outputDir) + { + var resourceTargetDir = Path.Combine(outputDir, "resource"); + var resourceThirdParty = Path.Combine(Constants.MaaProjectRootDirectory, "3rdparty\\resource"); + var resoutceMaa = Path.Combine(Constants.MaaProjectRootDirectory, "resource"); + + var files = new List(); + var directories = new List(); + + files.AddRange(Directory.GetFiles(resourceThirdParty)); + files.AddRange(Directory.GetFiles(resoutceMaa)); + directories.AddRange(Directory.GetDirectories(resourceThirdParty)); + directories.AddRange(Directory.GetDirectories(resoutceMaa)); + + if (Directory.Exists(resourceTargetDir) is false) + { + Directory.CreateDirectory(resourceTargetDir); + } + + foreach (var f in files) + { + var fileName = new FileInfo(f).Name; + context.CopyFile(f, Path.Combine(resourceTargetDir, fileName)); + context.Information($"Copy file: FROM {f} TO {Path.Combine(resourceTargetDir, fileName)}"); + } + + foreach (var d in directories) + { + var dirName = new DirectoryInfo(d).Name; + context.CopyDirectory(d, Path.Combine(resourceTargetDir, dirName)); + context.Information($"Copy directory: FROM {d} TO {Path.Combine(resourceTargetDir, dirName)}"); + } + } + } +} diff --git a/src/MeoAssistantBuilder/Helper/GetBuildInformationHelper.cs b/src/MeoAssistantBuilder/Helper/GetBuildInformationHelper.cs new file mode 100644 index 0000000000..ac87a4c998 --- /dev/null +++ b/src/MeoAssistantBuilder/Helper/GetBuildInformationHelper.cs @@ -0,0 +1,38 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; + +namespace MeoAssistantBuilder.Helper; + +public static class GetBuildInformationHelper +{ + public static (string, string) GetBuildInformation(this MaaBuildContext context) + { + var ghAction = context.GitHubActions(); + + var buildTime = DateTime.UtcNow.AddHours(8); + var bt = buildTime.ToString("yyyy-MM-dd-HH-mm-ss"); + string hash; + + if (ghAction.IsRunningOnGitHubActions) + { + hash = ghAction.Environment.Workflow.Sha.ToLower()[..7]; + } + else + { + try + { + var realPath = new DirectoryInfo(Constants.MaaProjectRootDirectory).FullName; + var repo = new LibGit2Sharp.Repository(realPath); + var commit = repo.Commits.First(); + hash = commit.Sha.ToLower()[..7]; + } + catch (Exception e) + { + context.Warning($"Failed to get git log: {e.Message}"); + hash = "Unknown"; + } + } + + return (bt, hash); + } +} diff --git a/src/MeoAssistantBuilder/MaaBuildContext.cs b/src/MeoAssistantBuilder/MaaBuildContext.cs new file mode 100644 index 0000000000..01044eed84 --- /dev/null +++ b/src/MeoAssistantBuilder/MaaBuildContext.cs @@ -0,0 +1,28 @@ +using Cake.Common; +using Cake.Common.Tools.VSWhere; +using Cake.Core; +using Cake.Core.Diagnostics; +using Cake.Frosting; + +namespace MeoAssistantBuilder; + +public class MaaBuildContext : FrostingContext +{ + public string MsBuildExecutable { get; set; } + + public MaaBuildContext(ICakeContext context) : base(context) + { + MsBuildExecutable = context.Argument("tool", ""); + if (MsBuildExecutable == "") + { + var vsPath = context.VSWhereLatest(); + if (vsPath == null) + { + context.Log.Write(Verbosity.Normal, LogLevel.Fatal, "Can not find Visual Studio install path"); + System.Environment.Exit(-1); + } + MsBuildExecutable = Path.Combine(vsPath.FullPath, "Msbuild\\Current\\Bin\\MsBuild.exe"); + } + context.Log.Information($"Use MsBuild at: {MsBuildExecutable}"); + } +} diff --git a/src/MeoAssistantBuilder/MeoAssistantBuilder.csproj b/src/MeoAssistantBuilder/MeoAssistantBuilder.csproj new file mode 100644 index 0000000000..c8d02f6130 --- /dev/null +++ b/src/MeoAssistantBuilder/MeoAssistantBuilder.csproj @@ -0,0 +1,17 @@ + + + + Exe + net6.0 + enable + disable + x64 + Debug;Release;CICD + + + + + + + + diff --git a/src/MeoAssistantBuilder/Program.cs b/src/MeoAssistantBuilder/Program.cs new file mode 100644 index 0000000000..c14c37d4ef --- /dev/null +++ b/src/MeoAssistantBuilder/Program.cs @@ -0,0 +1,15 @@ +using Cake.Frosting; +using MeoAssistantBuilder; + +var sArgs = new List(); +foreach (var arg in args) +{ + var sa = arg.Split(" ") + .ToList(); + sa.RemoveAll(x => string.IsNullOrEmpty(x) || string.IsNullOrWhiteSpace(x)); + sArgs.AddRange(sa); +} + +return new CakeHost() + .UseContext() + .Run(sArgs); diff --git a/src/MeoAssistantBuilder/README.md b/src/MeoAssistantBuilder/README.md new file mode 100644 index 0000000000..c4288f5cd3 --- /dev/null +++ b/src/MeoAssistantBuilder/README.md @@ -0,0 +1,23 @@ +# MeoAssistantBuilder + +MAA 构建项目 + +## 构建 MAA + +需要安装 +- `.NET SDK 6.0` +- `.NET Framework SDK 4.8` +- `MSVC v143 x64` +- `MSBuild (VS2022)` + +在本项目根目录执行 +``` +dotnet run -- --target +``` + +TARGET 可选项 + +- `DevBuild` +- `ReleaseCore` +- `ReleaseWpf` +- `ReleaseResource` diff --git a/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs new file mode 100644 index 0000000000..fd5ae6ea8a --- /dev/null +++ b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs @@ -0,0 +1,78 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using MeoAssistantBuilder.Helper; +using System.IO.Compression; + +namespace MeoAssistantBuilder.Tasks; + +[TaskName("DevBuild")] +public sealed class DevBuildTask : FrostingTask +{ + public override void Run(MaaBuildContext context) + { + context.Information("--------------------------------------------------"); + context.Information("1. Get build information"); + context.Information("--------------------------------------------------"); + + context.CleanArtifacts(); + var (bt, hash) = context.GetBuildInformation(); + var artifact = $"MaaFull-DevBuild-(CONF)-{hash}-{bt}.zip"; + context.Information($"Dev build of commit {hash} at {bt}"); + + context.Information("--------------------------------------------------"); + context.Information("2. Build MaaFull with configuration Release"); + context.Information("--------------------------------------------------"); + + context.CleanAll(); + + context.BuildCore("Release"); + context.BuildWpf("Release"); + var releaseOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "Release"); + var releaseArtifact = Path.Combine(Constants.MaaProjectArtifactDirectory, artifact.Replace("(CONF)", "Release")); + ZipFile.CreateFromDirectory(releaseOutput, releaseArtifact); + + context.Information("--------------------------------------------------"); + context.Information("3. Build MaaFull with configuration RelWithDebInfo"); + context.Information("--------------------------------------------------"); + + context.CleanAll(); + + context.BuildCore("RelWithDebInfo"); + context.BuildWpf("RelWithDebInfo"); + var releaseDebugOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "RelWithDebInfo"); + var releaseDebugArtifact = Path.Combine(Constants.MaaProjectArtifactDirectory, artifact.Replace("(CONF)", "RelWithDebInfo")); + ZipFile.CreateFromDirectory(releaseDebugOutput, releaseDebugArtifact); + + context.Information("--------------------------------------------------"); + context.Information("4. Build MaaFull with configuration CICD"); + context.Information("--------------------------------------------------"); + + context.CleanAll(); + + context.BuildCore("CICD"); + context.BuildWpf("CICD"); + var releaseCiOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "CICD"); + var releaseCiArtifact = Path.Combine(Constants.MaaProjectArtifactDirectory, artifact.Replace("(CONF)", "CICD")); + context.CopyThirdPartyDlls(releaseCiOutput); + context.CopyResources(releaseCiOutput); + ZipFile.CreateFromDirectory(releaseCiOutput, releaseCiArtifact); + + context.Information("--------------------------------------------------"); + context.Information("5. Upload Artifacts"); + context.Information("--------------------------------------------------"); + + var gh = context.GitHubActions(); + if (gh.IsRunningOnGitHubActions) + { + context.Information("Upload artifacts to GitHub Actions"); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseArtifact), artifact.Replace("(CONF)", "Release")).Wait(); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseDebugArtifact), artifact.Replace("(CONF)", "RelWithDebInfo")).Wait(); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseCiArtifact), artifact.Replace("(CONF)", "CICD")).Wait(); + } + else + { + context.Information("Skip"); + } + } +} diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs new file mode 100644 index 0000000000..f2e39cb757 --- /dev/null +++ b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs @@ -0,0 +1,102 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using MeoAssistantBuilder.Helper; +using System.IO.Compression; +using System.Text.RegularExpressions; + +namespace MeoAssistantBuilder.Tasks; + +[TaskName("ReleaseCore")] +public sealed class ReleaseCoreTask : FrostingTask +{ + public override void Run(MaaBuildContext context) + { + context.Information("--------------------------------------------------"); + context.Information("1. Build MaaCore with CICD configuration"); + context.Information("--------------------------------------------------"); + + context.CleanCore(); + context.CleanArtifacts(); + context.BuildCore("CICD"); + + context.Information("--------------------------------------------------"); + context.Information("2. Remove extra files from build output"); + context.Information("--------------------------------------------------"); + + var buildOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "CICD"); + context.RemoveExtraCore(buildOutput); + + context.Information("--------------------------------------------------"); + context.Information("3. Copy 3rd party library DLLs to output directory"); + context.Information("--------------------------------------------------"); + + var thirdPartyDlls = Directory.GetFiles(Path.Combine(Constants.MaaProjectThirdPartyDirectory, "bin")); + foreach(var f in thirdPartyDlls) + { + var fileName = new FileInfo(f).Name; + File.Copy(f, Path.Combine(buildOutput, fileName)); + context.Information($"Copy file: FROM {f} to {Path.Combine(buildOutput, fileName)}"); + } + + context.Information("--------------------------------------------------"); + context.Information("4. Read MaaCore version string"); + context.Information("--------------------------------------------------"); + + var version = "UNKNOWN"; + var versionFile = Path.Combine(Constants.MaaCoreProjectDirectory, "Version.h"); + var versionFileContent = File.ReadAllText(versionFile); + + var regex = @"v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)"; + + var match = Regex.Match(versionFileContent, regex); + if (match.Success is false) + { + context.Warning("Can not read version"); + Environment.Exit(-1); + } + else + { + version = match.Value; + } + + var ghActions = context.GitHubActions(); + if (ghActions.IsRunningOnGitHubActions is false) + { + version += "-Local"; + } + else + { + if (ghActions.Environment.Workflow.Workflow != "Release MaaCore") + { + version += $"-{ghActions.Environment.Workflow.RunId}"; + } + } + + context.Information($"MaaCore Version: {version}"); + + context.Information("--------------------------------------------------"); + context.Information("5. Bundle MaaCore DLLs"); + context.Information("--------------------------------------------------"); + + var bundle = Path.Combine(Constants.MaaProjectArtifactDirectory, $"MaaCore-{version}.zip"); + ZipFile.CreateFromDirectory(buildOutput, bundle); + + context.Information($"Bundled MAACore DLLs file: {bundle}"); + + context.Information("--------------------------------------------------"); + context.Information("6. Upload Artifact"); + context.Information("--------------------------------------------------"); + + var gh = context.GitHubActions(); + if (gh.IsRunningOnGitHubActions) + { + context.Information("Upload artifacts to GitHub Actions"); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaCore-{version}.zip").Wait(); + } + else + { + context.Information("Skip"); + } + } +} diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs new file mode 100644 index 0000000000..e73b1cd893 --- /dev/null +++ b/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs @@ -0,0 +1,58 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using MeoAssistantBuilder.Helper; +using System.IO.Compression; + +namespace MeoAssistantBuilder.Tasks; + +[TaskName("ReleaseResource")] +public sealed class ReleaseResourceTask : FrostingTask +{ + public override void Run(MaaBuildContext context) + { + context.Information("--------------------------------------------------"); + context.Information("1. Get bundle information"); + context.Information("--------------------------------------------------"); + + var (hash, bt) = context.GetBuildInformation(); + context.CleanArtifacts(); + var version = $"{hash}-{bt}"; + context.Information($"MaaResource Version: {version}"); + + context.Information("--------------------------------------------------"); + context.Information("2. Copy MaaResource"); + context.Information("--------------------------------------------------"); + + var resDir = Path.Combine(Constants.MaaBuildOutputDirectory, "resource"); + if (Directory.Exists(resDir) is false) + { + Directory.CreateDirectory(resDir); + } + context.CopyResources(resDir); + + context.Information("--------------------------------------------------"); + context.Information("3. Bundle MaaResource"); + context.Information("--------------------------------------------------"); + + var bundle = Path.Combine(Constants.MaaProjectArtifactDirectory, $"MaaResource-{version}.zip"); + ZipFile.CreateFromDirectory(resDir, bundle); + + context.Information($"Bundled MaaResource file: {bundle}"); + + context.Information("--------------------------------------------------"); + context.Information("4. Upload Artifact"); + context.Information("--------------------------------------------------"); + + var gh = context.GitHubActions(); + if (gh.IsRunningOnGitHubActions) + { + context.Information("Upload artifacts to GitHub Actions"); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaResource-{version}.zip").Wait(); + } + else + { + context.Information("Skip"); + } + } +} diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs new file mode 100644 index 0000000000..681bc85f3a --- /dev/null +++ b/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs @@ -0,0 +1,61 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using MeoAssistantBuilder.Helper; +using System.IO.Compression; + +namespace MeoAssistantBuilder.Tasks; + +[TaskName("ReleaseWpf")] +public sealed class ReleaseWpfTask : FrostingTask +{ + public override void Run(MaaBuildContext context) + { + context.Information("--------------------------------------------------"); + context.Information("1. Build MaaWpf with ReleaseCore configuration"); + context.Information("--------------------------------------------------"); + + var (hash, bt) = context.GetBuildInformation(); + context.CleanWpf(); + context.CleanArtifacts(); + context.BuildWpf("CICD"); + + context.Information("--------------------------------------------------"); + context.Information("2. Remove extra files from build output"); + context.Information("--------------------------------------------------"); + + var buildOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "CICD"); + context.RemoveExtraWpf(buildOutput); + + context.Information("--------------------------------------------------"); + context.Information("3. Set MaaWpf Version Number"); + context.Information("--------------------------------------------------"); + + var version = $"{hash}-{bt}"; + context.Information($"MaaWpf Version: {version}"); + + context.Information("--------------------------------------------------"); + context.Information("4. Bundle MaaWpf Executables"); + context.Information("--------------------------------------------------"); + + var bundle = Path.Combine(Constants.MaaProjectArtifactDirectory, $"MaaWpf-{version}.zip"); + ZipFile.CreateFromDirectory(buildOutput, bundle); + + context.Information($"Bundled MaaWpf Executables file: {bundle}"); + + context.Information("--------------------------------------------------"); + context.Information("5. Upload Artifact"); + context.Information("--------------------------------------------------"); + + var gh = context.GitHubActions(); + if (gh.IsRunningOnGitHubActions) + { + context.Information("Upload artifacts to GitHub Actions"); + gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaWpf-{version}.zip").Wait(); + } + else + { + context.Information("Skip"); + } + } +} From b21f9e54f5a0ed987b10079d9b5c59435a0464c3 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 13:06:12 +0800 Subject: [PATCH 04/17] =?UTF-8?q?ci.=E6=B7=BB=E5=8A=A0=20DevBuild=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/maa-dev-build.yaml diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml new file mode 100644 index 0000000000..9b3964d354 --- /dev/null +++ b/.github/workflows/maa-dev-build.yaml @@ -0,0 +1,21 @@ +name: "Maa Dev Build" + +on: + push: + pull_request: + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Goto MeoAssistantBuilder source directory + run: cd ./src/MeoAssistantBuilder + - name: Run dev build task + run: dotnet run -- --target DevBuild From 3024082dff01293a60a9c3db65a1717d0b3f15af Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 13:12:41 +0800 Subject: [PATCH 05/17] =?UTF-8?q?ci.=E4=BF=AE=20Ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 9 +++++---- ci-dev-build.ps1 | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 ci-dev-build.ps1 diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index 9b3964d354..f2197e2e3a 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -10,12 +10,13 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Setup .NET 6.0.x uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x - - name: Goto MeoAssistantBuilder source directory - run: cd ./src/MeoAssistantBuilder + - name: Run dev build task - run: dotnet run -- --target DevBuild + run: pwsh .\ci-dev-build.ps1 diff --git a/ci-dev-build.ps1 b/ci-dev-build.ps1 new file mode 100644 index 0000000000..ffb7496e54 --- /dev/null +++ b/ci-dev-build.ps1 @@ -0,0 +1,2 @@ +Set-Location .\src\MeoAssistantBuilder +dotnet run -- --target DevBuild From 0e5914439000c49e59c8fdf3a3b836bfdc1cafb8 Mon Sep 17 00:00:00 2001 From: Alisa Date: Mon, 9 May 2022 13:45:00 +0800 Subject: [PATCH 06/17] =?UTF-8?q?ci.=E4=BF=AE=E5=A4=8D=20CI=20=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=20Artifact=20=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index f2197e2e3a..057782f93a 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -20,3 +20,5 @@ jobs: - name: Run dev build task run: pwsh .\ci-dev-build.ps1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 36df5262813b0d15e1bed25adfd893a75a5e204f Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 14:04:11 +0800 Subject: [PATCH 07/17] =?UTF-8?q?ci.=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20GitHub=20Action=20=E7=9A=84=20Upload=20Artifacts=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 8 ++++++-- src/MeoAssistantBuilder/Tasks/DevBuildTask.cs | 17 ----------------- .../Tasks/ReleaseCoreTask.cs | 15 --------------- .../Tasks/ReleaseResourceTask.cs | 15 --------------- src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs | 15 --------------- 5 files changed, 6 insertions(+), 64 deletions(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index 057782f93a..63fb758d0d 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -20,5 +20,9 @@ jobs: - name: Run dev build task run: pwsh .\ci-dev-build.ps1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: Dev Build Bundles + path: ./artifacts diff --git a/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs index fd5ae6ea8a..0f8d93616b 100644 --- a/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs +++ b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs @@ -57,22 +57,5 @@ public sealed class DevBuildTask : FrostingTask context.CopyThirdPartyDlls(releaseCiOutput); context.CopyResources(releaseCiOutput); ZipFile.CreateFromDirectory(releaseCiOutput, releaseCiArtifact); - - context.Information("--------------------------------------------------"); - context.Information("5. Upload Artifacts"); - context.Information("--------------------------------------------------"); - - var gh = context.GitHubActions(); - if (gh.IsRunningOnGitHubActions) - { - context.Information("Upload artifacts to GitHub Actions"); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseArtifact), artifact.Replace("(CONF)", "Release")).Wait(); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseDebugArtifact), artifact.Replace("(CONF)", "RelWithDebInfo")).Wait(); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(releaseCiArtifact), artifact.Replace("(CONF)", "CICD")).Wait(); - } - else - { - context.Information("Skip"); - } } } diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs index f2e39cb757..27d2f0df99 100644 --- a/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs +++ b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs @@ -83,20 +83,5 @@ public sealed class ReleaseCoreTask : FrostingTask ZipFile.CreateFromDirectory(buildOutput, bundle); context.Information($"Bundled MAACore DLLs file: {bundle}"); - - context.Information("--------------------------------------------------"); - context.Information("6. Upload Artifact"); - context.Information("--------------------------------------------------"); - - var gh = context.GitHubActions(); - if (gh.IsRunningOnGitHubActions) - { - context.Information("Upload artifacts to GitHub Actions"); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaCore-{version}.zip").Wait(); - } - else - { - context.Information("Skip"); - } } } diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs index e73b1cd893..de89df2d60 100644 --- a/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs +++ b/src/MeoAssistantBuilder/Tasks/ReleaseResourceTask.cs @@ -39,20 +39,5 @@ public sealed class ReleaseResourceTask : FrostingTask ZipFile.CreateFromDirectory(resDir, bundle); context.Information($"Bundled MaaResource file: {bundle}"); - - context.Information("--------------------------------------------------"); - context.Information("4. Upload Artifact"); - context.Information("--------------------------------------------------"); - - var gh = context.GitHubActions(); - if (gh.IsRunningOnGitHubActions) - { - context.Information("Upload artifacts to GitHub Actions"); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaResource-{version}.zip").Wait(); - } - else - { - context.Information("Skip"); - } } } diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs index 681bc85f3a..43b7ceb0b9 100644 --- a/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs +++ b/src/MeoAssistantBuilder/Tasks/ReleaseWpfTask.cs @@ -42,20 +42,5 @@ public sealed class ReleaseWpfTask : FrostingTask ZipFile.CreateFromDirectory(buildOutput, bundle); context.Information($"Bundled MaaWpf Executables file: {bundle}"); - - context.Information("--------------------------------------------------"); - context.Information("5. Upload Artifact"); - context.Information("--------------------------------------------------"); - - var gh = context.GitHubActions(); - if (gh.IsRunningOnGitHubActions) - { - context.Information("Upload artifacts to GitHub Actions"); - gh.Commands.UploadArtifact(Cake.Core.IO.FilePath.FromString(bundle), $"MaaWpf-{version}.zip").Wait(); - } - else - { - context.Information("Skip"); - } } } From 1c4832b61b6f05f5ee6d0c877962c4a4620f074d Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 14:27:22 +0800 Subject: [PATCH 08/17] =?UTF-8?q?ci.=E5=88=86=E5=BC=80=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=9A=84=20Artifacts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index 63fb758d0d..b5564ab2c3 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -21,8 +21,20 @@ jobs: - name: Run dev build task run: pwsh .\ci-dev-build.ps1 - - name: Upload Artifacts + - name: Upload Artifacts Release uses: actions/upload-artifact@v3 with: - name: Dev Build Bundles - path: ./artifacts + name: MaaFull-DevBuild-Release + path: ./artifacts/MaaFull-DevBuild-Release* + + - name: Upload Artifacts RelWithDebInfo + uses: actions/upload-artifact@v3 + with: + name: MaaFull-DevBuild-RelWithDebInfo + path: ./artifacts/MaaFull-DevBuild-RelWithDebInfo* + + - name: Upload Artifacts CICD + uses: actions/upload-artifact@v3 + with: + name: MaaFull-DevBuild-CICD + path: ./artifacts/MaaFull-DevBuild-CICD* From bcd749f1f7fb1d83ba60dc027ff73534cac7221d Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 15:58:57 +0800 Subject: [PATCH 09/17] =?UTF-8?q?ci.=E4=BC=98=E5=8C=96=20DevBuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 5 +---- build.ps1 | 16 ++++++++++++++++ ci-dev-build.ps1 | 2 -- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 build.ps1 delete mode 100644 ci-dev-build.ps1 diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index b5564ab2c3..30169a7971 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -19,22 +19,19 @@ jobs: dotnet-version: 6.0.x - name: Run dev build task - run: pwsh .\ci-dev-build.ps1 + run: pwsh .\build.ps1 DevBuild - name: Upload Artifacts Release uses: actions/upload-artifact@v3 with: - name: MaaFull-DevBuild-Release path: ./artifacts/MaaFull-DevBuild-Release* - name: Upload Artifacts RelWithDebInfo uses: actions/upload-artifact@v3 with: - name: MaaFull-DevBuild-RelWithDebInfo path: ./artifacts/MaaFull-DevBuild-RelWithDebInfo* - name: Upload Artifacts CICD uses: actions/upload-artifact@v3 with: - name: MaaFull-DevBuild-CICD path: ./artifacts/MaaFull-DevBuild-CICD* diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..c3b9466100 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,16 @@ +if ($args.Length -ne 1) { + throw "One argument required" +} + +$target = $args[0] +$valid_targets = @("ReleaseCore", "ReleaseWpf", "ReleaseResource", "DevBuild") + +if (!$valid_targets.Contains($target)) { + throw "$target is not a valid target" +} + +Set-Location -Path .\src\MeoAssistantBuilder + +dotnet run -- --target $target + +Set-Location -Path ..\..\ diff --git a/ci-dev-build.ps1 b/ci-dev-build.ps1 deleted file mode 100644 index ffb7496e54..0000000000 --- a/ci-dev-build.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -Set-Location .\src\MeoAssistantBuilder -dotnet run -- --target DevBuild From 400fc9df8f66060845a4fcb5aa25142422e2c8f5 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 16:51:24 +0800 Subject: [PATCH 10/17] =?UTF-8?q?ci.=E6=B7=BB=E5=8A=A0=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 6 +++ .github/workflows/maa-doc-azure-deploy.yaml | 60 ++++++++++----------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index 30169a7971..fa58c41fb0 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -2,7 +2,10 @@ name: "Maa Dev Build" on: push: + branches: + - master pull_request: + workflow_dispatch: jobs: build: @@ -24,14 +27,17 @@ jobs: - name: Upload Artifacts Release uses: actions/upload-artifact@v3 with: + name: MaaFull-DevBuild-Release path: ./artifacts/MaaFull-DevBuild-Release* - name: Upload Artifacts RelWithDebInfo uses: actions/upload-artifact@v3 with: + name: MaaFull-DevBuild-RelWithDebInfo path: ./artifacts/MaaFull-DevBuild-RelWithDebInfo* - name: Upload Artifacts CICD uses: actions/upload-artifact@v3 with: + name: MaaFull-DevBuild-CICD path: ./artifacts/MaaFull-DevBuild-CICD* diff --git a/.github/workflows/maa-doc-azure-deploy.yaml b/.github/workflows/maa-doc-azure-deploy.yaml index f71103aa47..83b47e6832 100644 --- a/.github/workflows/maa-doc-azure-deploy.yaml +++ b/.github/workflows/maa-doc-azure-deploy.yaml @@ -1,30 +1,30 @@ -name: Azure Static Web Apps CI/CD - -on: - push: - branches: - - master - paths: - - "docs/*" - -jobs: - build_and_deploy: - runs-on: ubuntu-latest - name: Build and Deploy Job - if: github.repository_owner == 'MaaAssistantArknights' - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_DESERT_00290F400 }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/docs" # App source code path - api_location: "" # Api source code path - optional - output_location: ".vuepress/dist" # Built app content directory - optional +name: Deploy Docs + +on: + push: + branches: + - master + paths: + - "docs/*" + workflow_dispatch: + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_DESERT_00290F400 }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/docs" # App source code path + api_location: "" # Api source code path - optional + output_location: ".vuepress/dist" # Built app content directory - optional From 315d37b411a2abadb4e3ad211dcfbfb15f02099c Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 17:20:36 +0800 Subject: [PATCH 11/17] =?UTF-8?q?ci.=E6=B7=BB=E5=8A=A0=20ReleaseCore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-release-core.yaml | 44 +++++++++++++ .../Tasks/ReleaseCoreTask.cs | 66 +++++++++++-------- 2 files changed, 82 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/maa-release-core.yaml diff --git a/.github/workflows/maa-release-core.yaml b/.github/workflows/maa-release-core.yaml new file mode 100644 index 0000000000..d17e2061c6 --- /dev/null +++ b/.github/workflows/maa-release-core.yaml @@ -0,0 +1,44 @@ +name: Release MaaCore + +on: + release: + types: + - published + +jobs: + + release-core: + + runs-on: windows-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Run release core task + run: pwsh .\build.ps1 ReleaseCore + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: MaaCore-${{ steps.tag.outputs.tag }} + path: ./artifacts/MaaCore* + + - name: Upload release assets + uses: xresloader/upload-to-github-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: ./artifacts/MaaCore* + tags: true + verbose: true diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs index 27d2f0df99..8a2131b5e4 100644 --- a/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs +++ b/src/MeoAssistantBuilder/Tasks/ReleaseCoreTask.cs @@ -13,34 +13,7 @@ public sealed class ReleaseCoreTask : FrostingTask public override void Run(MaaBuildContext context) { context.Information("--------------------------------------------------"); - context.Information("1. Build MaaCore with CICD configuration"); - context.Information("--------------------------------------------------"); - - context.CleanCore(); - context.CleanArtifacts(); - context.BuildCore("CICD"); - - context.Information("--------------------------------------------------"); - context.Information("2. Remove extra files from build output"); - context.Information("--------------------------------------------------"); - - var buildOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "CICD"); - context.RemoveExtraCore(buildOutput); - - context.Information("--------------------------------------------------"); - context.Information("3. Copy 3rd party library DLLs to output directory"); - context.Information("--------------------------------------------------"); - - var thirdPartyDlls = Directory.GetFiles(Path.Combine(Constants.MaaProjectThirdPartyDirectory, "bin")); - foreach(var f in thirdPartyDlls) - { - var fileName = new FileInfo(f).Name; - File.Copy(f, Path.Combine(buildOutput, fileName)); - context.Information($"Copy file: FROM {f} to {Path.Combine(buildOutput, fileName)}"); - } - - context.Information("--------------------------------------------------"); - context.Information("4. Read MaaCore version string"); + context.Information("1. Read MaaCore version string"); context.Information("--------------------------------------------------"); var version = "UNKNOWN"; @@ -67,14 +40,51 @@ public sealed class ReleaseCoreTask : FrostingTask } else { + context.Information($"Running in GitHub Action with workflow name: {ghActions.Environment.Workflow.Workflow}, ref: {ghActions.Environment.Workflow.Ref}"); if (ghActions.Environment.Workflow.Workflow != "Release MaaCore") { version += $"-{ghActions.Environment.Workflow.RunId}"; } + else + { + var tag = ghActions.Environment.Workflow.Ref.Replace("refs/tags/", ""); + if (tag != version) + { + context.Error($"Version do not match. From File: {version}. From Ref: {tag}"); + Environment.Exit(-1); + } + } } context.Information($"MaaCore Version: {version}"); + context.Information("--------------------------------------------------"); + context.Information("2. Build MaaCore with CICD configuration"); + context.Information("--------------------------------------------------"); + + context.CleanCore(); + context.CleanArtifacts(); + context.BuildCore("CICD"); + + context.Information("--------------------------------------------------"); + context.Information("3. Remove extra files from build output"); + context.Information("--------------------------------------------------"); + + var buildOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "CICD"); + context.RemoveExtraCore(buildOutput); + + context.Information("--------------------------------------------------"); + context.Information("4. Copy 3rd party library DLLs to output directory"); + context.Information("--------------------------------------------------"); + + var thirdPartyDlls = Directory.GetFiles(Path.Combine(Constants.MaaProjectThirdPartyDirectory, "bin")); + foreach(var f in thirdPartyDlls) + { + var fileName = new FileInfo(f).Name; + File.Copy(f, Path.Combine(buildOutput, fileName)); + context.Information($"Copy file: FROM {f} to {Path.Combine(buildOutput, fileName)}"); + } + context.Information("--------------------------------------------------"); context.Information("5. Bundle MaaCore DLLs"); context.Information("--------------------------------------------------"); From 3d1209564b879365c6b755ece3438633afe631e5 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 18:21:57 +0800 Subject: [PATCH 12/17] =?UTF-8?q?ci.=E4=BF=AE=E6=94=B9=20ReleaseCore=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-release-core.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maa-release-core.yaml b/.github/workflows/maa-release-core.yaml index d17e2061c6..c8735c956f 100644 --- a/.github/workflows/maa-release-core.yaml +++ b/.github/workflows/maa-release-core.yaml @@ -41,4 +41,5 @@ jobs: with: file: ./artifacts/MaaCore* tags: true + draft: false verbose: true From 78aa13d25e8a995cf429a237ac3224dbd5102183 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 21:03:40 +0800 Subject: [PATCH 13/17] =?UTF-8?q?ci.=E9=99=90=E5=AE=9A=20DevBuild=20?= =?UTF-8?q?=E7=9A=84=E7=94=9F=E6=95=88=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index fa58c41fb0..124abb8cf9 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -3,8 +3,22 @@ name: "Maa Dev Build" on: push: branches: - - master + - dev + paths: + - src/MeoAssistant/** + - src/MeoAssistantBuilder/** + - src/MeoAsstGui/** + - 3rdparty/** + - include/** + - MeoAssistantArknights.sln pull_request: + paths: + - src/MeoAssistant/** + - src/MeoAssistantBuilder/** + - src/MeoAsstGui/** + - 3rdparty/** + - include/** + - MeoAssistantArknights.sln workflow_dispatch: jobs: From f994e5cef6bb2d38813859072ea96d041785d39d Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 21:48:12 +0800 Subject: [PATCH 14/17] =?UTF-8?q?ci.=E6=B7=BB=E5=8A=A0=20MaaWpf=20?= =?UTF-8?q?=E5=92=8C=20MaaResource=20=E7=9A=84=20Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-release-resource.yaml | 39 +++++++++++++++++++++ .github/workflows/maa-release-wpf.yaml | 38 ++++++++++++++++++++ read_path.ps1 | 16 +++++++++ 3 files changed, 93 insertions(+) create mode 100644 .github/workflows/maa-release-resource.yaml create mode 100644 .github/workflows/maa-release-wpf.yaml create mode 100644 read_path.ps1 diff --git a/.github/workflows/maa-release-resource.yaml b/.github/workflows/maa-release-resource.yaml new file mode 100644 index 0000000000..d68e94c4da --- /dev/null +++ b/.github/workflows/maa-release-resource.yaml @@ -0,0 +1,39 @@ +name: Release MaaResource + +on: + push: + branches: + - master + paths: + - resource/** + - 3rdparty/resource/** + workflow_dispatch: + +jobs: + + release-resource: + + runs-on: windows-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Run release resource task + run: pwsh .\build.ps1 ReleaseResource + + - name: Read file name + id: read_path + run: pwsh .\read_path.ps1 ./artifacts MaaResource* + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.read_path.outputs.name_0 }} + path: ${{ steps.read_path.outputs.path_0 }} diff --git a/.github/workflows/maa-release-wpf.yaml b/.github/workflows/maa-release-wpf.yaml new file mode 100644 index 0000000000..6dadea0963 --- /dev/null +++ b/.github/workflows/maa-release-wpf.yaml @@ -0,0 +1,38 @@ +name: Release MaaWpf + +on: + push: + branches: + - master + paths: + - src/MeoAsstGui/** + workflow_dispatch: + +jobs: + + release-wpf: + + runs-on: windows-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Run release wpf task + run: pwsh .\build.ps1 ReleaseWpf + + - name: Read file name + id: read_path + run: pwsh .\read_path.ps1 ./artifacts MaaWpf* + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.read_path.outputs.name_0 }} + path: ${{ steps.read_path.outputs.path_0 }} diff --git a/read_path.ps1 b/read_path.ps1 new file mode 100644 index 0000000000..6cfb1aaf0e --- /dev/null +++ b/read_path.ps1 @@ -0,0 +1,16 @@ +if ($args.Length -ne 2) { + throw "Need two arguments" +} + +$fs = Get-ChildItem -Path $args[0] -Filter $args[1] + +$index = 0 +foreach($f in $fs) { + + $name = $f.Name + $path = $f.FullName + Write-Output "::set-output name=name_$index::$name" + Write-Output "::set-output name=path_$index::$path" + + $index = $index + 1 +} From 0139745d0247c898e93269ee60728362b01b1097 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 23:49:38 +0800 Subject: [PATCH 15/17] =?UTF-8?q?ci.=20=E9=87=8D=E5=91=BD=E5=90=8D=20Bundl?= =?UTF-8?q?e=20=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 26 +++++++++++-------- src/MeoAssistantBuilder/Tasks/DevBuildTask.cs | 8 +++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index 124abb8cf9..f4e182094f 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -38,20 +38,24 @@ jobs: - name: Run dev build task run: pwsh .\build.ps1 DevBuild - - name: Upload Artifacts Release - uses: actions/upload-artifact@v3 - with: - name: MaaFull-DevBuild-Release - path: ./artifacts/MaaFull-DevBuild-Release* + - name: Read file name + id: read_path + run: pwsh .\read_path.ps1 ./artifacts MaaBundle - - name: Upload Artifacts RelWithDebInfo + - name: Upload Artifacts 0 uses: actions/upload-artifact@v3 with: - name: MaaFull-DevBuild-RelWithDebInfo - path: ./artifacts/MaaFull-DevBuild-RelWithDebInfo* + name: ${{ steps.read_path.outputs.name_0 }} + path: ${{ steps.read_path.outputs.path_0 }} - - name: Upload Artifacts CICD + - name: Upload Artifacts 1 uses: actions/upload-artifact@v3 with: - name: MaaFull-DevBuild-CICD - path: ./artifacts/MaaFull-DevBuild-CICD* + name: ${{ steps.read_path.outputs.name_1 }} + path: ${{ steps.read_path.outputs.path_1 }} + + - name: Upload Artifacts 2 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.read_path.outputs.name_2 }} + path: ${{ steps.read_path.outputs.path_2 }} diff --git a/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs index 0f8d93616b..6b7ce804c7 100644 --- a/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs +++ b/src/MeoAssistantBuilder/Tasks/DevBuildTask.cs @@ -17,11 +17,11 @@ public sealed class DevBuildTask : FrostingTask context.CleanArtifacts(); var (bt, hash) = context.GetBuildInformation(); - var artifact = $"MaaFull-DevBuild-(CONF)-{hash}-{bt}.zip"; + var artifact = $"MaaBundle-DevBuild-(CONF)-{hash}-{bt}.zip"; context.Information($"Dev build of commit {hash} at {bt}"); context.Information("--------------------------------------------------"); - context.Information("2. Build MaaFull with configuration Release"); + context.Information("2. Build MaaBundle with configuration Release"); context.Information("--------------------------------------------------"); context.CleanAll(); @@ -33,7 +33,7 @@ public sealed class DevBuildTask : FrostingTask ZipFile.CreateFromDirectory(releaseOutput, releaseArtifact); context.Information("--------------------------------------------------"); - context.Information("3. Build MaaFull with configuration RelWithDebInfo"); + context.Information("3. Build MaaBundle with configuration RelWithDebInfo"); context.Information("--------------------------------------------------"); context.CleanAll(); @@ -45,7 +45,7 @@ public sealed class DevBuildTask : FrostingTask ZipFile.CreateFromDirectory(releaseDebugOutput, releaseDebugArtifact); context.Information("--------------------------------------------------"); - context.Information("4. Build MaaFull with configuration CICD"); + context.Information("4. Build MaaBundle with configuration CICD"); context.Information("--------------------------------------------------"); context.CleanAll(); From 3f52a6f2f75d15d6edb5bb71a699347c84bfba38 Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Mon, 9 May 2022 23:50:05 +0800 Subject: [PATCH 16/17] =?UTF-8?q?ci.=E6=B7=BB=E5=8A=A0=20MaaBundle=20?= =?UTF-8?q?=E7=9A=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-release-bundle.yaml | 45 ++++++++++ build.ps1 | 2 +- .../Tasks/ReleaseBundleTask.cs | 88 +++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/maa-release-bundle.yaml create mode 100644 src/MeoAssistantBuilder/Tasks/ReleaseBundleTask.cs diff --git a/.github/workflows/maa-release-bundle.yaml b/.github/workflows/maa-release-bundle.yaml new file mode 100644 index 0000000000..eb25aaa7f0 --- /dev/null +++ b/.github/workflows/maa-release-bundle.yaml @@ -0,0 +1,45 @@ +name: Release MaaBundle + +on: + release: + types: + - published + +jobs: + + release-bundle: + + runs-on: windows-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Setup .NET 6.0.x + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Run release core task + run: pwsh .\build.ps1 ReleaseBundle + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: MaaBundle-${{ steps.tag.outputs.tag }} + path: ./artifacts/MaaBundle* + + - name: Upload release assets + uses: xresloader/upload-to-github-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: ./artifacts/MaaBundle* + tags: true + draft: false + verbose: true diff --git a/build.ps1 b/build.ps1 index c3b9466100..ee59fbc4fe 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ if ($args.Length -ne 1) { } $target = $args[0] -$valid_targets = @("ReleaseCore", "ReleaseWpf", "ReleaseResource", "DevBuild") +$valid_targets = @("ReleaseCore", "ReleaseWpf", "ReleaseResource", "ReleaseBundle", "DevBuild") if (!$valid_targets.Contains($target)) { throw "$target is not a valid target" diff --git a/src/MeoAssistantBuilder/Tasks/ReleaseBundleTask.cs b/src/MeoAssistantBuilder/Tasks/ReleaseBundleTask.cs new file mode 100644 index 0000000000..1a75549b30 --- /dev/null +++ b/src/MeoAssistantBuilder/Tasks/ReleaseBundleTask.cs @@ -0,0 +1,88 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using MeoAssistantBuilder.Helper; +using System.IO.Compression; +using System.Text.RegularExpressions; + +namespace MeoAssistantBuilder.Tasks; + +[TaskName("ReleaseBundle")] +public sealed class ReleaseBundleTask : FrostingTask +{ + public override void Run(MaaBuildContext context) + { + context.Information("--------------------------------------------------"); + context.Information("1. Read MaaCore version string"); + context.Information("--------------------------------------------------"); + + var version = "UNKNOWN"; + var versionFile = Path.Combine(Constants.MaaCoreProjectDirectory, "Version.h"); + var versionFileContent = File.ReadAllText(versionFile); + + var regex = @"v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)"; + + var match = Regex.Match(versionFileContent, regex); + if (match.Success is false) + { + context.Warning("Can not read version"); + Environment.Exit(-1); + } + else + { + version = match.Value; + } + + var ghActions = context.GitHubActions(); + if (ghActions.IsRunningOnGitHubActions is false) + { + version += "-Local"; + } + else + { + context.Information($"Running in GitHub Action with workflow name: {ghActions.Environment.Workflow.Workflow}, ref: {ghActions.Environment.Workflow.Ref}"); + if (ghActions.Environment.Workflow.Workflow != "Release MaaCore") + { + version += $"-{ghActions.Environment.Workflow.RunId}"; + } + else + { + var tag = ghActions.Environment.Workflow.Ref.Replace("refs/tags/", ""); + if (tag != version) + { + context.Error($"Version do not match. From File: {version}. From Ref: {tag}"); + Environment.Exit(-1); + } + } + } + + context.Information($"MaaCore Version: {version}"); + + context.Information("--------------------------------------------------"); + context.Information("2. Release MaaCore with third party dlls and resource"); + context.Information("--------------------------------------------------"); + + var buildOutput = Path.Combine(Constants.MaaBuildOutputDirectory, "Release"); + context.CleanAll(); + context.CleanArtifacts(); + + context.BuildCore("Release"); + context.RemoveExtraCore(buildOutput); + + context.Information("--------------------------------------------------"); + context.Information("3. Release MaaWpf with third party executables"); + context.Information("--------------------------------------------------"); + + context.BuildWpf("Release"); + context.RemoveExtraWpf(buildOutput); + + context.Information("--------------------------------------------------"); + context.Information("4. Bundle MaaBundle package"); + context.Information("--------------------------------------------------"); + + var bundle = Path.Combine(Constants.MaaProjectArtifactDirectory, $"MaaBundle-{version}.zip"); + ZipFile.CreateFromDirectory(buildOutput, bundle); + + context.Information($"Bundled MaaBundle file: {bundle}"); + } +} From 96c03d3079976caabbdb410e828c9dc3e6bf1d1e Mon Sep 17 00:00:00 2001 From: Liam Sho Date: Tue, 10 May 2022 00:15:13 +0800 Subject: [PATCH 17/17] =?UTF-8?q?ci.=E4=BF=AE=E5=A4=8D=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maa-dev-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maa-dev-build.yaml b/.github/workflows/maa-dev-build.yaml index f4e182094f..aa321e67d0 100644 --- a/.github/workflows/maa-dev-build.yaml +++ b/.github/workflows/maa-dev-build.yaml @@ -40,7 +40,7 @@ jobs: - name: Read file name id: read_path - run: pwsh .\read_path.ps1 ./artifacts MaaBundle + run: pwsh .\read_path.ps1 ./artifacts MaaBundle* - name: Upload Artifacts 0 uses: actions/upload-artifact@v3