-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (127 loc) · 5.53 KB
/
ci.yml
File metadata and controls
156 lines (127 loc) · 5.53 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: CI
on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NUGET_XML_DOC_MODE: skip
jobs:
# ──────────────────────────────────────────────
# 单元测试
# ──────────────────────────────────────────────
test:
name: 单元测试
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_project:
- Tests/Mud.HttpUtils.Generator.Tests/Mud.HttpUtils.Generator.Tests.csproj
- Tests/Mud.HttpUtils.Client.Tests/Mud.HttpUtils.Client.Tests.csproj
- Tests/Mud.HttpUtils.Resilience.Tests/Mud.HttpUtils.Resilience.Tests.csproj
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore ${{ matrix.test_project }}
- name: Build
run: dotnet build ${{ matrix.test_project }} --no-restore --configuration Release
- name: Run tests
run: dotnet test ${{ matrix.test_project }} --no-build --configuration Release --logger "console;verbosity=detailed"
# ──────────────────────────────────────────────
# Demo 项目构建
# ──────────────────────────────────────────────
build-demos:
name: Demo 构建
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
demo_project:
- Demos/HttpClientApiDemo/HttpClientApiDemo.csproj
- Demos/HttpClientApiPublicDemo/HttpClientApiPublicDemo.csproj
- Demos/HttpClientDemo/HttpClientDemo.csproj
- Demos/ResilienceDemo/ResilienceDemo.csproj
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore ${{ matrix.demo_project }}
- name: Build
run: dotnet build ${{ matrix.demo_project }} --no-restore --configuration Release
# ──────────────────────────────────────────────
# 主项目及子包构建与发布
# ──────────────────────────────────────────────
build-and-pack:
name: 构建与发布
runs-on: ubuntu-latest
needs: [ test ]
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore Mud.HttpUtils.slnx
- name: Build solution
run: dotnet build Mud.HttpUtils.slnx --no-restore --configuration Release
- name: Pack Abstractions
run: dotnet pack Mud.HttpUtils.Abstractions/Mud.HttpUtils.Abstractions.csproj --no-build --configuration Release --output artifacts
- name: Pack Attributes
run: dotnet pack Mud.HttpUtils.Attributes/Mud.HttpUtils.Attributes.csproj --no-build --configuration Release --output artifacts
- name: Pack Client
run: dotnet pack Mud.HttpUtils.Client/Mud.HttpUtils.Client.csproj --no-build --configuration Release --output artifacts
- name: Pack Resilience
run: dotnet pack Mud.HttpUtils.Resilience/Mud.HttpUtils.Resilience.csproj --no-build --configuration Release --output artifacts
- name: Pack Mud.HttpUtils (meta package)
run: dotnet pack Mud.HttpUtils/Mud.HttpUtils.csproj --no-build --configuration Release --output artifacts
- name: Pack Generator
run: dotnet pack Mud.HttpUtils.Generator/Mud.HttpUtils.Generator.csproj --no-build --configuration Release --output artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*.nupkg
retention-days: 30
# ──────────────────────────────────────────────
# 发布到 NuGet(仅 tag 触发)
# ──────────────────────────────────────────────
publish-nuget:
name: 发布到 NuGet
runs-on: ubuntu-latest
needs: [ build-and-pack ]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Publish to NuGet
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate