forked from FritzAndFriends/BlazorWebFormsComponents
-
Notifications
You must be signed in to change notification settings - Fork 3
287 lines (238 loc) · 9.43 KB
/
release.yml
File metadata and controls
287 lines (238 loc) · 9.43 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: Release
on:
release:
types: [published]
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: fritzandfriends/blazorwebformscomponents/serversidesamples
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
# Ensure version has at least 3 parts for SemVer (e.g., 0.18 → 0.18.0)
if [[ "$VERSION" != *.*.* ]]; then
VERSION="$VERSION.0"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Extracted version: $VERSION"
- name: Remove NBGV to prevent version conflicts
run: |
sed -i '/<PackageReference Include="Nerdbank.GitVersioning"/,/<\/PackageReference>/d' Directory.Build.props
echo "Directory.Build.props after NBGV removal:"
cat Directory.Build.props
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: |
dotnet restore src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj
dotnet restore src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj
dotnet restore samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj
- name: Build library
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore -p:Version=${{ env.VERSION }}
- name: Build test project
run: dotnet build src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --no-restore -p:Version=${{ env.VERSION }}
- name: Build server-side sample
run: dotnet build samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj --configuration Release --no-restore -p:Version=${{ env.VERSION }}
- name: Run tests
run: dotnet test src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --results-directory src/BlazorWebFormsComponents.Test/TestResults
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: src/BlazorWebFormsComponents.Test/TestResults/*.trx
- name: Publish test results
uses: dorny/test-reporter@v2
if: always()
with:
name: Unit Test Results
path: src/BlazorWebFormsComponents.Test/TestResults/*.trx
reporter: dotnet-trx
fail-on-error: true
publish-nuget:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
if [[ "$VERSION" != *.*.* ]]; then
VERSION="$VERSION.0"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Extracted version: $VERSION"
- name: Remove NBGV to prevent version conflicts
run: |
sed -i '/<PackageReference Include="Nerdbank.GitVersioning"/,/<\/PackageReference>/d' Directory.Build.props
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj
- name: Build
run: dotnet build src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-restore -p:Version=${{ env.VERSION }}
- name: Run tests
run: |
dotnet restore src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj
dotnet test src/BlazorWebFormsComponents.Test/BlazorWebFormsComponents.Test.csproj --configuration Release --verbosity normal
- name: Pack
run: dotnet pack src/BlazorWebFormsComponents/BlazorWebFormsComponents.csproj --configuration Release --no-build --output ./nupkg -p:PackageVersion=${{ env.VERSION }} -p:Version=${{ env.VERSION }}
- name: Push to GitHub Packages
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
- name: Push to nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
if: env.NUGET_API_KEY != ''
run: dotnet nuget push ./nupkg/*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ env.NUGET_API_KEY }} --skip-duplicate
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ./nupkg/*.nupkg
- name: Attach NuGet package to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./nupkg/*.nupkg --clobber
deploy-docker:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
if [[ "$VERSION" != *.*.* ]]; then
VERSION="$VERSION.0"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Extracted version: $VERSION"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: samples/AfterBlazorServerSide/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
- name: Trigger Azure App Service deployment
env:
AZURE_WEBAPP_WEBHOOK_URL: ${{ secrets.AZURE_WEBAPP_WEBHOOK_URL }}
if: env.AZURE_WEBAPP_WEBHOOK_URL != ''
run: |
curl -sf -X POST "${{ env.AZURE_WEBAPP_WEBHOOK_URL }}" \
-H "Content-Length: 0" \
--max-time 60 \
|| echo "::warning::Azure webhook call failed — the App Service may need to be updated manually"
deploy-docs:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build mkdocs Docker image
run: |
docker build -t mkdocs -f ./docs/Dockerfile ./
- name: Build docs
run: |
docker run --rm -v "$(pwd):/docs" mkdocs build --strict
sudo chown -R $(id -u):$(id -g) ./site
- name: Check GitHub Pages status
uses: crazy-max/ghaction-github-status@v1
with:
pages_threshold: major_outage
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v2.1.1
with:
target_branch: gh-pages
build_dir: site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-demos:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
if [[ "$VERSION" != *.*.* ]]; then
VERSION="$VERSION.0"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "Extracted version: $VERSION"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Publish Server-Side Demo
run: |
dotnet restore samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj
dotnet publish samples/AfterBlazorServerSide/AfterBlazorServerSide.csproj --configuration Release --output ./publish/server-side
- name: Upload Server-Side Demo artifact
uses: actions/upload-artifact@v4
with:
name: demo-server-side-${{ env.VERSION }}
path: ./publish/server-side
- name: Create demo archives for release
run: |
cd ./publish
tar -czf server-side-demo-${{ env.VERSION }}.tar.gz -C server-side .
- name: Attach demo artifacts to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} \
./publish/server-side-demo-${{ env.VERSION }}.tar.gz \
--clobber