diff --git a/.github/workflows/release-maa-resource.yml b/.github/workflows/release-maa-resource.yml
deleted file mode 100644
index bff34b9368..0000000000
--- a/.github/workflows/release-maa-resource.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-# ------------------------------------------------------------------------------
-#
-#
-# This code was generated.
-#
-# - To turn off auto-generation set:
-#
-# [GitHubActions (AutoGenerate = false)]
-#
-# - To trigger manual generation invoke:
-#
-# nuke --generate-configuration GitHubActions_release-maa-resource --host GitHubActions
-#
-#
-# ------------------------------------------------------------------------------
-
-name: release-maa-resource
-
-on:
- push:
- branches:
- - master
- paths:
- - 'resource/**'
- - '3rdparty/resource/**'
-
-jobs:
- windows-latest:
- name: windows-latest
- runs-on: windows-latest
- steps:
- - uses: actions/checkout@v1
- - name: Cache .nuke/temp, ~/.nuget/packages
- uses: actions/cache@v2
- with:
- path: |
- .nuke/temp
- ~/.nuget/packages
- key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
- - name: Run './build.cmd ReleaseMaaResource'
- run: ./build.cmd ReleaseMaaResource
- env:
- PUBLISH_GH_PAT: ${{ secrets.PUBLISH_GH_PAT }}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - uses: actions/upload-artifact@v1
- with:
- name: artifacts
- path: artifacts
diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json
index c10d69de2d..35186d1765 100644
--- a/.nuke/build.schema.json
+++ b/.nuke/build.schema.json
@@ -66,7 +66,6 @@
"Default",
"DevBuild",
"ReleaseMaa",
- "ReleaseMaaResource",
"SetMaaChangeLog",
"SetPackageBundled",
"SetVersion",
@@ -75,13 +74,10 @@
"UseMaaChangeLog",
"UseMaaDevBundle",
"UseMaaRelease",
- "UseMaaResource",
- "UseMaaResourceChangeLog",
"UsePublishArtifact",
"UsePublishRelease",
"UseTagVersion",
"WithCompileCoreRelease",
- "WithCompileResourceRelease",
"WithCompileWpfRelease"
]
}
@@ -95,7 +91,6 @@
"Default",
"DevBuild",
"ReleaseMaa",
- "ReleaseMaaResource",
"SetMaaChangeLog",
"SetPackageBundled",
"SetVersion",
@@ -104,13 +99,10 @@
"UseMaaChangeLog",
"UseMaaDevBundle",
"UseMaaRelease",
- "UseMaaResource",
- "UseMaaResourceChangeLog",
"UsePublishArtifact",
"UsePublishRelease",
"UseTagVersion",
"WithCompileCoreRelease",
- "WithCompileResourceRelease",
"WithCompileWpfRelease"
]
}
diff --git a/package-definition.json b/package-definition.json
index 4671fc0841..4bc838582a 100644
--- a/package-definition.json
+++ b/package-definition.json
@@ -2,21 +2,23 @@
{
"name_template": "MaaBundle-{VERSION}",
"type": "MaaBundle",
- "configuration": { }
+ "configuration": {
+ "include": [
+ "**"
+ ]
+ }
},
{
"name_template": "MaaBundle-OTA-{VERSION}",
"type": "MaaBundleOta",
"configuration": {
+ "include": [
+ "resource/**",
+ "MeoAssistant.dll",
+ "MeoAsstGui.exe"
+ ],
"exclude": [
- "libiomp5md.dll",
- "mkldnn.dll",
- "mklml.dll",
- "opencv_world453.dll",
- "paddle_inference.dll",
- "ppocr.dll",
- "aria2c.exe",
- "resource/PaddleOCR/**"
+ "**/PaddleOCR/**"
]
}
},
@@ -37,9 +39,10 @@
"libiomp5md.dll",
"mkldnn.dll",
"mklml.dll",
- "opencv_world453.dll",
"paddle_inference.dll",
- "ppocr.dll"
+ "ppocr.dll",
+ "opencv_world453.dll",
+ "**/PaddleOCR/**"
]
}
},
@@ -48,12 +51,22 @@
"type": "MaaDependencyNoAvx",
"configuration": {
"include": [
- "libiomp5md.dll",
- "mkldnn.dll",
- "mklml.dll",
- "opencv_world453.dll"
+ "opencv_world453.dll",
+ "**/PaddleOCR/**"
],
"no_avx_bundle": "3rdparty/ppocr_noavx.zip"
}
+ },
+ {
+ "name_template": "MaaResource-{VERSION}",
+ "type": "MaaResource",
+ "configuration": {
+ "include": [
+ "resource/**"
+ ],
+ "exclude": [
+ "**/PaddleOCR/**"
+ ]
+ }
}
]
diff --git a/tools/MaaBuilder/Build.CI.GitHubActions.ReleaseMaaResource.cs b/tools/MaaBuilder/Build.CI.GitHubActions.ReleaseMaaResource.cs
deleted file mode 100644
index 3111772f05..0000000000
--- a/tools/MaaBuilder/Build.CI.GitHubActions.ReleaseMaaResource.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Nuke.Common.CI.GitHubActions;
-
-namespace MaaBuilder;
-
-[GitHubActions(
- name: "release-maa-resource",
- image: GitHubActionsImage.WindowsLatest,
- OnPushBranches = new[] { MasterBranch },
- OnPushIncludePaths = new[]
- {
- "resource/**",
- "3rdparty/resource/**"
- },
- InvokedTargets = new[] { nameof(ReleaseMaaResource) },
- ImportSecrets = new[] { "PUBLISH_GH_PAT" },
- EnableGitHubToken = true,
- PublishArtifacts = true
- )]
-public partial class Build { }
diff --git a/tools/MaaBuilder/Build.Helper.Bundler.cs b/tools/MaaBuilder/Build.Helper.Bundler.cs
index f84ed5e22a..8e53856789 100644
--- a/tools/MaaBuilder/Build.Helper.Bundler.cs
+++ b/tools/MaaBuilder/Build.Helper.Bundler.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
-using System.Text.Json;
+using System.Linq;
using MaaBuilder.Models;
using Microsoft.Extensions.FileSystemGlobbing;
using Nuke.Common;
@@ -29,30 +29,23 @@ public partial class Build
ZipFile.CreateFromDirectory(input, bundle, CompressionLevel.SmallestSize, false);
}
- static void RemoveIgnoredFiles(AbsolutePath baseDirectory, IEnumerable ignorePattern)
+ static void MoveGlobFiles(AbsolutePath source, AbsolutePath target, IEnumerable include, IEnumerable exclude)
{
- var match = new Matcher();
+ var iMatch = new Matcher();
+ var eMatch = new Matcher();
- // 这里反过来可以获取到需要排除的文件列表,而不是需要保留的文件列表
- match.AddIncludePatterns(ignorePattern);
+ iMatch.AddIncludePatterns(include);
+ eMatch.AddIncludePatterns(exclude);
+
+ var includeFiles = iMatch.GetResultsInFullPath(source).ToList();
+ var excludeFiles = eMatch.GetResultsInFullPath(source).ToList();
+
+ includeFiles.RemoveAll(x => excludeFiles.Contains(x));
- var ignoredFiles = match.GetResultsInFullPath(baseDirectory);
- foreach (var f in ignoredFiles)
- {
- FileSystemTasks.DeleteFile(f);
- }
- }
-
- static void CopyIncludeFiles(AbsolutePath originalDirectory, AbsolutePath targetDirectory, IEnumerable includePattern)
- {
- var match = new Matcher();
- match.AddIncludePatterns(includePattern);
- var includeFiles = match.GetResultsInFullPath(originalDirectory);
-
foreach (var file in includeFiles)
{
- var relative = file.Replace(originalDirectory, string.Empty);
- var targetPath = targetDirectory / relative;
+ var relative = file.Replace(source, string.Empty);
+ var targetPath = target / relative;
FileSystemTasks.CopyFile(file, targetPath, FileExistsPolicy.Overwrite);
}
@@ -68,63 +61,23 @@ public partial class Build
}
}
- static T GetPackageBundlerConfiguration(Package package) where T : class, IPackageConfiguration
+ void BundleMaaBundle(AbsolutePath buildOutput, string bundleName, Package package)
{
- var configString = package.Configuration["configuration"].ToString().NotNull();
- var config = JsonSerializer.Deserialize(configString).NotNull();
- return config;
- }
-
- void BundleMaaBundle(AbsolutePath buildOutput, string bundleName)
- {
- BundlePackage(buildOutput, bundleName);
- }
-
- void BundleMaaBundleOta(AbsolutePath buildOutput, string bundleName, Package package)
- {
- var context = Parameters.BuildOutput / package.PackageType.ToString();
- FileSystemTasks.CopyDirectoryRecursively(buildOutput, context, DirectoryExistsPolicy.Merge);
-
- var config = GetPackageBundlerConfiguration(package);
-
- RemoveIgnoredFiles(context, config.Exclude);
- BundlePackage(context, bundleName);
- }
-
- void BundleMaaCore(AbsolutePath buildOutput, string bundleName, Package package)
- {
- var context = Parameters.BuildOutput / package.PackageType.ToString();
- FileSystemTasks.EnsureExistingDirectory(context);
+ var tempDir = buildOutput.Parent / package.PackageType.ToString();
+ FileSystemTasks.EnsureExistingDirectory(tempDir);
- var config = GetPackageBundlerConfiguration(package);
+ var include = package.Configuration.Include;
+ var exclude = package.Configuration.Exclude;
+ var noAvxBundle = package.Configuration.NoAvxBundle;
- CopyIncludeFiles(buildOutput, context, config.Include);
- BundlePackage(context, bundleName);
- }
+ MoveGlobFiles(buildOutput, tempDir, include, exclude);
- void BundleMaaDependency(AbsolutePath buildOutput, string bundleName, Package package)
- {
- var context = Parameters.BuildOutput / package.PackageType.ToString();
- FileSystemTasks.EnsureExistingDirectory(context);
+ if (string.IsNullOrEmpty(noAvxBundle) is false)
+ {
+ var file = RootDirectory / noAvxBundle;
+ ZipFile.ExtractToDirectory(file, tempDir, true);
+ }
- var config = GetPackageBundlerConfiguration(package);
-
- CopyIncludeFiles(buildOutput, context, config.Include);
- BundlePackage(context, bundleName);
- }
-
- void BundleMaaDependencyNoAvx(AbsolutePath buildOutput, string bundleName, Package package)
- {
- var context = Parameters.BuildOutput / package.PackageType.ToString();
- FileSystemTasks.EnsureExistingDirectory(context);
-
- var config = GetPackageBundlerConfiguration(package);
-
- CopyIncludeFiles(buildOutput, context, config.Include);
-
- var noAvxBundle = RootDirectory / config.NoAvxBundle;
- ZipFile.ExtractToDirectory(noAvxBundle, context, overwriteFiles: true);
-
- BundlePackage(context, bundleName);
+ BundlePackage(tempDir, bundleName);
}
}
diff --git a/tools/MaaBuilder/Build.Job.Bundle.cs b/tools/MaaBuilder/Build.Job.Bundle.cs
index 4dc273e1eb..d84ef7d713 100644
--- a/tools/MaaBuilder/Build.Job.Bundle.cs
+++ b/tools/MaaBuilder/Build.Job.Bundle.cs
@@ -29,45 +29,14 @@ public partial class Build
foreach (var package in Parameters.Packages)
{
- var type = package.PackageType;
var name = package.NameTemplate.Replace("{VERSION}", Version);
-
- switch (type)
- {
- case PackageTypes.MaaBundle:
- BundleMaaBundle(releaseBuildOutput, name);
- break;
- case PackageTypes.MaaBundleOta:
- BundleMaaBundleOta(releaseBuildOutput, name, package);
- break;
- case PackageTypes.MaaCore:
- BundleMaaCore(releaseBuildOutput, name, package);
- break;
- case PackageTypes.MaaDependency:
- BundleMaaDependency(releaseBuildOutput, name, package);
- break;
- case PackageTypes.MaaDependencyNoAvx:
- BundleMaaDependencyNoAvx(releaseBuildOutput, name, package);
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
+
+ BundleMaaBundle(releaseBuildOutput, name, package);
}
});
- Target UseMaaResource => _ => _
- .DependsOn(WithCompileResourceRelease)
- .Triggers(SetPackageBundled)
- .Executes(() =>
- {
- var buildOutput = Parameters.BuildOutput / BuildConfiguration.Release;
- RemoveDebugSymbols(buildOutput);
-
- BundlePackage(buildOutput, MaaResourcePackageName);
- });
-
Target SetPackageBundled => _ => _
- .After(UseMaaDevBundle, UseMaaResource)
+ .After(UseMaaDevBundle)
.Executes(() =>
{
Information("已完成打包");
diff --git a/tools/MaaBuilder/Build.Job.Changelog.cs b/tools/MaaBuilder/Build.Job.Changelog.cs
index 27e6d59424..6e7d44d761 100644
--- a/tools/MaaBuilder/Build.Job.Changelog.cs
+++ b/tools/MaaBuilder/Build.Job.Changelog.cs
@@ -31,23 +31,6 @@ public partial class Build
}
});
- Target UseMaaResourceChangeLog => _ => _
- .Triggers(SetMaaChangeLog)
- .Executes(() =>
- {
- if (File.Exists(Parameters.MaaResourceChangeLogFile))
- {
- Information($"找到 {Parameters.MaaResourceChangeLogFile} 文件,读取内容作为更新日志");
- var text = File.ReadAllText(Parameters.MaaResourceChangeLogFile);
- ChangeLog = text;
- }
- else
- {
- Warning($"未发现 {Parameters.MaaResourceChangeLogFile} 文件,将使用默认值");
- }
- ChangeLog += $"\n\n对应 Commit:[{Parameters.MainRepo}@{Parameters.CommitHash}](https://github.com/{Parameters.MainRepo}/commit/{Parameters.CommitHashFull})";
- });
-
Target SetMaaChangeLog => _ => _
.Executes(() =>
{
diff --git a/tools/MaaBuilder/Build.Job.Compile.cs b/tools/MaaBuilder/Build.Job.Compile.cs
index 2d5601a265..a109f51624 100644
--- a/tools/MaaBuilder/Build.Job.Compile.cs
+++ b/tools/MaaBuilder/Build.Job.Compile.cs
@@ -1,5 +1,4 @@
using Nuke.Common;
-using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.MSBuild;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;
@@ -40,21 +39,4 @@ public partial class Build
.EnableRestore()
);
});
-
- Target WithCompileResourceRelease => _ => _
- .DependsOn(UseClean)
- .After(SetVersion)
- .Executes(() =>
- {
- var output = Parameters.BuildOutput / BuildConfiguration.Release;
- var resourceFile = RootDirectory / "resource";
- var resourceFileThirdParty = RootDirectory / "3rdparty" / "resource";
-
- Information($"复制目录:{resourceFile} -> {output}");
- FileSystemTasks.CopyDirectoryRecursively(resourceFile, output,
- DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
- Information($"复制目录:{resourceFileThirdParty} -> {output}");
- FileSystemTasks.CopyDirectoryRecursively(resourceFileThirdParty, output,
- DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
- });
}
diff --git a/tools/MaaBuilder/Build.Job.Workflow.cs b/tools/MaaBuilder/Build.Job.Workflow.cs
index 297dc97f02..cf237660b7 100644
--- a/tools/MaaBuilder/Build.Job.Workflow.cs
+++ b/tools/MaaBuilder/Build.Job.Workflow.cs
@@ -22,14 +22,4 @@ public partial class Build
.DependsOn(UseMaaChangeLog)
.DependsOn(UsePublishArtifact)
.DependsOn(UsePublishRelease);
-
- ///
- /// 见
- ///
- Target ReleaseMaaResource => _ => _
- .DependsOn(UseCommitVersion)
- .DependsOn(UseMaaResource)
- .DependsOn(UseMaaResourceChangeLog)
- .DependsOn(UsePublishArtifact)
- .DependsOn(UsePublishRelease);
}
diff --git a/tools/MaaBuilder/Models/IPackageConfiguration.cs b/tools/MaaBuilder/Models/IPackageConfiguration.cs
deleted file mode 100644
index 699a316849..0000000000
--- a/tools/MaaBuilder/Models/IPackageConfiguration.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-namespace MaaBuilder.Models;
-
-public interface IPackageConfiguration { }
diff --git a/tools/MaaBuilder/Models/Package.MaaBundleOta.cs b/tools/MaaBuilder/Models/Package.MaaBundleOta.cs
deleted file mode 100644
index 70384a190c..0000000000
--- a/tools/MaaBuilder/Models/Package.MaaBundleOta.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace MaaBuilder.Models;
-
-public record PackageMaaBundleOta : IPackageConfiguration
-{
- [JsonPropertyName("exclude")]
- public List Exclude { get; set; }
-}
diff --git a/tools/MaaBuilder/Models/Package.MaaCore.cs b/tools/MaaBuilder/Models/Package.MaaCore.cs
deleted file mode 100644
index 6145263c19..0000000000
--- a/tools/MaaBuilder/Models/Package.MaaCore.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace MaaBuilder.Models;
-
-public record PackageMaaCore : IPackageConfiguration
-{
- [JsonPropertyName("include")]
- public List Include { get; set; }
-}
diff --git a/tools/MaaBuilder/Models/Package.MaaDependency.cs b/tools/MaaBuilder/Models/Package.MaaDependency.cs
deleted file mode 100644
index 20f564e617..0000000000
--- a/tools/MaaBuilder/Models/Package.MaaDependency.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace MaaBuilder.Models;
-
-public record PackageMaaDependency : IPackageConfiguration
-{
- [JsonPropertyName("include")]
- public List Include { get; set; }
-}
diff --git a/tools/MaaBuilder/Models/Package.MaaDependencyNoAvx.cs b/tools/MaaBuilder/Models/Package.MaaDependencyNoAvx.cs
deleted file mode 100644
index 63378deea9..0000000000
--- a/tools/MaaBuilder/Models/Package.MaaDependencyNoAvx.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
-
-namespace MaaBuilder.Models;
-
-public record PackageMaaDependencyNoAvx : IPackageConfiguration
-{
- [JsonPropertyName("include")]
- public List Include { get; set; }
-
- [JsonPropertyName("no_avx_bundle")]
- public string NoAvxBundle { get; set; }
-}
diff --git a/tools/MaaBuilder/Models/Package.cs b/tools/MaaBuilder/Models/Package.cs
index 33e78dd7c3..a508dd6912 100644
--- a/tools/MaaBuilder/Models/Package.cs
+++ b/tools/MaaBuilder/Models/Package.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace MaaBuilder.Models;
@@ -12,6 +11,6 @@ public record Package
[JsonConverter(typeof(JsonStringEnumConverter))]
public PackageTypes PackageType { get; init; }
- [JsonExtensionData]
- public Dictionary Configuration { get; init; }
+ [JsonPropertyName("configuration")]
+ public PackageConfiguration Configuration { get; init; }
}
diff --git a/tools/MaaBuilder/Models/PackageConfiguration.cs b/tools/MaaBuilder/Models/PackageConfiguration.cs
new file mode 100644
index 0000000000..83e0f5ebaf
--- /dev/null
+++ b/tools/MaaBuilder/Models/PackageConfiguration.cs
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+
+namespace MaaBuilder.Models;
+
+public record PackageConfiguration
+{
+ [JsonPropertyName("include")]
+ public IEnumerable Include { get; init; } = new List();
+
+ [JsonPropertyName("exclude")]
+ public IEnumerable Exclude { get; init; } = new List();
+
+ [JsonPropertyName("no_avx_bundle")]
+ public string NoAvxBundle { get; init; } = string.Empty;
+}
diff --git a/tools/MaaBuilder/Models/PackageTypes.cs b/tools/MaaBuilder/Models/PackageTypes.cs
index 4cd26d1dd8..613cea2b06 100644
--- a/tools/MaaBuilder/Models/PackageTypes.cs
+++ b/tools/MaaBuilder/Models/PackageTypes.cs
@@ -6,5 +6,6 @@ public enum PackageTypes
MaaBundleOta,
MaaCore,
MaaDependency,
- MaaDependencyNoAvx
+ MaaDependencyNoAvx,
+ MaaResource
}