-
-
Notifications
You must be signed in to change notification settings - Fork 8
163 lines (155 loc) Β· 5.27 KB
/
Copy pathci.yml
File metadata and controls
163 lines (155 loc) Β· 5.27 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
157
158
159
160
161
162
163
name: CI
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
paths:
- '.github/**'
- 'src/**'
- build.cake
- CodeCoverage.runsettings
- dotnet-tools.json
- global.json
- Key.snk
- NaCl.Core.sln
pull_request:
branches:
- master
paths:
- 'src/**'
- build.cake
- CodeCoverage.runsettings
- dotnet-tools.json
- global.json
- Key.snk
- NaCl.Core.sln
release:
types:
- published
permissions:
contents: read
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Set the build number in MinVer
MINVERBUILDMETADATA: build.${{github.run_number}}
# Set artifacts directory
BUILD_ARTIFACT_PATH: './Artifacts'
jobs:
build:
name: Build on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: 'Checkout'
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
fetch-tags: true
#filter: tree:0
- name: 'Install .NET SDK'
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
- name: '.NET Restore'
run: dotnet tool restore
- name: 'Build Project'
run: dotnet cake --target=Build
- name: 'Run Unit Tests'
run: dotnet cake --target=Test
- name: 'Pack NuGet'
run: dotnet cake --target=Pack
- name: 'Publish Artifacts'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{matrix.os}}
path: |
${{env.BUILD_ARTIFACT_PATH}}
!${{env.BUILD_ARTIFACT_PATH}}/**/In/**/*
coverage:
name: 'Process Coverage'
runs-on: ubuntu-latest
needs: build
steps:
- name: 'Checkout'
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: 'Download All Artifacts'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: ./artifacts
pattern: '*-latest'
merge-multiple: false
- name: 'Install .NET SDK'
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
10.0.x
- name: 'Install ReportGenerator'
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: 'List Coverage Files'
run: find ./artifacts -name "coverage.cobertura.xml" -type f
- name: 'Generate Merged Coverage Report'
run: reportgenerator -reports:"./artifacts/**/coverage.cobertura.xml" -targetdir:${{env.BUILD_ARTIFACT_PATH}}/TestResults/Coverage/Reports "-reporttypes:HtmlInline;HTMLChart;Cobertura"
- name: 'Upload Coverage'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: ${{env.BUILD_ARTIFACT_PATH}}/TestResults/Coverage/Reports/Cobertura.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: 'Publish Coverage Report'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: 'coverage-report'
path: ${{env.BUILD_ARTIFACT_PATH}}
push-to-github-packages:
name: 'Push GitHub Packages'
needs: build
if: github.ref == 'refs/heads/master' || github.event_name == 'release'
environment:
name: 'GitHub Packages'
url: https://github.com/daviddesmet/NaCl.Core/packages
permissions:
packages: write
runs-on: windows-latest
steps:
- name: 'Download Artifact'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: 'windows-latest'
- name: 'NuGet Push'
run: dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/daviddesmet/index.json --skip-duplicate --api-key ${{secrets.GITHUB_TOKEN}}
push-to-nuget:
name: 'Push NuGet Packages'
needs: build
if: github.event_name == 'release'
environment:
name: 'NuGet'
url: https://www.nuget.org/packages/NaCl.Core
permissions:
id-token: write # Required for NuGet Trusted Publishing (OIDC)
runs-on: windows-latest
steps:
- name: 'Download Artifact'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: 'windows-latest'
- name: 'NuGet Login (Trusted Publishing)'
id: nuget-login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
with:
user: idaviddesmet # nuget.org username of the trust policy creator (not the GitHub username)
- name: 'NuGet Push'
run: |
Get-ChildItem -Filter *.nupkg |
Where-Object { !$_.Name.Contains('preview') } |
ForEach-Object { dotnet nuget push $_ --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{steps.nuget-login.outputs.NUGET_API_KEY}} }
shell: pwsh