-
Notifications
You must be signed in to change notification settings - Fork 2
220 lines (189 loc) · 7.42 KB
/
Copy pathci.yml
File metadata and controls
220 lines (189 loc) · 7.42 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
name: CI
on:
push:
branches: [ master, main ]
tags: [ 'v*' ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
jobs:
# ---------------------------------------------------------------------------
# Linux: build the native CycloneDDS libraries + idlc, then build and test the
# managed code against them. Building the managed solution exercises the
# build-time IDL code generator (idlc) on Linux end-to-end, and the runtime
# tests exercise the DllImport("ddsc") -> libddsc.so path. The native artifacts
# are uploaded for the Windows pack job to fold into the cross-platform package.
# ---------------------------------------------------------------------------
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for Nerdbank.GitVersioning to determine version
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
# net8.0 is the target framework, but the code uses C# 13 language
# features (e.g. ref structs in async methods), which require the .NET 10
# SDK's compiler. Install both: the 10.0 SDK builds, the 8.0 runtime runs
# the net8.0 test assemblies.
dotnet-version: |
8.0.x
10.0.x
- name: Install native build prerequisites
run: sudo apt-get update && sudo apt-get install -y cmake build-essential patchelf
- name: Display Tools Versions
run: |
dotnet --version
cmake --version
gcc --version
- name: Build Native (linux-x64)
shell: bash
run: build/native-linux.sh Release
- name: Build Managed Code
run: dotnet build CycloneDDS.NET.Core.slnf -c Release
- name: Run Runtime Tests
run: dotnet test tests/CycloneDDS.Runtime.Tests/CycloneDDS.Runtime.Tests.csproj -c Release --no-build --logger "console;verbosity=normal"
- name: Upload linux-x64 Native Artifacts
uses: actions/upload-artifact@v4
with:
name: native-linux-x64
path: artifacts/native/linux-x64/*
if-no-files-found: error
# ---------------------------------------------------------------------------
# Windows: full build, test and pack via the existing pack.ps1 pipeline
# (builds win-x64 native, builds core, runs runtime tests, packs both the
# CycloneDDS.NET and DdsMonitor packages, builds the examples). The linux-x64
# native artifacts produced above are downloaded first so the packed NuGet
# carries both win-x64 and linux-x64 runtime assets.
# ---------------------------------------------------------------------------
build:
runs-on: windows-latest
needs: [ linux-build ]
env:
# This ensures the build script can find CMake if not in default path (though it usually is on runners)
CMAKE_GENERATOR: "Visual Studio 17 2022"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for Nerdbank.GitVersioning to determine version
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
# net8.0 is the target framework, but the code uses C# 13 language
# features (e.g. ref structs in async methods), which require the .NET 10
# SDK's compiler. Install both: the 10.0 SDK builds, the 8.0 runtime runs
# the net8.0 test assemblies.
dotnet-version: |
8.0.x
10.0.x
- name: Display Tools Versions
run: |
dotnet --version
cmake --version
- name: Download linux-x64 Native Artifacts
uses: actions/download-artifact@v4
with:
name: native-linux-x64
path: artifacts/native/linux-x64/
- name: Build, Test, and Pack
shell: pwsh
run: .\build\pack.ps1
- name: Smoke-test the packed package (Windows)
shell: pwsh
run: .\build\test-package.ps1
- name: Upload win-x64 Native Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: native-win-x64
path: artifacts/native/win-x64/*
if-no-files-found: warn
- name: Upload NuGet Packages
uses: actions/upload-artifact@v4
if: always()
with:
name: nuget-packages
path: artifacts/nuget/*.nupkg
if-no-files-found: warn
- name: Upload Symbol Packages
uses: actions/upload-artifact@v4
if: always()
with:
name: symbol-packages
path: artifacts/nuget/*.snupkg
if-no-files-found: warn
# ---------------------------------------------------------------------------
# Linux: prove the *cross-platform* package (packed on Windows above) actually
# works on Linux. Downloads the finished 'nuget-packages' artifact and consumes
# it as a real NuGet package via build/test-package.sh: restore -> the bundled
# Linux idlc runs code generation -> DllImport resolves libddsc.so -> pub/sub
# round-trip, then the ddsmonitor tool is installed and served. No native build.
# ---------------------------------------------------------------------------
linux-verify:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for Nerdbank.GitVersioning (applies to the smoke-test project)
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
10.0.x
- name: Download cross-platform packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts/nuget/
- name: Smoke-test the cross-platform package (Linux)
shell: bash
run: build/test-package.sh
# ---------------------------------------------------------------------------
# Publish to NuGet.org — ONLY on a version tag (vX.Y.Z), and ONLY after the
# cross-platform package has been verified on both Windows (build) and Linux
# (linux-verify). Pushes the packages produced by the build job (both
# CycloneDDS.NET and CycloneDDS.NET.DdsMonitor) plus their symbol packages.
#
# Requires a repository secret named NUGET_API_KEY:
# Repo -> Settings -> Secrets and variables -> Actions -> New repository secret.
# To release: create a GitHub Release with a tag matching the NBGV version of
# the target commit (e.g. v0.3.2 — check with `nbgv get-version` first).
# ---------------------------------------------------------------------------
publish:
runs-on: ubuntu-latest
needs: [ build, linux-verify ]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 10.0.x
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts/nuget/
- name: Download symbol packages
uses: actions/download-artifact@v4
with:
name: symbol-packages
path: artifacts/nuget/
- name: Push to NuGet.org
shell: bash
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
if [ -z "$NUGET_API_KEY" ]; then
echo "::error::NUGET_API_KEY secret is not set — cannot publish." >&2
exit 1
fi
# dotnet expands the wildcard and auto-pushes the matching .snupkg for each .nupkg.
dotnet nuget push "artifacts/nuget/*.nupkg" \
--api-key "$NUGET_API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate