-
-
Notifications
You must be signed in to change notification settings - Fork 0
453 lines (390 loc) · 15.5 KB
/
Copy pathpublish.yml
File metadata and controls
453 lines (390 loc) · 15.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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
name: Publish
on:
release:
types: [published]
permissions:
packages: write
contents: write
actions: write
env:
DOTNET_VERSION: '10.0.x'
ARTIFACT_OUTPUT: '${{ github.workspace }}/artifacts'
jobs:
build-native:
name: Build native framework-system rust (${{ matrix.os }} ${{ matrix.platform }})
strategy:
fail-fast: true
matrix:
include:
- os: Windows
runsOn: windows-latest
platform: win-x64
artifactPath: framework-system-ffi-extensions/target/release/framework_lib_ffi.dll
- os: Windows
runsOn: windows-11-arm
platform: win-arm64
artifactPath: framework-system-ffi-extensions/target/release/framework_lib_ffi.dll
- os: Linux
runsOn: ubuntu-latest
platform: linux-x64
artifactPath: framework-system-ffi-extensions/target/release/libframework_lib_ffi.so
- os: Linux
runsOn: ubuntu-24.04-arm
platform: linux-arm64
artifactPath: framework-system-ffi-extensions/target/release/libframework_lib_ffi.so
runs-on: ${{ matrix.runsOn }}
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Setup Rust with Cache
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-workspaces: |
framework-system-ffi-extensions -> target
- name: Install with Cache Linux Framework dependencies (libudev-dev)
uses: awalsh128/cache-apt-pkgs-action@v1
if: runner.os == 'Linux'
with:
packages: libudev-dev
version: ${{ runner.os }}-${{ runner.arch }}
- name: Build native library
run: cargo build --manifest-path framework-system-ffi-extensions/Cargo.toml -p framework_lib_ffi --release
- name: Upload native artifact
uses: actions/upload-artifact@v7
with:
name: framework-dotnet-native-${{ matrix.platform }}
path: ${{ matrix.artifactPath }}
if-no-files-found: error
- name: Upload generated bindings artifact
if: matrix.platform == 'win-x64'
uses: actions/upload-artifact@v7
with:
name: framework-dotnet-bindings
path: framework-system-ffi-extensions/csharp/NativeMethods.g.cs
if-no-files-found: error
- name: "Cancel if failure"
if: ${{ failure() }}
uses: potiuk/cancel-workflow-runs@master
with:
cancelMode: self
cancelFutureDuplicates: false
selfPreservation: false
token: ${{ secrets.GITHUB_TOKEN }}
pack:
name: Pack and publish NuGet
needs: build-native
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Set version environment variable
run: |
$tagName = "${{ github.event.release.tag_name }}"
# Check if the tag starts with 'v' and remove it
if ($tagName.StartsWith("v")) {
$version = $tagName.Substring(1)
} else {
$version = $tagName
}
Write-Host "The original tag name was: $tagName"
Write-Host "The processed version is: $version"
# Set the environment variable for subsequent steps in the same job
echo "version=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh # Explicitly use PowerShell Core (default on windows-latest for 'run')
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download generated bindings artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-bindings
path: framework-system-ffi-extensions/csharp
- name: Download win-x64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-win-x64
path: artifacts/win-x64
- name: Download win-arm64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-win-arm64
path: artifacts/win-arm64
- name: Download linux-x64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-linux-x64
path: artifacts/linux-x64
- name: Download linux-arm64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-linux-arm64
path: artifacts/linux-arm64
- name: Cache and restore nugets
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-${{ runner.arch }}-nuget-${{ github.workflow }}-${{ github.ref }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-nuget-${{ github.workflow }}-${{ github.ref }}-
- name: Restore dependencies
run: dotnet restore -v normal --locked-mode -p:Version=${{ env.version }} -p:InformationalVersion=${{ env.version }}+${{ github.sha }} -p:DebugSymbols=true -p:DebugType=portable
- name: Build
run: >-
dotnet build framework-dotnet/framework-dotnet.csproj
-v normal
--configuration Release
--no-restore
-p:Version=${{ env.version }}
-p:InformationalVersion=${{ env.version }}+${{ github.sha }}
-p:DebugSymbols=true
-p:DebugType=portable
-p:ContinuousIntegrationBuild=true
-p:SkipRustBuild=true
-p:FrameworkDotnetWindowsNativeLibraryPath=${{ github.workspace }}\artifacts\win-x64\framework_lib_ffi.dll
-p:FrameworkDotnetWindowsArm64NativeLibraryPath=${{ github.workspace }}\artifacts\win-arm64\framework_lib_ffi.dll
-p:FrameworkDotnetLinuxNativeLibraryPath=${{ github.workspace }}\artifacts\linux-x64\libframework_lib_ffi.so
-p:FrameworkDotnetLinuxArm64NativeLibraryPath=${{ github.workspace }}\artifacts\linux-arm64\libframework_lib_ffi.so
- name: Pack NuGet package
run: >-
dotnet pack framework-dotnet/framework-dotnet.csproj
-v normal
--configuration Release
--no-restore
--no-build
--output ${{ env.ARTIFACT_OUTPUT }}
-p:Version=${{ env.version }}
-p:InformationalVersion=${{ env.version }}+${{ github.sha }}
-p:DebugSymbols=true
-p:DebugType=portable
-p:ContinuousIntegrationBuild=true
-p:SkipRustBuild=true
-p:FrameworkDotnetWindowsNativeLibraryPath=${{ github.workspace }}\artifacts\win-x64\framework_lib_ffi.dll
-p:FrameworkDotnetWindowsArm64NativeLibraryPath=${{ github.workspace }}\artifacts\win-arm64\framework_lib_ffi.dll
-p:FrameworkDotnetLinuxNativeLibraryPath=${{ github.workspace }}\artifacts\linux-x64\libframework_lib_ffi.so
-p:FrameworkDotnetLinuxArm64NativeLibraryPath=${{ github.workspace }}\artifacts\linux-arm64\libframework_lib_ffi.so
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v7
with:
name: framework-dotnet-nuget
path: ${{ env.ARTIFACT_OUTPUT }}
if-no-files-found: error
- name: Attach release assets
uses: softprops/action-gh-release@v3
with:
files: |
${{ env.ARTIFACT_OUTPUT }}/*.nupkg
${{ env.ARTIFACT_OUTPUT }}/*.snupkg
fail_on_unmatched_files: false
- name: Push nugets to Github
run: |
nuget sources Add -Name "GitHub" -Source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -Username "${{ github.actor }}" -Password "${{ secrets.GITHUB_TOKEN }}"
nuget push "${{ env.ARTIFACT_OUTPUT }}/**/*.nupkg" -Source "GitHub"
nuget push "${{ env.ARTIFACT_OUTPUT }}/**/*.nupkg" -Source https://api.nuget.org/v3/index.json -NoSymbols -SkipDuplicate -ApiKey ${{ secrets.NUGET_KEY }}
sample-app:
name: Package sample app (${{ matrix.os }} ${{ matrix.platform }})
needs: build-native
strategy:
fail-fast: true
matrix:
include:
- os: Windows
runsOn: windows-latest
platform: win-x64
- os: Windows
runsOn: windows-11-arm
platform: win-arm64
- os: Linux
runsOn: ubuntu-latest
platform: linux-x64
- os: Linux
runsOn: ubuntu-24.04-arm
platform: linux-arm64
runs-on: ${{ matrix.runsOn }}
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Set version environment variable
run: |
$tagName = "${{ github.event.release.tag_name }}"
if ($tagName.StartsWith("v")) {
$version = $tagName.Substring(1)
} else {
$version = $tagName
}
Write-Host "The original tag name was: $tagName"
Write-Host "The processed version is: $version"
echo "version=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download generated bindings artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-bindings
path: framework-system-ffi-extensions/csharp
- name: Download win-x64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-win-x64
path: artifacts/win-x64
- name: Download win-arm64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-win-arm64
path: artifacts/win-arm64
- name: Download linux-x64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-linux-x64
path: artifacts/linux-x64
- name: Download linux-arm64 native artifact
uses: actions/download-artifact@v8
with:
name: framework-dotnet-native-linux-arm64
path: artifacts/linux-arm64
- name: Cache and restore nugets
uses: actions/cache@v6
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-${{ runner.arch }}-nuget-${{ github.workflow }}-${{ github.ref }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-nuget-${{ github.workflow }}-${{ github.ref }}-
- name: Restore dependencies for library
run: dotnet restore -v normal --locked-mode -p:Version=${{ env.version }} -p:InformationalVersion=${{ env.version }}+${{ github.sha }} -p:DebugSymbols=true -p:DebugType=portable
- name: Restore dependencies for sample app
run: dotnet restore framework-dotnet-cli-test/framework-dotnet-cli-test.csproj -v normal -p:Version=${{ env.version }} -p:InformationalVersion=${{ env.version }}+${{ github.sha }} -p:DebugSymbols=true -p:DebugType=portable
- name: Build library
run: >-
dotnet build framework-dotnet/framework-dotnet.csproj
-v normal
--configuration Release
--no-restore
-p:Version=${{ env.version }}
-p:InformationalVersion=${{ env.version }}+${{ github.sha }}
-p:DebugSymbols=true
-p:DebugType=portable
-p:ContinuousIntegrationBuild=true
-p:SkipRustBuild=true
-p:FrameworkDotnetWindowsNativeLibraryPath=${{ github.workspace }}/artifacts/win-x64/framework_lib_ffi.dll
-p:FrameworkDotnetWindowsArm64NativeLibraryPath=${{ github.workspace }}/artifacts/win-arm64/framework_lib_ffi.dll
-p:FrameworkDotnetLinuxNativeLibraryPath=${{ github.workspace }}/artifacts/linux-x64/libframework_lib_ffi.so
-p:FrameworkDotnetLinuxArm64NativeLibraryPath=${{ github.workspace }}/artifacts/linux-arm64/libframework_lib_ffi.so
- name: Build sample app
run: >-
dotnet build framework-dotnet-cli-test/framework-dotnet-cli-test.csproj
-v normal
--configuration Release
--no-restore
-p:Version=${{ env.version }}
-p:InformationalVersion=${{ env.version }}+${{ github.sha }}
-p:DebugSymbols=true
-p:DebugType=portable
-p:ContinuousIntegrationBuild=true
-p:SkipRustBuild=true
- name: Publish sample app
run: >-
dotnet publish framework-dotnet-cli-test/framework-dotnet-cli-test.csproj
-v normal
--configuration Release
--no-restore
--no-build
--output ${{ github.workspace }}/artifacts/sample-app/${{ matrix.platform }}
-p:Version=${{ env.version }}
-p:InformationalVersion=${{ env.version }}+${{ github.sha }}
-p:DebugSymbols=true
-p:DebugType=portable
-p:ContinuousIntegrationBuild=true
-p:SkipRustBuild=true
- name: Archive sample app
run: |
$sampleAppPath = "${{ github.workspace }}/artifacts/sample-app/${{ matrix.platform }}"
$archivePath = "${{ env.ARTIFACT_OUTPUT }}/framework-dotnet-sample-app-${{ matrix.platform }}.zip"
if (Test-Path $archivePath) {
Remove-Item $archivePath -Force
}
Compress-Archive -Path "$sampleAppPath/*" -DestinationPath $archivePath
shell: pwsh
- name: Upload sample app artifact
uses: actions/upload-artifact@v7
with:
name: framework-dotnet-sample-app-${{ matrix.platform }}
path: ${{ env.ARTIFACT_OUTPUT }}/framework-dotnet-sample-app-${{ matrix.platform }}.zip
if-no-files-found: error
- name: Attach sample app release asset
uses: softprops/action-gh-release@v3
with:
files: ${{ env.ARTIFACT_OUTPUT }}/framework-dotnet-sample-app-${{ matrix.platform }}.zip
clean-up:
name: Cleans up artifacts
needs:
- pack
- sample-app
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Deletes generated bindings artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-bindings
failOnError: false
- name: Deletes win-x64 native artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-native-win-x64
failOnError: false
- name: Deletes win-arm64 native artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-native-win-arm64
failOnError: false
- name: Deletes linux-x64 native artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-native-linux-x64
failOnError: false
- name: Deletes linux-arm64 native artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-native-linux-arm64
failOnError: false
- name: Deletes NuGet package artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-nuget
failOnError: false
- name: Deletes win-x64 sample app artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-sample-app-win-x64
failOnError: false
- name: Deletes win-arm64 sample app artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-sample-app-win-arm64
failOnError: false
- name: Deletes linux-x64 sample app artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-sample-app-linux-x64
failOnError: false
- name: Deletes linux-arm64 sample app artifact
uses: geekyeggo/delete-artifact@v6
if: ${{ always() }}
with:
name: framework-dotnet-sample-app-linux-arm64
failOnError: false