Skip to content

Commit

Permalink
累积策略更新并新增发布不附带框架的软件包 (#26)
Browse files Browse the repository at this point in the history
新增 发布不附带框架的软件包
优化 自动发布逻辑
优化 项目文件排除规则
修复 自动发布的软件包无法使用的问题
修复 英式英语语言文件命名错误的问题
调整 根据警告添加partial关键字
调整 补全菜单图标
调整 暂时禁用裁剪功能
调整 SDK版本
更新 策略配置文件至133.0.2992.0版本
更新 依赖项
  • Loading branch information
NXY666 authored Dec 8, 2024
1 parent 446e468 commit b58661d
Show file tree
Hide file tree
Showing 33 changed files with 2,290 additions and 227 deletions.
46 changes: 44 additions & 2 deletions .github/workflows/create_release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ function retry(fn, retryCount = 0) {
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;

await Promise.all(['x64', 'x86', 'arm64'].map((arch) => {
execSync("dotnet restore");
notice(`还原完成。`);

await Promise.all(['x64', 'x86', 'arm64'].map(async (arch) => {
execSync(`dotnet publish -p:Platform=${arch} -p:PublishProfile=Properties/PublishProfiles/win-${arch}.pubxml`);
execSync(`dotnet publish -p:Platform=${arch} -p:PublishProfile=Properties/PublishProfiles/win-${arch}-lite.pubxml`);
notice(`${arch} 架构软件包生成完成。`);
}));

Expand All @@ -53,6 +57,21 @@ function retry(fn, retryCount = 0) {
name: 'EdgePolicyManager-v${PUBLISH_VERSION}-arm64.exe',
path: './bin/publish/win-arm64/EdgePolicyManager.exe',
contentType: 'application/octet-stream'
},
{
name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x64-no-runtime.exe',
path: './bin/publish/win-x64-lite/EdgePolicyManager.exe',
contentType: 'application/octet-stream'
},
{
name: 'EdgePolicyManager-v${PUBLISH_VERSION}-x86-no-runtime.exe',
path: './bin/publish/win-x86-lite/EdgePolicyManager.exe',
contentType: 'application/octet-stream'
},
{
name: 'EdgePolicyManager-v${PUBLISH_VERSION}-arm64-no-runtime.exe',
path: './bin/publish/win-arm64-lite/EdgePolicyManager.exe',
contentType: 'application/octet-stream'
}
];

Expand All @@ -73,7 +92,30 @@ function retry(fn, retryCount = 0) {
owner, repo,
tag_name: `v${PUBLISH_VERSION}`,
name: CONFIG === 'Debug' ? `TestOnly ${PUBLISH_VERSION}` : `Release ${PUBLISH_VERSION}`,
body: `## 更新日志\n\n概述:**${COMMIT_TITLE}**\n\n<details>\n\n${COMMIT_BODY}\n\n</details>\n\n<hr>\n\n> 发布时间:${PUBLISH_DATETIME}\n\n> 策略版本:${EDGE_POLICY_VERSION}`,
body: `## 更新日志
概述:**${COMMIT_TITLE}**
<details>
${COMMIT_BODY}
</details>
<hr>
> [!NOTE]
> 带有 no-runtime 标记的版本在首次启动时可能需要下载并安装 .NET Runtime 和 Windows 应用 SDK。
>
> 不带 no-runtime 标记的版本已包含 .NET Runtime 和 Windows 应用 SDK,因此可以直接运行。
>
> 若你计划长期使用本软件,建议选择带有 no-runtime 标记的版本,以便节省流量。
>
> 反之,如果不希望安装额外的软件,或因某些原因无法完成安装,请选择不带 no-runtime 标记的版本。
> 发布时间:${PUBLISH_DATETIME}
> 策略版本:${EDGE_POLICY_VERSION}`,
draft: CONFIG === 'Debug',
prerelease: false
});
Expand Down
33 changes: 3 additions & 30 deletions .github/workflows/edit_version.mjs
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import fs from 'fs';
import {XMLParser, XMLBuilder} from 'fast-xml-parser';

(async () => {
const {PUBLISH_VERSION, CONFIG} = process.env;

const csprojPath = './PolicyManager.csproj';
const csprojData = fs.readFileSync(csprojPath);
const csprojData = fs.readFileSync(csprojPath).toString();

// 解析XML
const options = {
ignoreAttributes: false,
attributeNamePrefix: '@',
suppressEmptyNode: true,
format: CONFIG === 'Debug'
};

const parser = new XMLParser(options);
const csprojObj = parser.parse(csprojData);

// 修改版本号
if (csprojObj.Project?.PropertyGroup) {
const config = csprojObj.Project.PropertyGroup.find((item) => item["Version"]);
if (!config) {
console.log(JSON.stringify(csprojObj.Project.PropertyGroup));
throw new Error('Cannot find version property.');
}
config["Version"] = PUBLISH_VERSION;
} else {
console.log(JSON.stringify(csprojObj));
throw new Error('Cannot find PropertyGroup.');
}

// 转换为XML字符串
const builder = new XMLBuilder(options);
const xml = builder.build(csprojObj);
const xml = csprojData.replace("0.0.0.0", PUBLISH_VERSION);

// 写回.csproj文件
fs.writeFileSync(csprojPath, xml);
})();
})();
10 changes: 6 additions & 4 deletions .github/workflows/publisher.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publisher
name: Test Publisher

on:
push:
Expand All @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
node-version: [ 20.x ]
dotnet-version: [ 8.0.x ]
env:
CONFIG: Release

Expand All @@ -37,7 +38,6 @@ jobs:

- name: 修改版本号
run: |
npm i fast-xml-parser
node .github/workflows/edit_version.mjs
- name: 克隆完整仓库
Expand All @@ -63,12 +63,14 @@ jobs:
- name: 安装 .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: ${{ matrix.dotnet-version }}
cache: true

- name: 发布软件包
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
run: |
npm i @actions/github @octokit/rest
npm i -g @actions/github @octokit/rest
npm link @actions/github @octokit/rest
node .github/workflows/create_release.mjs
8 changes: 5 additions & 3 deletions .github/workflows/test_publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
node-version: [ 20.x ]
dotnet-version: [ 8.0.x ]
env:
CONFIG: Debug

Expand All @@ -37,7 +38,6 @@ jobs:

- name: 修改版本号
run: |
npm i fast-xml-parser
node .github/workflows/edit_version.mjs
- name: 克隆完整仓库
Expand All @@ -63,12 +63,14 @@ jobs:
- name: 安装 .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: ${{ matrix.dotnet-version }}
cache: true

- name: 发布软件包
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
run: |
npm i @actions/github @octokit/rest
npm i -g @actions/github @octokit/rest
npm link @actions/github @octokit/rest
node .github/workflows/create_release.mjs
5 changes: 4 additions & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.UI.Xaml;
using System;
using Microsoft.UI.Xaml;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -16,6 +17,8 @@ public partial class App
/// </summary>
public App()
{
// Set base directory env var for PublishSingleFile support (referenced by SxS redirection)
Environment.SetEnvironmentVariable("MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY", AppContext.BaseDirectory);
InitializeComponent();
}

Expand Down
2 changes: 1 addition & 1 deletion MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class GoPageParameter
public Dictionary<string, object> Parameters { get; init; }
}

