返回提交历史
Added
.github/PUBLISHING.md
+45
-0
Added
.github/workflows/publish-packages.yml
+137
-0
Added
.github/workflows/validate.yml
+34
-0
Renamed
AutoConfig.Analyzer.Test/AutoConfig.Analyzer.Test.csproj
+2
-2
Modified
AutoConfig.Analyzer.Test/Program.cs
+1
-1
Modified
AutoConfig.Analyzer.Test/SystemProfile.cs
+1
-1
Modified
AutoConfig.Analyzer.Test/UserInfo.cs
+1
-1
Modified
AutoConfig.Analyzer.Test/UserProfile.cs
+1
-1
Deleted
XFEExtension.NetCore.AutoConfig.sln
+0
-39
Added
XFEExtension.NetCore.AutoConfig.slnx
+7
-0
Modified
XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj
+2
-2
XFEstudio/XFEExtension.NetCore.AutoConfig
重构测试项目并引入CI/CD自动化发布流程
- 测试项目命名空间重命名为 AutoConfig.Analyzer.Test,并迁移 csproj 文件 - 升级主项目和测试项目至 .NET 10.0,依赖包升级至 4.2.3 - 用 .slnx 替换传统 .sln,优化自动化支持 - 新增 validate.yml 和 publish-packages.yml,实现自动化构建与包发布 - 增加 PUBLISHING.md,完善发布流程文档
9b4c1ed
代码差异
11 个文件
+231
-47
@@ -0,0 +1,45 @@
1
# Publishing Packages
2
3
This repository now includes two GitHub Actions workflows:
4
5
- `Validate`: runs on `push` and `pull_request` to ensure the solution restores and builds cleanly.
6
- `Publish Packages`: runs when you push a tag that starts with `v`, for example `v3.0.9`, or when you trigger it manually from the Actions page.
7
8
## Required secrets
9
10
Add this repository secret before publishing to NuGet.org:
11
12
- `NUGET_API_KEY`: API key from NuGet.org with push permission for `XFEExtension.NetCore.AutoConfig`
13
14
No extra secret is required for GitHub Packages. The workflow uses the built-in `GITHUB_TOKEN` and requests `packages: write`.
15
16
The same built-in `GITHUB_TOKEN` is also used to create the GitHub Release and upload package assets.
17
18
## Recommended release flow
19
20
1. Update the project and verify CI is green.
21
2. Push a version tag such as `v3.0.9`.
22
3. GitHub Actions will automatically do all of the following:
23
- build and pack the project
24
- upload the generated `.nupkg` as a workflow artifact
25
- publish the package to NuGet.org
26
- publish the package to GitHub Packages at `https://nuget.pkg.github.com/XFEstudio/index.json`
27
- create a GitHub Release for that tag
28
- attach the generated `.nupkg` files to the GitHub Release
29
30
## Tag-triggered release behavior
31
32
When you push a new tag like `v3.0.9`, that single action is the release trigger for the entire pipeline. You do not need to manually start the workflow afterward.
33
34
The release workflow is tied to `push.tags: v*`, so each new version tag automatically runs the full publishing flow.
35
36
## Manual publish
37
38
If you need to republish packages from the GitHub Actions UI:
39
40
1. Open `Publish Packages`.
41
2. Click `Run workflow`.
42
3. Fill in the `version` input.
43
4. Optionally set `skip_nuget_org` to `true` when you only want GitHub Packages.
44
45
Manual runs publish packages, but GitHub Release creation is only performed for real tag pushes so the release stays aligned with the repository tag history.
@@ -0,0 +1,137 @@
1
name: Publish Packages
2
3
on:
4
push:
5
tags:
6
- "v*"
7
workflow_dispatch:
8
inputs:
9
version:
10
description: Package version to publish, for example 1.0.0
11
required: true
12
type: string
13
skip_nuget_org:
14
description: Skip publishing to NuGet.org
15
required: false
16
default: false
17
type: boolean
18
19
permissions:
20
contents: write
21
packages: write
22
23
env:
24
DOTNET_VERSION: 10.0.x
25
SOLUTION_PATH: XFEExtension.NetCore.AutoConfig.slnx
26
PROJECT_PATH: XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj
27
PACKAGE_OUTPUT_DIR: ${{ github.workspace }}/artifacts/packages
28
29
jobs:
30
publish:
31
runs-on: windows-latest
32
33
steps:
34
- name: Checkout
35
uses: actions/checkout@v4
36
with:
37
fetch-depth: 0
38
39
- name: Setup .NET
40
uses: actions/setup-dotnet@v4
41
with:
42
dotnet-version: ${{ env.DOTNET_VERSION }}
43
44
- name: Resolve version
45
id: version
46
shell: bash
47
run: |
48
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
49
version="${{ inputs.version }}"
50
else
51
version="${GITHUB_REF_NAME#v}"
52
fi
53
54
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?([-.][0-9A-Za-z.-]+)?$ ]]; then
55
echo "Invalid package version: $version"
56
exit 1
57
fi
58
59
echo "value=$version" >> "$GITHUB_OUTPUT"
60
echo "PACKAGE_VERSION=$version" >> "$GITHUB_ENV"
61
62
- name: Restore
63
run: dotnet restore ${{ env.SOLUTION_PATH }}
64
65
- name: Build
66
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
67
68
- name: Pack
69
run: dotnet pack ${{ env.PROJECT_PATH }} --configuration Release --no-build --no-restore --output ${{ env.PACKAGE_OUTPUT_DIR }} -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true -p:Version=${{ env.PACKAGE_VERSION }} -p:PackageVersion=${{ env.PACKAGE_VERSION }}
70
71
- name: Upload package artifacts
72
uses: actions/upload-artifact@v4
73
with:
74
name: packages-${{ env.PACKAGE_VERSION }}
75
path: ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg
76
if-no-files-found: error
77
78
- name: Publish to GitHub Packages
79
shell: pwsh
80
run: |
81
$packages = Get-ChildItem -Path "${{ env.PACKAGE_OUTPUT_DIR }}" -Filter *.nupkg -File
82
if (-not $packages) {
83
throw "No .nupkg files found in ${{ env.PACKAGE_OUTPUT_DIR }}"
84
}
85
86
foreach ($package in $packages) {
87
dotnet nuget push $package.FullName --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate
88
}
89
90
- name: Publish to NuGet.org
91
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.skip_nuget_org }}
92
shell: pwsh
93
run: |
94
$packages = Get-ChildItem -Path "${{ env.PACKAGE_OUTPUT_DIR }}" -Filter *.nupkg -File
95
if (-not $packages) {
96
throw "No .nupkg files found in ${{ env.PACKAGE_OUTPUT_DIR }}"
97
}
98
99
foreach ($package in $packages) {
100
dotnet nuget push $package.FullName --source "https://api.nuget.org/v3/index.json" --api-key "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
101
}
102
103
- name: Create GitHub Release
104
uses: softprops/action-gh-release@v2
105
with:
106
tag_name: ${{ github.ref_name }}
107
name: XFEExtension.NetCore.AutoConfig ${{ github.ref_name }}
108
generate_release_notes: true
109
append_body: true
110
body: |
111
## Package feeds
112
113
- NuGet.org
114
- GitHub Packages: `https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json`
115
files: ${{ env.PACKAGE_OUTPUT_DIR }}/*.nupkg
116
fail_on_unmatched_files: true
117
prerelease: ${{ contains(env.PACKAGE_VERSION, '-') }}
118
119
- name: Publish summary
120
shell: bash
121
run: |
122
{
123
echo "## Published packages"
124
echo ""
125
echo "- Version: \`${PACKAGE_VERSION}\`"
126
echo "- GitHub Packages: published"
127
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.skip_nuget_org }}" == "true" ]]; then
128
echo "- NuGet.org: skipped"
129
else
130
echo "- NuGet.org: published"
131
fi
132
if [[ "${{ github.event_name }}" == "push" && "${GITHUB_REF_NAME}" == v* ]]; then
133
echo "- GitHub Release: created"
134
else
135
echo "- GitHub Release: skipped"
136
fi
137
} >> "$GITHUB_STEP_SUMMARY"
@@ -0,0 +1,34 @@
1
name: Validate
2
3
on:
4
push:
5
branches:
6
- master
7
- main
8
pull_request:
9
10
permissions:
11
contents: read
12
13
env:
14
DOTNET_VERSION: 10.0.x
15
SOLUTION_PATH: XFEExtension.NetCore.AutoConfig.slnx
16
17
jobs:
18
build:
19
runs-on: windows-latest
20
21
steps:
22
- name: Checkout
23
uses: actions/checkout@v4
24
25
- name: Setup .NET
26
uses: actions/setup-dotnet@v4
27
with:
28
dotnet-version: ${{ env.DOTNET_VERSION }}
29
30
- name: Restore
31
run: dotnet restore ${{ env.SOLUTION_PATH }}
32
33
- name: Build
34
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true
@@ -2,7 +2,7 @@
2
2
3
3
<PropertyGroup>
4
4
<OutputType>Exe</OutputType>
5
<TargetFramework>net8.0</TargetFramework>
5
<TargetFramework>net10.0</TargetFramework>
6
6
<ImplicitUsings>enable</ImplicitUsings>
7
7
<Nullable>enable</Nullable>
8
8
<PublishAot>true</PublishAot>
@@ -10,7 +10,7 @@
10
10
</PropertyGroup>
11
11
12
12
<ItemGroup>
13
<PackageReference Include="XFEExtension.NetCore" Version="3.2.5" />
13
<PackageReference Include="XFEExtension.NetCore" Version="4.2.3" />
14
14
</ItemGroup>
15
15
16
16
<ItemGroup>
@@ -4,7 +4,7 @@ using System.Text.Json;
4
4
using XFEExtension.NetCore.StringExtension;
5
5
using XFEExtension.NetCore.StringExtension.Json;
6
6
7
namespace XFEExtension.NetCore.XUnit.Test;
7
namespace AutoConfig.Analyzer.Test;
8
8
9
9
public class Program
10
10
{
@@ -1,6 +1,6 @@
1
1
using XFEExtension.NetCore.AutoConfig;
2
2
3
namespace XFEExtension.NetCore.XUnit.Test;
3
namespace AutoConfig.Analyzer.Test;
4
4
5
5
public partial class SystemProfile : XFEProfile
6
6
{
@@ -1,4 +1,4 @@
1
namespace XFEExtension.NetCore.XUnit.Test;
1
namespace AutoConfig.Analyzer.Test;
2
2
3
3
/// <summary>
4
4
/// 用户信息
@@ -1,6 +1,6 @@
1
1
using XFEExtension.NetCore.AutoConfig;
2
2
3
namespace XFEExtension.NetCore.XUnit.Test;
3
namespace AutoConfig.Analyzer.Test;
4
4
5
5
/// <summary>
6
6
/// 用户配置文件
@@ -1,39 +0,0 @@
1
Microsoft Visual Studio Solution File, Format Version 12.00
2
# Visual Studio Version 18
3
VisualStudioVersion = 18.3.11415.281 d18.3
4
MinimumVisualStudioVersion = 10.0.40219.1
5
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoConfig", "XFEExtension.NetCore.AutoConfig\XFEExtension.NetCore.AutoConfig.csproj", "{33769964-C49C-4997-BB87-F8DB9669C98E}"
6
ProjectSection(ProjectDependencies) = postProject
7
{223198F6-C372-46F7-83E0-DC2504E7FDD3} = {223198F6-C372-46F7-83E0-DC2504E7FDD3}
8
EndProjectSection
9
EndProject
10
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoConfig.Analyzer", "XFEExtension.NetCore.AutoConfig.Analyzer\XFEExtension.NetCore.AutoConfig.Analyzer.csproj", "{223198F6-C372-46F7-83E0-DC2504E7FDD3}"
11
EndProject
12
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XFEExtension.NetCore.XUnit.Test", "AutoConfig.Analyzer.Test\XFEExtension.NetCore.XUnit.Test.csproj", "{30010077-451E-4DEA-9596-72208E41B2A2}"
13
EndProject
14
Global
15
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16
Debug|Any CPU = Debug|Any CPU
17
Release|Any CPU = Release|Any CPU
18
EndGlobalSection
19
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20
{33769964-C49C-4997-BB87-F8DB9669C98E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21
{33769964-C49C-4997-BB87-F8DB9669C98E}.Debug|Any CPU.Build.0 = Debug|Any CPU
22
{33769964-C49C-4997-BB87-F8DB9669C98E}.Release|Any CPU.ActiveCfg = Release|Any CPU
23
{33769964-C49C-4997-BB87-F8DB9669C98E}.Release|Any CPU.Build.0 = Release|Any CPU
24
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
26
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
27
{223198F6-C372-46F7-83E0-DC2504E7FDD3}.Release|Any CPU.Build.0 = Release|Any CPU
28
{30010077-451E-4DEA-9596-72208E41B2A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29
{30010077-451E-4DEA-9596-72208E41B2A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
30
{30010077-451E-4DEA-9596-72208E41B2A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
31
{30010077-451E-4DEA-9596-72208E41B2A2}.Release|Any CPU.Build.0 = Release|Any CPU
32
EndGlobalSection
33
GlobalSection(SolutionProperties) = preSolution
34
HideSolutionNode = FALSE
35
EndGlobalSection
36
GlobalSection(ExtensibilityGlobals) = postSolution
37
SolutionGuid = {C99AD407-FD04-4804-BD73-5FF02A85E71F}
38
EndGlobalSection
39
EndGlobal
@@ -0,0 +1,7 @@
1
<Solution>
2
<Project Path="AutoConfig.Analyzer.Test/AutoConfig.Analyzer.Test.csproj" />
3
<Project Path="XFEExtension.NetCore.AutoConfig.Analyzer/XFEExtension.NetCore.AutoConfig.Analyzer.csproj" />
4
<Project Path="XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj">
5
<BuildDependency Project="XFEExtension.NetCore.AutoConfig.Analyzer/XFEExtension.NetCore.AutoConfig.Analyzer.csproj" />
6
</Project>
7
</Solution>
@@ -1,7 +1,7 @@
1
1
<Project Sdk="Microsoft.NET.Sdk">
2
2
3
3
<PropertyGroup>
4
<TargetFramework>net8.0</TargetFramework>
4
<TargetFramework>net10.0</TargetFramework>
5
5
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
6
6
<ImplicitUsings>enable</ImplicitUsings>
7
7
<Nullable>enable</Nullable>
@@ -50,7 +50,7 @@
50
50
</ItemGroup>
51
51
52
52
<ItemGroup>
53
<PackageReference Include="XFEExtension.NetCore" Version="3.2.5" />
53
<PackageReference Include="XFEExtension.NetCore" Version="4.2.3" />
54
54
</ItemGroup>
55
55
56
56
</Project>