File tree Expand file tree Collapse file tree 1 file changed +49
-13
lines changed
Expand file tree Collapse file tree 1 file changed +49
-13
lines changed Original file line number Diff line number Diff line change 1- name : dotnet-ci
1+ name : Publish NuGet to Releases
22
3- on : [push, pull_request]
3+ # 手动触发工作流,支持输入版本号
4+ on :
5+ workflow_dispatch :
6+ inputs :
7+ version :
8+ description : ' 发布版本号 (例如: 3.7.0)'
9+ required : true
10+ type : string
411
512jobs :
6- build :
13+ build-and-publish :
714 runs-on : windows-latest
8-
915 steps :
10- - uses : actions/checkout@v3
11- - name : Setup .NET SDK
12- uses : actions/setup-dotnet@v2
13- with :
14- dotnet-version : ' 9.0.x'
15- - name : Restore dependencies
16- run : dotnet restore ./src/c#/GeneralUpdate.sln
17- - name : build
18- run : dotnet build ./src/c#/GeneralUpdate.sln -c Release
16+ - name : 检出代码
17+ uses : actions/checkout@v4
18+
19+ - name : 安装.NET SDK
20+ uses : actions/setup-dotnet@v4
21+ with :
22+ dotnet-version : ' 9.0.x'
23+
24+ - name : 恢复依赖
25+ run : dotnet restore ./src/c#/GeneralUpdate.sln
26+
27+ - name : 构建并打包NuGet
28+ run : |
29+ # 定义需要发布的组件列表
30+ $projects = @(
31+ "GeneralUpdate.Bowl",
32+ "GeneralUpdate.ClientCore",
33+ "GeneralUpdate.Core",
34+ "GeneralUpdate.Differential"
35+ )
36+
37+ # 循环打包每个组件,使用统一版本号
38+ foreach ($project in $projects) {
39+ dotnet pack ./src/c#/$project/$project.csproj `
40+ -c Release `
41+ -o ./nupkgs `
42+ -p:Version=${{ github.event.inputs.version }} `
43+ -p:PackageVersion=${{ github.event.inputs.version }}
44+ }
45+ shell : pwsh
46+
47+ - name : 创建GitHub Release并上传NuGet包
48+ uses : softprops/action-gh-release@v2
49+ with :
50+ tag_name : v${{ github.event.inputs.version }}
51+ name : Release v${{ github.event.inputs.version }}
52+ files : ./nupkgs/*.nupkg
53+ env :
54+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments