-
Notifications
You must be signed in to change notification settings - Fork 17
290 lines (246 loc) · 10.1 KB
/
Copy pathmain.yaml
File metadata and controls
290 lines (246 loc) · 10.1 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
288
289
290
name: Build, Test and Release
on:
merge_group:
pull_request:
branches:
- main
push:
branches:
- feat/dotnet-standard2.0
tags:
- 'v*'
concurrency:
# Prevent duplicate publishes for the same ref (tag/branch) running concurrently
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
env:
# Suppress .NET first-time experience and telemetry
# Source: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
framework: [ net6.0, net8.0, net9.0 ]
include:
# .NET4.8 requires Windows
- os: windows-latest
framework: net48
# .NET Core 3.1 is EOL, and is having libssl issues on Linux
# But we still want to test it - no support is promised
# It should still use .NET Standard 2.0
- os: windows-latest
framework: netcoreapp3.1
# Test current LTS against Mac and Windows too
- os: windows-latest
framework: net8.0
- os: macos-latest
framework: net8.0
name: Test ${{ matrix.framework }} on ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET versions
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
9.0.x
- name: Cache NuGet packages
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OpenFga.Sdk.sln --verbosity minimal
- name: Build SDK and test project
run: dotnet build --no-restore --configuration Release --verbosity minimal
- name: Run tests for specific framework
run: dotnet test src/OpenFga.Sdk.Test/OpenFga.Sdk.Test.csproj --no-build --configuration Release --framework ${{ matrix.framework }} --verbosity normal --logger trx --results-directory TestResults/ --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: test-results-${{ matrix.os }}-${{ matrix.framework }}
path: TestResults/
retention-days: 7
- name: Upload coverage to Codecov
# Only upload coverage from one matrix job to avoid conflicts
if: matrix.os == 'ubuntu-latest' && matrix.framework == 'net8.0'
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: openfga/dotnet-sdk
build-verification:
runs-on: ubuntu-latest
name: Build Verification
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET versions
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore OpenFga.Sdk.sln --verbosity minimal
- name: Build SDK for all target frameworks
run: dotnet build src/OpenFga.Sdk/OpenFga.Sdk.csproj --no-restore --configuration Release --verbosity normal
- name: Verify all framework outputs exist
run: |
echo "Checking build outputs..."
ls -la src/OpenFga.Sdk/bin/Release/
# Verify each framework was built successfully
frameworks=("netstandard2.0" "net48" "net8.0" "net9.0")
for framework in "${frameworks[@]}"; do
if [ -d "src/OpenFga.Sdk/bin/Release/${framework}" ]; then
echo "✅ ${framework} build output found"
ls -la "src/OpenFga.Sdk/bin/Release/${framework}/"
else
echo "❌ ${framework} build output missing"
exit 1
fi
done
- name: Upload SDK artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdk-build-outputs
path: src/OpenFga.Sdk/bin/Release/
retention-days: 7
pack:
runs-on: ubuntu-latest
name: Pack NuGet
needs: [test, build-verification]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore OpenFga.Sdk.sln --verbosity minimal
- name: Build
run: dotnet build src/OpenFga.Sdk/OpenFga.Sdk.csproj --no-restore --configuration Release -p:ContinuousIntegrationBuild=true --verbosity minimal
- name: Pack
# Produce both the primary NuGet package (.nupkg) and the symbol package (.snupkg)
run: |
dotnet pack src/OpenFga.Sdk/OpenFga.Sdk.csproj \
--no-build \
--configuration Release \
-p:ContinuousIntegrationBuild=true \
-p:IncludeSymbols=true \
-p:SymbolPackageFormat=snupkg \
-p:DebugType=portable \
-o artifact-pack
- name: List produced packages
run: ls -la artifact-pack
- name: Upload NuGet package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: nuget-package
path: |
artifact-pack/*.nupkg
artifact-pack/*.snupkg
retention-days: 7
verify-version:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
needs: [pack]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
- name: Verify versions match
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
MANIFEST_VERSION=$(jq -r '.["."]' .release-please-manifest.json)
CSPROJ_VERSION=$(grep 'x-release-please-version' src/OpenFga.Sdk/OpenFga.Sdk.csproj | grep -oP '>\K[^<]+')
echo "Tag: $TAG_VERSION | Manifest: $MANIFEST_VERSION | .csproj: $CSPROJ_VERSION"
if [[ "$TAG_VERSION" != "$MANIFEST_VERSION" ]]; then
echo "ERROR: Tag version does not match manifest version"
exit 1
fi
if [[ "$CSPROJ_VERSION" != "$MANIFEST_VERSION" ]]; then
echo "ERROR: .csproj version does not match manifest version"
exit 1
fi
echo "All versions verified: $TAG_VERSION"
publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
needs: [pack, verify-version]
permissions:
id-token: write # For OIDC authentication with NuGet.org
packages: write # For publishing to the GitHub Nuget Registry
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
9.0.x
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
- name: Download package artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v4.1.8
with:
name: nuget-package
path: ./dist
- name: NuGet login (OIDC)
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
run: |
echo "Publishing primary package to NuGet (.nupkg)...";
dotnet nuget push dist/OpenFga.Sdk.*.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json
echo "Publishing symbol package to NuGet (.snupkg)...";
dotnet nuget push dist/OpenFga.Sdk.*.snupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json || echo "No symbol package found or already published."
- name: Publish to GitHub Package Registry
continue-on-error: true
run: |
echo "Publishing primary package to GitHub Package Registry (.nupkg)...";
dotnet nuget push dist/OpenFga.Sdk.*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --source https://nuget.pkg.github.com/openfga/index.json
echo "Publishing symbol package to GitHub Package Registry (.snupkg)...";
dotnet nuget push dist/OpenFga.Sdk.*.snupkg --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --source https://nuget.pkg.github.com/openfga/index.json || echo "No symbol package found or already published."
undraft-release:
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-test')
needs: [publish]
permissions:
contents: write
uses: openfga/sdk-generator/.github/workflows/undraft-release.yml@main