-
Notifications
You must be signed in to change notification settings - Fork 1.9k
262 lines (224 loc) · 10.5 KB
/
ci.yml
File metadata and controls
262 lines (224 loc) · 10.5 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
name: CI/CD Pipeline
on:
push:
branches:
- main
- develop
tags:
- 'v*'
pull_request:
branches:
- main
- develop
workflow_dispatch:
inputs:
version:
description: 'Package version (e.g., 10.0.0-rc.1)'
required: false
type: string
permissions:
contents: read
packages: write
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore src/FSH.Framework.slnx
- name: Build
run: dotnet build src/FSH.Framework.slnx -c Release --no-restore
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
src/**/bin/Release
src/**/obj/Release
retention-days: 1
test:
name: Test - ${{ matrix.test-project.name }}
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
test-project:
- name: Architecture.Tests
path: src/Tests/Architecture.Tests
- name: Auditing.Tests
path: src/Tests/Auditing.Tests
- name: Generic.Tests
path: src/Tests/Generic.Tests
- name: Identity.Tests
path: src/Tests/Identity.Tests
- name: Multitenancy.Tests
path: src/Tests/Multitenancy.Tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: src
- name: Run ${{ matrix.test-project.name }}
run: dotnet test ${{ matrix.test-project.path }} -c Release --no-build --verbosity normal
publish-dev-containers:
name: Publish Dev Containers
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish API container image
run: |
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-api \
-p:ContainerImageTags='"dev-${{ github.sha }};dev-latest"'
- name: Publish Blazor container image
run: |
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor \
-p:ContainerImageTags='"dev-${{ github.sha }};dev-latest"'
- name: Push containers to GHCR
run: |
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:dev-${{ github.sha }}
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:dev-latest
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:dev-${{ github.sha }}
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:dev-latest
publish-release:
name: Publish Release (NuGet + Containers)
runs-on: ubuntu-latest
needs: test
if: |
(github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch') ||
startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
echo "No version specified and not a tag push"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Restore and Build with version
run: |
dotnet restore src/FSH.Framework.slnx
dotnet build src/FSH.Framework.slnx -c Release --no-restore -p:Version=${{ steps.version.outputs.version }}
- name: Pack BuildingBlocks
run: |
dotnet pack src/BuildingBlocks/Core/Core.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Shared/Shared.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Persistence/Persistence.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Caching/Caching.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Mailing/Mailing.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Jobs/Jobs.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Storage/Storage.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Eventing/Eventing.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Web/Web.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/BuildingBlocks/Blazor.UI/Blazor.UI.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
- name: Pack Modules
run: |
dotnet pack src/Modules/Auditing/Modules.Auditing.Contracts/Modules.Auditing.Contracts.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/Modules/Auditing/Modules.Auditing/Modules.Auditing.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/Modules/Identity/Modules.Identity.Contracts/Modules.Identity.Contracts.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/Modules/Identity/Modules.Identity/Modules.Identity.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/Modules/Multitenancy/Modules.Multitenancy.Contracts/Modules.Multitenancy.Contracts.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
dotnet pack src/Modules/Multitenancy/Modules.Multitenancy/Modules.Multitenancy.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
- name: Pack CLI Tool
run: dotnet pack src/Tools/CLI/FSH.CLI.csproj -c Release --no-build -o ./nupkgs -p:PackageVersion=${{ steps.version.outputs.version }}
- name: Push to NuGet.org
run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push API container
run: |
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-api \
-p:ContainerImageTags='"${{ steps.version.outputs.version }};latest"'
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ steps.version.outputs.version }}
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:latest
- name: Build and push Blazor container
run: |
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
-c Release -r linux-x64 \
-p:PublishProfile=DefaultContainer \
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor \
-p:ContainerImageTags='"${{ steps.version.outputs.version }};latest"'
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ steps.version.outputs.version }}
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:latest