-
Notifications
You must be signed in to change notification settings - Fork 62
58 lines (50 loc) · 1.79 KB
/
dotnet-ci.yaml
File metadata and controls
58 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Publish NuGet to releases
on:
workflow_dispatch:
inputs:
version:
description: '发布版本号 (例如: 1.0.0)'
required: true
type: string
jobs:
build-and-publish:
runs-on: windows-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 安装.NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x' # 支持GeneralUpdate.Drivelution的.NET 10目标框架
- name: 恢复依赖
run: dotnet restore ./src/c#/GeneralUpdate.sln # 使用解决方案统一恢复
- name: 构建项目(确保生成DLL)
run: dotnet build ./src/c#/GeneralUpdate.sln -c Release --no-restore # 显式构建,避免重复恢复
- name: 打包NuGet包
run: |
$projects = @(
"GeneralUpdate.Bowl",
"GeneralUpdate.ClientCore",
"GeneralUpdate.Common",
"GeneralUpdate.Core",
"GeneralUpdate.Differential",
"GeneralUpdate.Drivelution",
"GeneralUpdate.Extension"
)
foreach ($project in $projects) {
dotnet pack ./src/c#/$project/$project.csproj `
-c Release `
-o ./nupkgs `
-p:Version=${{ github.event.inputs.version }} `
-p:PackageVersion=${{ github.event.inputs.version }} `
--no-build # 避免重复构建,使用已生成的文件
}
shell: pwsh
- name: 创建GitHub Release并上传NuGet包
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ github.event.inputs.version }}
name: Release v${{ github.event.inputs.version }}
files: ./nupkgs/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}