public class MainPageModel(MainPage mainPage) : INotifyPropertyChanged
public partial class MainPageModel(MainPage mainPage) : INotifyPropertyChanged
{
private string _activePageName;

Expand Down
2 changes: 1 addition & 1 deletion Models/Icon/IconMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

namespace PolicyManager.Models.Icon;

public class IconMap : Dictionary<string, string>;
public partial class IconMap : Dictionary<string, string>;
2 changes: 1 addition & 1 deletion Models/Policy/PolicyDetailMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace PolicyManager.Models.Policy;

public class PolicyDetailMap : Dictionary<string, PolicyDetail>;
public partial class PolicyDetailMap : Dictionary<string, PolicyDetail>;

public class PolicyDetail
{
Expand Down
2 changes: 1 addition & 1 deletion Models/Policy/PolicyMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace PolicyManager.Models.Policy;

public class PolicyMenu : List<PolicyMenuItem>;
public partial class PolicyMenu : List<PolicyMenuItem>;

public class PolicyMenuItem
{
Expand Down
2 changes: 1 addition & 1 deletion Pages/Policy/DetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace PolicyManager.Pages.Policy;

public sealed class DetailPageModel : INotifyPropertyChanged, IDisposable
public sealed partial class DetailPageModel : INotifyPropertyChanged, IDisposable
{
public delegate void SearchPolicyEventHandler(string keyword);

Expand Down
11 changes: 1 addition & 10 deletions Pages/Policy/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using Windows.Win32.UI.Shell;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -11,18 +9,11 @@

namespace PolicyManager.Pages.Policy;

public sealed class SettingsPageModel : INotifyPropertyChanged
public sealed class SettingsPageModel
{
public string PolicyType { get; init; }

public string PolicyRegistryPath { init; get; }

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

public sealed partial class SettingsPage
Expand Down
91 changes: 26 additions & 65 deletions PolicyManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,99 +13,60 @@
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<EnableMsixTooling>true</EnableMsixTooling>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<LangVersion>12</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<SelfContained>true</SelfContained>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode>
<WindowsPackageType>None</WindowsPackageType>
<PublishTrimmed>false</PublishTrimmed>
<PublishSingleFile>true</PublishSingleFile>
<WindowsAppSdkUndockedRegFreeWinRTInitialize>true</WindowsAppSdkUndockedRegFreeWinRTInitialize>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<DebugType>embedded</DebugType>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<Version>0.0.0.0</Version>
</PropertyGroup>

<ItemGroup>
<None Remove="StaticModels\Icon\IconMap.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\en-US\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\en-US\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\zh-CN\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\zh-CN\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\zh-TW\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeUpdate\zh-TW\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\EdgeWebview\en-US\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeWebview\en-US\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\EdgeWebview\zh-CN\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeWebview\zh-CN\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\EdgeWebview\zh-TW\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\EdgeWebview\zh-TW\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\Edge\en-US\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\Edge\en-US\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\Edge\zh-CN\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\Edge\zh-CN\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\Edge\zh-TW\PolicyDetailMap.json" />
<None Remove="StaticModels\Policy\Edge\zh-TW\PolicyMenuList.json" />
<None Remove="StaticModels\Policy\SUPPORT_VERSION" />
<SupportedPlatform Include="Windows" />
</ItemGroup>

<ItemGroup>
<None Remove="StaticModels\**" />
<None Remove="README.*" />
<None Remove="Local\**" />
<None Remove="node_modules\**" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="StaticModels\Icon\IconMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\en-US\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\en-US\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\zh-CN\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\zh-CN\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\zh-TW\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeUpdate\zh-TW\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\en-US\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\en-US\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\zh-CN\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\zh-CN\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\zh-TW\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\EdgeWebview\zh-TW\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\en-US\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\en-US\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\zh-CN\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\zh-CN\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\zh-TW\PolicyDetailMap.json" />
<EmbeddedResource Include="StaticModels\Policy\Edge\zh-TW\PolicyMenuList.json" />
<EmbeddedResource Include="StaticModels\Policy\SUPPORT_VERSION" />
<EmbeddedResource Include="StaticModels\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" Version="8.0.7" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240627000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<Manifest Include="$(ApplicationManifest)" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="WinUIEx" Version="2.5.0" />
</ItemGroup>
<ItemGroup>
<Content Update="Assets\icon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Assets\msedge.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Assets\msedgeupdate.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Assets\msedgewebview2.ico">
<Content Update="Assets\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<WebView2EnableCsWinRTProjection>False</WebView2EnableCsWinRTProjection>
</PropertyGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Expand Down
Loading

0 comments on commit b58661d

Please sign in to comment.