forked from bonsai-rx/portaudio.net
-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (216 loc) · 11.5 KB
/
Copy pathPortAudioNet.yml
File metadata and controls
242 lines (216 loc) · 11.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
name: PortAudio.NET
on:
push:
# This prevents tag pushes from triggering this workflow
branches: ['*']
pull_request:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version"
default: ""
will_publish_packages:
description: "Publish packages?"
default: "false"
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
ContinuousIntegrationBuild: true
jobs:
# =====================================================================================================================================================================
# Build and package
# =====================================================================================================================================================================
build:
strategy:
fail-fast: false
matrix:
include:
- name: Windows x64
os: windows-latest
rid: win-x64
native-build-command: ./PortAudioNet.Native/build-native.cmd
generate-command: ./generate.cmd
- name: Linux x64
os: ubuntu-22.04
rid: linux-x64
native-build-command: ./PortAudioNet.Native/build-native.sh
generate-command: ./generate.sh
name: ${{matrix.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
# ----------------------------------------------------------------------- Setup tools
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Workaround for https://github.com/MochiLibraries/Biohazrd/issues/248
- name: Install libtinfo5
if: matrix.rid == 'linux-x64'
run: |
sudo apt-get update
sudo apt-get install libtinfo5 -y
# ----------------------------------------------------------------------- Configure build
- name: Configure build
run: python .github/workflows/configure-build.py
env:
github_event_name: ${{github.event_name}}
github_ref: ${{github.ref}}
github_run_number: ${{github.run_number}}
release_version: ${{github.event.release.tag_name}}
workflow_dispatch_version: ${{github.event.inputs.version}}
workflow_dispatch_will_publish_packages: ${{github.event.inputs.will_publish_packages}}
# ----------------------------------------------------------------------- Populate PortAudio Git revision
- name: Populate PortAudio Git revision
shell: bash
working-directory: external/portaudio/
run: ./update_gitrevision.sh
# ----------------------------------------------------------------------- Build native library
- name: Build native library
run: ${{matrix.native-build-command}}
# ----------------------------------------------------------------------- Generate PortAudioNet
- name: Restore PortAudioNet.Generator
run: dotnet restore PortAudioNet.Generator
- name: Build PortAudioNet.Generator
run: dotnet build PortAudioNet.Generator --configuration Release
- name: Generate PortAudioNet
id: generate
run: ${{matrix.generate-command}}
# Currently the generated output for Windows is comitted to the repository, so we don't expect changes
- name: Ensure the generated output did not change on Windows
if: matrix.rid == 'win-x64'
run: git diff --exit-code --ignore-submodules=all
# ----------------------------------------------------------------------- Build PortAudioNet
- name: Restore PortAudioNet
# This is a workaround for the fact that the NuGet package name of PortAudioNet.Native changes depending on the configuration.
# Ideally we'd just manually specify the dependency but NuGet makes that really annoying to do. See https://github.com/NuGet/Home/issues/8133
env:
Configuration: Release
run: dotnet restore PortAudioNet
- name: Build PortAudioNet
run: dotnet build PortAudioNet --no-restore --configuration Release
# ----------------------------------------------------------------------- Pack PortAudioNet
- name: Pack PortAudioNet
id: pack
run: dotnet pack PortAudioNet --no-build --configuration Release
# ----------------------------------------------------------------------- Pack PortAudioNet.Native variants
- name: Restore PortAudioNet
run: dotnet restore PortAudioNet.Native --runtime ${{matrix.rid}}
- name: Pack PortAudioNet.Native.${{matrix.rid}}-debug
run: dotnet pack PortAudioNet.Native --no-build --configuration Debug /p:RuntimeIdentifier=${{matrix.rid}}
- name: Pack PortAudioNet.Native.${{matrix.rid}}
run: dotnet pack PortAudioNet.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Run device listing sample as a smoke test
# We do this last so it can't indirectly affect the build process of any packages
- name: Smoke test modern .NET (Debug)
if: ${{matrix.rid != 'linux-x64'}}
run: dotnet run --project Samples/ListDevices --framework net8.0 --configuration Debug
- name: Smoke test modern .NET (Release)
if: ${{matrix.rid != 'linux-x64'}}
run: dotnet run --project Samples/ListDevices --framework net8.0 --configuration Release
- name: Smoke test .NET Framework (Debug)
if: matrix.rid == 'win-x64'
run: dotnet run --project Samples/ListDevices --framework net472 --configuration Debug
- name: Smoke test .NET Framework (Release)
if: matrix.rid == 'win-x64'
run: dotnet run --project Samples/ListDevices --framework net472 --configuration Release
# ----------------------------------------------------------------------- Ensure everything else builds
# This mainly exists to ensure all samples build
- name: Ensure everything else builds (Debug)
if: ${{matrix.rid != 'linux-x64'}}
run: dotnet build --configuration Debug
- name: Ensure everything else builds (Release)
if: ${{matrix.rid != 'linux-x64'}}
run: dotnet build --configuration Release
# ----------------------------------------------------------------------- Collect artifacts
# All of these steps ignore failure so that we get what artifacts are available when things are broken
- name: Collect NuGet packages
if: steps.pack.outcome == 'success' && always()
uses: actions/upload-artifact@v4
with:
name: Packages-${{matrix.rid}}
if-no-files-found: error
path: artifacts/package/**
- name: Collect generated output
if: steps.generate.outcome == 'success' && always()
uses: actions/upload-artifact@v4
with:
name: Generated-${{matrix.rid}}
if-no-files-found: error
path: PortAudioNet/#Generated/**
# =====================================================================================================================================================================
# Publish NuGet Packages to GitHub
# =====================================================================================================================================================================
publish-packages-github:
name: Publish to GitHub
runs-on: ubuntu-latest
needs: [build]
# Pushes always publish CI packages (configure-build.py will add the branch name to the version string for branches besides main)
# Published releases always publish packages
# A manual workflow only publishes packages if explicitly enabled
if: github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true')
steps:
# ----------------------------------------------------------------------- Setup tools
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v4
with:
name: Packages-win-x64
path: Packages
# ----------------------------------------------------------------------- Upload release assets
- name: Upload release assets
if: github.event_name == 'release'
run: gh release upload ${{github.event.release.tag_name}} Packages/**/*.nupkg --clobber -R ${{github.repository}}
env:
GH_TOKEN: ${{github.token}}
# ----------------------------------------------------------------------- Push to GitHub Packages
- name: Push to GitHub Packages
run: dotnet nuget push "Packages/**/*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
# =====================================================================================================================================================================
# Publish NuGet Packages to NuGet.org
# =====================================================================================================================================================================
publish-packages-nuget-org:
name: Publish to NuGet.org
runs-on: ubuntu-latest
needs: [build]
environment: PublicRelease
# Release builds always publish packages to NuGet.org
# Workflow dispatch builds will only publish packages if enabled and an explicit version number is given
# Make sure this logic matches configure-build.py to ensure we don't accidentally depend on sibling CI pre-release packages
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true' && github.event.inputs.version != '')
steps:
# ----------------------------------------------------------------------- Setup tools
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v4
with:
name: Packages-win-x64
path: Packages
# ----------------------------------------------------------------------- Push to NuGet.org
- name: Push to NuGet.org
run: dotnet nuget push "Packages/**/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0