-
-
Notifications
You must be signed in to change notification settings - Fork 1
267 lines (226 loc) · 8.29 KB
/
ci.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: Continuous Integration
on:
push:
branches:
- "master"
tags:
- "*"
pull_request:
types: [synchronize]
schedule:
- cron: "0 0 * * *"
env:
DOTNET_NOLOGO: "true"
CONFIGURATION: Release
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
GITHUB_PACKAGES_FEED_URL: https://nuget.pkg.github.com/cythral/index.json
permissions:
contents: read
id-token: write
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_OSS_ROLE }}
aws-region: us-east-1
- name: Set version
shell: bash
run: echo "VERSION=$(cat version.json | jq -r '.version')" >> $GITHUB_ENV
- name: Display version
run: echo ${{ env.VERSION }}
- name: Check for Stale Version Number
if: ${{ !startsWith(github.ref , 'refs/tags/v') }}
shell: bash
run: |
lastTaggedVersion=$(git describe --abbrev=0 --tags)
lastTaggedVersionSha=$(git rev-list -n 1 $lastTaggedVersion)
if [ "$lastTaggedVersion" = "v$VERSION" ] && [ "$lastTaggedVersionSha" != "${{ github.sha }}" ]; then exit 1; fi
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
global-json-file: "./global.json"
- name: Display .NET Info
run: dotnet --info
- name: Restore
run: dotnet restore
- name: Build
shell: bash
run: dotnet build --no-restore -m -bl:obj/logs/build-${{ matrix.os }}.binlog -p:OutputLayerTemplateFilePath=$(pwd)/Layer.template.yml
env:
UPLOAD_LAYER_TEMPLATE: ${{ matrix.os == 'ubuntu-latest' }}
- name: Test
run: dotnet test --no-build --collect:"XPlat Code coverage"
- name: Upload Coverage
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./obj/Tests/Release/net7.0/coverage.xml
fail_ci_if_error: true
- name: Upload Nugets
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: nugets
path: bin/Packages/${{ env.CONFIGURATION }}
- name: Upload Logs
uses: actions/upload-artifact@v3
with:
name: logs-${{ matrix.os }}
path: obj/logs/
- name: Upload Layer Template
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: layer-template
path: Layer.template.yml
if-no-files-found: ignore
- name: Deploy to Github Packages
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push'
run: dotnet nuget push "bin/Packages/${CONFIGURATION}/*.nupkg" -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate --no-symbols
env:
FEED_TOKEN: ${{ secrets.GH_TOKEN }}
FEED_URL: ${{ env.GITHUB_PACKAGES_FEED_URL }}
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Build Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while building ${{ github.repository }} ${{ env.VERSION }} on ${{ matrix.os }}",
"color": 12720135
}
]
end-to-end-tests:
runs-on: ubuntu-latest
needs: build
concurrency: end-to-end
if: startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'E2E') || github.event_name == 'schedule'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Download NuGets
uses: actions/download-artifact@v3
id: download-nugets
with:
name: nugets
path: bin/Packages/Release
- name: Download Layer Template
uses: actions/download-artifact@v3
id: download-layer-template
with:
name: layer-template
path: ./
- name: Set version
shell: bash
run: echo "VERSION=$(cat version.json | jq -r '.version')" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_OSS_ROLE }}
aws-region: us-east-1
- name: Test
run: dotnet build -t:EndToEndTests -p:PackageBucket=${BUCKET}
env:
BUCKET: ${{ secrets.ARTIFACT_BUCKET }}
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] End-To-End Tests Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while running the end-to-end tests for ${{ github.repository }} ${{ env.VERSION }}",
"color": 12720135
}
]
release:
needs:
- build
- end-to-end-tests
runs-on: ubuntu-latest
environment:
name: Production
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_OSS_ROLE }}
aws-region: us-east-1
- name: Set version
shell: bash
run: echo "VERSION=$(cat version.json | jq -r '.version')" >> $GITHUB_ENV
- name: Download NuGets
uses: actions/download-artifact@v3
id: download-nugets
with:
name: nugets
- name: Download Layer Template
uses: actions/download-artifact@v3
id: download-layer-template
with:
name: layer-template
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Deploy to NuGet
run: dotnet nuget push '${{ steps.download-nugets.outputs.download-path }}/*.nupkg' -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate
env:
FEED_TOKEN: ${{ secrets.NUGET_TOKEN }}
FEED_URL: ${{ env.NUGET_FEED_URL }}
- name: Publish to SAR
run: |
set -eo pipefail
sam publish \
--template ${{ steps.download-layer-template.outputs.download-path }}/Layer.template.yml \
--region us-east-1 \
--semantic-version ${VERSION}
- uses: ncipollo/release-action@v1
with:
artifacts: "${{ steps.download-nugets.outputs.download-path }}/*.nupkg,${{ steps.download-nugets.outputs.download-path }}/*.snupkg"
bodyFile: ".github/releases/v${{ env.VERSION }}.md"
tag: v${{ env.VERSION }}
commit: ${{ github.sha }}
token: ${{ secrets.GH_TOKEN }}
prerelease: ${{ contains(env.VERSION, '-') }}
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Release Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while releasing ${{ github.repository }} ${{ env.VERSION }}",
"color": 12720135
}
]