Merge branch 'master' into dev

This commit is contained in:
Liam Sho
2022-06-18 02:44:26 +08:00
5 changed files with 76 additions and 35 deletions

View File

@@ -1,30 +0,0 @@
name: deploy-docs
on:
push:
branches:
- master
paths:
- "docs/*"
workflow_dispatch:
jobs:
deploy-to-azure:
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

7
.maabundlerignore Normal file
View File

@@ -0,0 +1,7 @@
libiomp5md.dll
mkldnn.dll
mklml.dll
opencv_world453.dll
paddle_inference.dll
ppocr.dll
resource/PaddleOCR/**

View File

@@ -73,11 +73,13 @@
"SetVersion",
"UseCleanArtifact",
"UseCleanRelease",
"UseCleanReleaseOta",
"UseCommitVersion",
"UseMaaChangeLog",
"UseMaaCore",
"UseMaaDevBundle",
"UseMaaLegacyBundle",
"UseMaaLegacyBundleOta",
"UseMaaResource",
"UseMaaResourceChangeLog",
"UsePublishArtifact",
@@ -105,11 +107,13 @@
"SetVersion",
"UseCleanArtifact",
"UseCleanRelease",
"UseCleanReleaseOta",
"UseCommitVersion",
"UseMaaChangeLog",
"UseMaaCore",
"UseMaaDevBundle",
"UseMaaLegacyBundle",
"UseMaaLegacyBundleOta",
"UseMaaResource",
"UseMaaResourceChangeLog",
"UsePublishArtifact",

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileSystemGlobbing;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
@@ -10,6 +11,7 @@ using Nuke.Common.Tools.MSBuild;
using Octokit;
using Serilog;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
@@ -47,6 +49,7 @@ public partial class Build : NukeBuild
const string MaaDevBundlePackageNameTemplate = "MaaBundle-Dev-{VERSION}";
const string MaaLegacyBundlePackageNameTemplate = "MeoAssistantArknights_{VERSION}";
const string MaaLegacyBundleOtaPackageNameTemplate = "MeoAssistantArknights_OTA_{VERSION}";
const string MaaCorePackageNameTemplate = "MaaCore-{VERSION}";
const string MaaResourcePackageNameTemplate = "MaaResource-{VERSION}";
@@ -55,6 +58,7 @@ public partial class Build : NukeBuild
private string MaaDevBundlePackageName => MaaDevBundlePackageNameTemplate.Replace("{VERSION}", _version);
private string MaaLegacyBundlePackageName => MaaLegacyBundlePackageNameTemplate.Replace("{VERSION}", _version);
private string MaaLegacyBundleOtaPackageName => MaaLegacyBundleOtaPackageNameTemplate.Replace("{VERSION}", _version);
private string MaaCorePackageName => MaaCorePackageNameTemplate.Replace("{VERSION}", _version);
private string MaaResourcePackageName => MaaResourcePackageNameTemplate.Replace("{VERSION}", _version);
@@ -69,7 +73,6 @@ public partial class Build : NukeBuild
Information($"MSBuild 路径:{Parameters.MsBuildPath ?? "Null"}");
Information("2. 仓库");
Information($"Fork{Parameters.IsFork}");
Information($"主仓库:{Parameters.MainRepo ?? "Null"}");
Information($"MaaResource 发布仓库:{Parameters.MaaResourceReleaseRepo ?? "Null"}");
Information($"主分支:{Parameters.MasterBranchRef ?? "Null"}");
@@ -122,6 +125,12 @@ public partial class Build : NukeBuild
{
FileSystemTasks.EnsureCleanDirectory(Parameters.BuildOutput / BuildConfiguration.Release);
});
Target UseCleanReleaseOta => _ => _
.Executes(() =>
{
FileSystemTasks.EnsureCleanDirectory(Parameters.BuildOutput / $"{BuildConfiguration.Release}_OTA");
});
#endregion
@@ -252,6 +261,27 @@ public partial class Build : NukeBuild
BundlePackage(releaseBuildOutput, MaaLegacyBundlePackageName);
});
Target UseMaaLegacyBundleOta => _ => _
.After(UseMaaLegacyBundle)
.DependsOn(UseCleanArtifact, WithCompileCoreRelease, WithCompileWpfRelease, UseCleanReleaseOta)
.Triggers(SetPackageBundled)
.Executes(() =>
{
var releaseBuildOutput = Parameters.BuildOutput / BuildConfiguration.Release;
var otaPackageOutput = Parameters.BuildOutput / $"{BuildConfiguration.Release}_OTA";
FileSystemTasks.CopyDirectoryRecursively(releaseBuildOutput, otaPackageOutput,
DirectoryExistsPolicy.Merge, FileExistsPolicy.Overwrite);
var ignoreFile = RootDirectory / ".maabundlerignore";
if (ignoreFile.FileExists())
{
RemoveIgnoreFiles(otaPackageOutput, ignoreFile);
}
BundlePackage(otaPackageOutput, MaaLegacyBundleOtaPackageName);
});
Target UseMaaCore => _ => _
.DependsOn(UseCleanArtifact, WithCompileCoreRelease)
.Triggers(SetPackageBundled)
@@ -276,6 +306,7 @@ public partial class Build : NukeBuild
});
Target SetPackageBundled => _ => _
.After(UseMaaDevBundle, UseMaaLegacyBundle, UseMaaLegacyBundleOta, UseMaaCore, UseMaaResource)
.Executes(() =>
{
Information("已完成打包");
@@ -405,6 +436,7 @@ public partial class Build : NukeBuild
Target ReleaseMaa => _ => _
.DependsOn(UseTagVersion)
.DependsOn(UseMaaLegacyBundle)
.DependsOn(UseMaaLegacyBundleOta)
.DependsOn(UseMaaChangeLog)
.DependsOn(UsePublishArtifact)
.DependsOn(UsePublishRelease);
@@ -448,6 +480,38 @@ public partial class Build : NukeBuild
#region Utilities
private void RemoveIgnoreFiles(AbsolutePath baseDirectory, AbsolutePath ignoreFile)
{
var ignoreFileLines = File.ReadAllLines(ignoreFile);
var ignorePattern = new List<string>();
var keepPattern = new List<string>();
foreach (var line in ignoreFileLines)
{
if (line.StartsWith("#"))
{
continue;
}
if (line.StartsWith("!"))
{
keepPattern.Add(line.Substring(1));
}
else
{
ignorePattern.Add(line);
}
}
var match = new Matcher();
// 这里反过来可以获取到需要排除的文件列表,而不是需要保留的文件列表
match.AddExcludePatterns(keepPattern);
match.AddIncludePatterns(ignorePattern);
var ignoredFiles = match.GetResultsInFullPath(baseDirectory);
foreach (var f in ignoredFiles)
{
FileSystemTasks.DeleteFile(f);
}
}
private void BundlePackage(AbsolutePath input, string bundleName)
{
var packName = bundleName;
@@ -473,7 +537,6 @@ public partial class Build : NukeBuild
foreach (var file in files)
{
FileSystemTasks.DeleteFile(file);
Information($"删除文件:{file}");
}
}
private void RemoveReleaseResource(AbsolutePath outputDir)

View File

@@ -59,7 +59,6 @@ public partial class Build
public AbsolutePath VisualStudioPath { get; }
// 仓库
public bool IsFork { get; }
public string MainRepo { get; }
public string MasterBranchRef { get; }
public string DevBranchRef { get; }
@@ -104,7 +103,6 @@ public partial class Build
MsBuildPath = (AbsolutePath)msbuild;
// 仓库
IsFork = false;
MainRepo = "MaaAssistantArknights/MaaAssistantArknights";
MaaResourceReleaseRepo = "MaaAssistantArknights/MaaResourceRelease";
@@ -197,7 +195,6 @@ public partial class Build
MainRepo = b.GitHubActions.Repository;
var repoOwner = MainRepo.Split("/")[0];
MaaResourceReleaseRepo = $"{repoOwner}/MaaResourceRelease";
IsFork = true;
}
// 若是 DevBuildBranch 必须不为 Master或者是 PR 至 Dev又或者是手动触发