-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (101 loc) · 2.97 KB
/
build-test.yaml
File metadata and controls
106 lines (101 loc) · 2.97 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
name: Build and Test
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'
types: [assigned, opened, synchronize, reopened]
env:
BUILD_CONFIGURATION: Debug
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
name: .NET Build
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
- name: Set BUILD_CONFIGURATION
if: startsWith(github.ref, 'refs/tags/')
run: echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration ${{env.BUILD_CONFIGURATION}} --no-restore
- name: Test
run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory test-results --no-build
- name: Build packages
run: dotnet pack --configuration ${{env.BUILD_CONFIGURATION}} --output ./artifacts --no-build
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# directory: ./test-results
# files: '*.cobertura.xml'
#
- name: Upload artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v5
with:
name: artifacts
path: ./artifacts
- name: Upload test results
uses: actions/upload-artifact@v5
with:
name: test-results-${{ matrix.os }}
path: ./test-results
if: ${{ always() }} # Always run this step even on failure
deploy-testing:
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment: testing
needs: build
name: Deploy Testing
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: artifacts
path: ./artifacts
- name: Push packages
run: dotnet nuget push -s ${{vars.MYGET_URL}} -k ${{secrets.MYGET_API_KEY}} ./artifacts/*.nupkg
deploy-release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: production
needs:
- build
- deploy-testing
name: Deploy Production
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: artifacts
path: ./artifacts
- name: Push packages
run: dotnet nuget push -s ${{vars.NUGET_URL}} -k ${{secrets.NUGET_API_KEY}} ./artifacts/*.nupkg