-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (117 loc) · 3.44 KB
/
build.yml
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
name: Build
on:
push:
branches:
- master
- develop
- feat/**
paths:
- .github/workflows/build.yml
- global.json
- nuget.config
- Shimakaze.Sdk.sln
- Directory.Build.props
- Directory.Build.targets
- "app/**/*"
- "lib/**/*"
- "sdk/**/*"
- "test/**/*"
pull_request:
branches:
- master
- develop
paths:
- .github/workflows/build.yml
- global.json
- nuget.config
- Shimakaze.Sdk.sln
- Directory.Build.props
- Directory.Build.targets
- "app/**/*"
- "lib/**/*"
- "sdk/**/*"
- "test/**/*"
jobs:
build-dotnet:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
name: .Net 构建 ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: 签出仓库
uses: actions/checkout@v4
with:
lfs: true
- name: 配置 Nuget 缓存
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-cache
restore-keys: |
nuget-cache
- name: 配置 .Net 环境
uses: actions/setup-dotnet@v4.0.0
with:
global-json-file: ./global.json
- name: 还原
shell: pwsh
run: dotnet restore
- name: 构建
shell: pwsh
run: dotnet build --configuration Release --no-restore
- name: 测试
shell: pwsh
run: dotnet test --configuration Release --no-build
- name: 打包
shell: pwsh
run: dotnet pack --configuration Release --no-restore --no-build --include-symbols --include-source
- name: 生成校验和
shell: pwsh
env:
matrix_os : ${{ matrix.os }}
run: |
Write-Output "### Build Success :rocket: $env:matrix_os" >> $env:GITHUB_STEP_SUMMARY
Write-Output "|File|SHA256|" >> $env:GITHUB_STEP_SUMMARY
Write-Output "|:-|:-:|" >> $env:GITHUB_STEP_SUMMARY
Get-ChildItem nupkg | ForEach-Object {
Write-Output "|$($PSItem.Name)|$((Get-FileHash $PSItem -Algorithm SHA256).Hash)|" >> $env:GITHUB_STEP_SUMMARY
}
- name: 收集 Nuget 包
uses: actions/upload-artifact@v3.1.3
with:
name: nuget-packages-${{ matrix.os }}
path: |
nupkg/*
retention-days: 3
- name: 推送 Nuget 包
shell: pwsh
continue-on-error: true
if: matrix.os == 'windows-latest' && github.repository == 'ShimakazeProject/Shimakaze.Sdk' && github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master'
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: |
Set-Location nupkg
dotnet nuget push *.nupkg -s nuget -k $env:NUGET_TOKEN --skip-duplicate
Set-Location ..
- name: 收集测试覆盖率
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true
file: ./coverage/lcov.info
coverage-upload:
needs: build-dotnet
if: ${{ always() }}
name: 上传测试覆盖率
runs-on: ubuntu-latest
steps:
- name: 上传测试覆盖率
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "run-ubuntu-latest,run-windows-latest,run-macos-latest"