-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (131 loc) · 4.16 KB
/
Copy pathdotnet.yml
File metadata and controls
155 lines (131 loc) · 4.16 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
name: .NET CI/CD
on:
push:
branches: [ "main", "legacy-1.0", "experimental" ]
tags: [ "v*" ]
pull_request:
branches: [ "main", "legacy-1.0", "experimental" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
configuration: [Debug, Release]
tfm: [net8.0, net10.0]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Determine Version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
elif [[ "${{ github.ref_name }}" == "main" ]]; then
VERSION="2.0.0"
elif [[ "${{ github.ref_name }}" == "legacy-1.0" ]]; then
VERSION="1.0.0"
elif [[ "${{ github.ref_name }}" == "experimental" ]]; then
VERSION="3.0.0-alpha"
else
VERSION="0.0.0-dev"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration ${{ matrix.configuration }} -p:Version=${{ steps.version.outputs.version }}
- name: Test (${{ matrix.tfm }})
run: >
dotnet test
--no-build
--configuration ${{ matrix.configuration }}
--framework ${{ matrix.tfm }}
--verbosity detailed
--logger "trx;LogFileName=test-results.trx"
--logger "console;verbosity=detailed"
--collect:"XPlat Code Coverage"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.configuration }}-${{ matrix.tfm }}
path: "**/*.trx"
- name: Upload coverage reports
if: matrix.configuration == 'Release'
uses: codecov/codecov-action@v3
with:
files: '**/coverage.cobertura.xml'
flags: ${{ matrix.tfm }}
fail_ci_if_error: false
package:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Determine Version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION="2.0.0"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Restore dependencies
run: dotnet restore
- name: Create NuGet Package
run: dotnet pack --configuration Release -p:Version=${{ steps.version.outputs.version }} --output ./packages
- name: Upload Package Artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./packages/*.nupkg
github-release:
needs: package
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine Version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download Package Artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./packages
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md)
echo "$NOTES" > release_notes.md
echo "Release notes extracted for v$VERSION"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
files: ./packages/*.nupkg