-
Notifications
You must be signed in to change notification settings - Fork 0
246 lines (202 loc) · 7.32 KB
/
ci.yml
File metadata and controls
246 lines (202 loc) · 7.32 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
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
name: CI/CD Pipeline
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0.x']
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for better analysis
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration Release
- name: Run tests
run: dotnet test --no-build --configuration Release --verbosity normal --logger trx --results-directory TestResults
- name: Publish test results
uses: dorny/test-reporter@v2
if: success() || failure()
with:
name: .NET Test Results
path: TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: TestResults/
retention-days: 30
code-quality:
name: Code Quality Analysis
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration Release
- name: Run code analysis
run: dotnet build --verbosity normal --configuration Release /p:TreatWarningsAsErrors=true
package:
name: Create NuGet Package
runs-on: ubuntu-latest
needs: [build-and-test, code-quality, tag-version]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2
with:
useConfigFile: true
- name: Restore dependencies
run: dotnet restore
- name: Pack NuGet packages
run: |
VERSION="${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "Creating NuGet packages with version: $VERSION"
dotnet pack Iso20022Library.Domain/Iso20022Library.Domain.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
dotnet pack Iso20022Library.Messages/Iso20022Library.Messages.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
dotnet pack Iso20022Library.Infrastructure/Iso20022Library.Infrastructure.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
dotnet pack Iso20022Library.Application/Iso20022Library.Application.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages-v${{ steps.gitversion.outputs.majorMinorPatch }}
path: ./packages/*.nupkg
retention-days: 90
security-scan:
name: Security Scan
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Run vulnerability scan
run: dotnet list package --vulnerable --include-transitive
continue-on-error: true
- name: Install and run security scan (optional)
run: |
# Try to install and run security-scan, but don't fail if it doesn't work
if dotnet tool install --global security-scan --version 5.6.7; then
echo "Security scan tool installed successfully"
if security-scan Iso20022Library.sln; then
echo "Security scan completed successfully"
else
echo "Security scan failed, but continuing..."
fi
else
echo "Failed to install security scan tool, skipping..."
fi
continue-on-error: true
- name: Run built-in code analysis
run: dotnet build --configuration Release --verbosity minimal /p:RunAnalyzersDuringBuild=true /p:TreatWarningsAsErrors=false
continue-on-error: true
tag-version:
name: Create Version Tag
runs-on: ubuntu-latest
needs: [build-and-test, code-quality]
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'
- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2
with:
useConfigFile: true
- name: Create version tag
run: |
VERSION="${{ steps.gitversion.outputs.majorMinorPatch }}"
TAG_NAME="v$VERSION"
# Check if tag already exists
if git tag -l "$TAG_NAME" | grep -q "$TAG_NAME"; then
echo "Tag $TAG_NAME already exists, skipping..."
else
echo "Creating tag: $TAG_NAME"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "$TAG_NAME" -m "Release version $VERSION"
git push origin "$TAG_NAME"
echo "Created and pushed tag: $TAG_NAME"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.gitversion.outputs.majorMinorPatch }}
name: Release ${{ steps.gitversion.outputs.majorMinorPatch }}
body: |
## 🚀 Release ${{ steps.gitversion.outputs.majorMinorPatch }}
**Build:** ${{ github.sha }}
**Branch:** ${{ github.ref_name }}
### 📦 NuGet Packages
- Iso20022Library.Domain
- Iso20022Library.Messages
- Iso20022Library.Infrastructure
- Iso20022Library.Application
### 🧪 Tests
All ${{ github.event.head_commit.message }} tests passed successfully.
---
*Auto-generated release from CI/CD pipeline*
draft: false
prerelease: false
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}