Repository navigation
179 lines (148 loc) · 5.27 KB
/
Copy pathbuild.yml
File metadata and controls
179 lines (148 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: .NET build
on:
push:
branches:
- main
paths-ignore:
- docs/**
- .github/workflows/docs.yml
pull_request:
branches:
- main
workflow_dispatch:
jobs:
run-tests:
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_MULTILEVEL_LOOKUP: false
steps:
- uses: actions/checkout@v5
# Install .NET
- uses: actions/setup-dotnet@v5
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
10.0.x
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run local/enable-test-upload@v1
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']);
core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']);
# Test
- name: Run local/dotnet-test@v1
run: >
dotnet test
--results-directory ${{ github.workspace }}/coverage/results
--coverage
--coverage-output-format cobertura
env:
TUNIT_ARTIFACT_RETENTION_DAYS: 5
- uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: ${{ github.workspace }}/coverage/results/*.cobertura.xml
targetdir: ${{ github.workspace }}/coverage/reports
reporttypes: HtmlInline;Cobertura;MarkdownSummaryGithub
verbosity: Verbose
- name: Run local/set-test-summary@v1
shell: pwsh
run: Get-Content '${{ github.workspace }}/coverage/reports/SummaryGithub.md' >> $env:GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.os }}
path: ${{ github.workspace }}/coverage/reports
create-nuget:
runs-on: ubuntu-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_MULTILEVEL_LOOKUP: false
Configuration: Release
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # get all history here, for semantic versioning
# Install the .NET workload
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run local/dotnet-restore@v1
run: dotnet restore
- name: Run local/dotnet-build@v1
working-directory: ${{ github.workspace }}/generators/OneOf.CodeGeneration
run: dotnet build --no-restore -maxCpuCount:1
- name: Run local/dotnet-build@v1
run: dotnet build --no-restore
- name: Run local/get-suffix@v1
id: suffix
run: |
suffix=alpha
if [ ${{ github.event_name }} == push ];
then
suffix=beta;
fi
echo "value=$suffix" >> $GITHUB_OUTPUT
# Pack
- name: Run local/dotnet-pack@v1
run: dotnet pack --output ${{ github.workspace }}/nupkg -property:ComputeSemanticVersion=true -property:SemanticVersionOutputPath=${{ github.workspace }}/versions -property:SemanticVersionIncrement=ReleaseLabel --version-suffix ${{ steps.suffix.outputs.value }}
- uses: actions/upload-artifact@v4
with:
name: NuPkg
if-no-files-found: error
retention-days: 7
path: ${{ github.workspace }}/nupkg
- uses: actions/upload-artifact@v4
with:
name: Versions
if-no-files-found: error
retention-days: 7
path: ${{ github.workspace }}/versions
push:
runs-on: ubuntu-latest
permissions:
actions: write
# enabled GitHub packages writing
packages: write
# enable GitHub OIDC token issuance for this job
id-token: write
needs: [ create-nuget, run-tests ]
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_MULTILEVEL_LOOKUP: false
steps:
- uses: actions/download-artifact@v5
with:
name: NuPkg
path: ${{ github.workspace }}/nupkg
- name: Run local/dotnet-nuget-push-github@v1
id: push-github
working-directory: ${{ github.workspace }}/nupkg
run: dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
- uses: NuGet/login@v1
id: login
with:
user: ${{ github.actor }}
- name: Run local/dotnet-nuget-push-nuget@v1
id: push-nuget
if: ${{ github.event_name == 'push' }}
working-directory: ${{ github.workspace }}/nupkg
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate
# delete-artifact
- uses: GeekyEggo/delete-artifact@v5
if: ${{ steps.push.conclusion == 'success' }}
with:
name: NuPkg