XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.AutoPath

【DLL】自动路径创建工具,自动创建不存在的文件夹,对路径统一管理

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.AutoPath

升级至 .NET 10 并集成自动化 CI/CD 工作流

- 解决方案文件由 .sln 改为 .slnx,适配自动化场景 - 项目目标框架从 net8.0 升级为 net10.0 - 新增 validate.yml 和 publish-packages.yml,实现自动化构建与包发布 - 新增 PUBLISHING.md,完善发布流程文档

995a43a
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

6 个文件 +232 -38
Added .github/PUBLISHING.md +45 -0
@@ -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.WinUIHelper`
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.
Added .github/workflows/publish-packages.yml +137 -0
@@ -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 3.0.9
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.AutoPath.slnx
26 PROJECT_PATH: XFEExtension.NetCore.AutoPath/XFEExtension.NetCore.AutoPath.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.AutoPath ${{ 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"
Added .github/workflows/validate.yml +35 -0
@@ -0,0 +1,35 @@
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.AutoPath.slnx
16 PROJECT_PATH: XFEExtension.NetCore.AutoPath/XFEExtension.NetCore.AutoPath.csproj
17
18 jobs:
19 build:
20 runs-on: windows-latest
21
22 steps:
23 - name: Checkout
24 uses: actions/checkout@v4
25
26 - name: Setup .NET
27 uses: actions/setup-dotnet@v4
28 with:
29 dotnet-version: ${{ env.DOTNET_VERSION }}
30
31 - name: Restore
32 run: dotnet restore ${{ env.PROJECT_PATH }}
33
34 - name: Build
35 run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release --no-restore -p:GeneratePackageOnBuild=false -p:ContinuousIntegrationBuild=true
Deleted XFEExtension.NetCore.AutoPath.sln +0 -33
@@ -1,33 +0,0 @@
1 Microsoft Visual Studio Solution File, Format Version 12.00
2 # Visual Studio Version 17
3 VisualStudioVersion = 17.11.34929.205
4 MinimumVisualStudioVersion = 10.0.40219.1
5 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoPath", "XFEExtension.NetCore.AutoPath\XFEExtension.NetCore.AutoPath.csproj", "{5AE91819-3D1B-497A-8910-28182ACE3053}"
6 ProjectSection(ProjectDependencies) = postProject
7 {F1215C28-AB1D-4DE3-8546-31F21E283AA1} = {F1215C28-AB1D-4DE3-8546-31F21E283AA1}
8 EndProjectSection
9 EndProject
10 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XFEExtension.NetCore.AutoPath.Analyzer", "XFEExtension.NetCore.AutoPath.Analyzer\XFEExtension.NetCore.AutoPath.Analyzer.csproj", "{F1215C28-AB1D-4DE3-8546-31F21E283AA1}"
11 EndProject
12 Global
13 GlobalSection(ExtensibilityGlobals) = postSolution
14 SolutionGuid = {90AADC1F-6681-41B3-88DF-16A19E421FF8}
15 EndGlobalSection
16 GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 {5AE91819-3D1B-497A-8910-28182ACE3053}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 {5AE91819-3D1B-497A-8910-28182ACE3053}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 {5AE91819-3D1B-497A-8910-28182ACE3053}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 {5AE91819-3D1B-497A-8910-28182ACE3053}.Release|Any CPU.Build.0 = Release|Any CPU
21 {F1215C28-AB1D-4DE3-8546-31F21E283AA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 {F1215C28-AB1D-4DE3-8546-31F21E283AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 {F1215C28-AB1D-4DE3-8546-31F21E283AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 {F1215C28-AB1D-4DE3-8546-31F21E283AA1}.Release|Any CPU.Build.0 = Release|Any CPU
25 EndGlobalSection
26 GlobalSection(SolutionConfigurationPlatforms) = preSolution
27 Debug|Any CPU = Debug|Any CPU
28 Release|Any CPU = Release|Any CPU
29 EndGlobalSection
30 GlobalSection(SolutionProperties) = preSolution
31 HideSolutionNode = FALSE
32 EndGlobalSection
33 EndGlobal
Added XFEExtension.NetCore.AutoPath.slnx +6 -0
@@ -0,0 +1,6 @@
1 <Solution>
2 <Project Path="XFEExtension.NetCore.AutoPath.Analyzer/XFEExtension.NetCore.AutoPath.Analyzer.csproj" />
3 <Project Path="XFEExtension.NetCore.AutoPath/XFEExtension.NetCore.AutoPath.csproj">
4 <BuildDependency Project="XFEExtension.NetCore.AutoPath.Analyzer/XFEExtension.NetCore.AutoPath.Analyzer.csproj" />
5 </Project>
6 </Solution>
Modified XFEExtension.NetCore.AutoPath/XFEExtension.NetCore.AutoPath.csproj +9 -5
@@ -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 <ImplicitUsings>enable</ImplicitUsings>
6 6 <Nullable>enable</Nullable>
7 7 <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
@@ -11,15 +11,19 @@
11 11 <Copyright>寰宇朽力网络科技有限公司版权所有</Copyright>
12 12 <Description>自动路径创建工具,自动创建不存在的文件夹,对路径统一管理</Description>
13 13 <PackageTags>XFE;path;directory</PackageTags>
14 <PackageReleaseNotes>更新项目类型和元素值,删除属性和元素
14 <PackageReleaseNotes>
15 升级至 .NET 10 并集成自动化 CI/CD 工作流
15 16
16 在`PathPropertyAutoGenerator.cs`文件中,删除了`Options`属性的`ProfileInstanceAttribute`属性列表。在`XFEExtension.NetCore.AutoPath.sln`解决方案文件中,项目类型已从旧的项目系统迁移到新的项目系统。在`XFEExtension.NetCore.AutoPath.csproj`项目文件中,进行了一系列更改,包括更新`Title`元素的值,删除`PackageProjectUrl`和`RepositoryUrl`元素,更新`PackageTags`元素的值,并添加了新的`Version`元素。
17 </PackageReleaseNotes>
17 - 解决方案文件由 .sln 改为 .slnx,适配自动化场景
18 - 项目目标框架从 net8.0 升级为 net10.0
19 - 新增 validate.yml 和 publish-packages.yml,实现自动化构建与包发布
20 - 新增 PUBLISHING.md,完善发布流程文档
21 </PackageReleaseNotes>
18 22 <PackageReadmeFile>README.md</PackageReadmeFile>
19 23 <PackageIcon>logoIcon.png</PackageIcon>
20 24 <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
21 25 <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
22 <Version>1.0.1</Version>
26 <Version>2.0.0</Version>
23 27 </PropertyGroup>
24 28
25 29 <ItemGroup>