-
Notifications
You must be signed in to change notification settings - Fork 39
70 lines (56 loc) · 1.92 KB
/
buildAndDeploy.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
name: Build and Test
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
env:
solutionName: UriTemplates.sln
outputFolder: ./buildArtifacts
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore ${{ env.solutionName }}
- name: Check formatting
run: dotnet format --verify-no-changes --verbosity diagnostic
- name: Build
run: dotnet build ${{ env.solutionName }} --no-restore -c Release
- name: Test
run: dotnet test ${{ env.solutionName }} --no-build --verbosity normal -c Release /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=opencover
- name: Pack
run: dotnet pack ${{ env.solutionName }} /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output ${{ env.outputFolder }} -c Release
- name: Upload Nuget Package and Symbols
uses: actions/upload-artifact@v3
with:
name: drop
path: |
${{ env.outputFolder }}/*.nupkg
${{ env.outputFolder }}/*.snupkg
deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
environment:
name: production
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: drop
- name: Nuget push
run: dotnet nuget push "*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k ${{ secrets.PUBLISH_GH_TOKEN }}