Repository navigation
501 lines (448 loc) · 22.1 KB
/
Copy pathbuild-codenet.yml
File metadata and controls
501 lines (448 loc) · 22.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
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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
name: Build CodeNet Runtime
permissions:
contents: write
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
target_os:
description: 'Target OS'
required: true
default: 'osx'
type: choice
options:
- osx
- linux
- win
target_arch:
description: 'Target Architecture'
required: true
default: 'arm64'
type: choice
options:
- arm64
- x64
- arm
jobs:
# The `clr+libs` subset does not produce a single combined output directory.
# It produces two, and both are needed for a usable runtime:
# 1. artifacts/bin/coreclr/<OS>.<Arch>.<Config>
# CoreCLR host + tools (corerun, libcoreclr.dylib, System.Private.CoreLib.dll, crossgen2, ...)
# See docs/workflow/building/coreclr/README.md
# 2. artifacts/bin/runtime/<tfm>-<OS>-<Config>-<Arch>
# All managed libraries (System.Runtime.dll, System.Collections.dll, ...)
# See LibrariesAllBinArtifactsPath in eng/liveBuilds.targets
# The packaging step below merges both into one directory.
build-macos:
name: Build macOS (${{ matrix.arch }})
if: ${{ github.event_name == 'workflow_dispatch' && inputs.target_os == 'osx' || github.event_name != 'workflow_dispatch' }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
# x64 与 arm64 都要:arm64 供 SulfurLauncher 的 arm64 通道;
# x64 供 MChub(拿 x64 SDK 交叉构建 osx-arm64)与 SulfurLauncher 的 x64 通道。
# 两者都进 sdk-v10.0.400 的 CodeNetSDK(见 build-codenet-sdk.yml)。
# workflow_dispatch 只建 inputs.target_arch 指定的那一个,排障时能把一轮从 6 个 job 缩到 1 个。
arch: ${{ github.event_name == 'workflow_dispatch' && fromJSON(format('["{0}"]', inputs.target_arch)) || fromJSON('["arm64", "x64"]') }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Install dependencies
run: |
brew install cmake ninja icu4c
- name: Build .NET Runtime for macOS arm64
run: |
./build.sh -arch ${{ matrix.arch }} -os osx -c Release \
--subset clr+libs \
--ninja \
/p:TargetOS=osx \
/p:TargetArchitecture=${{ matrix.arch }} \
/p:Configuration=Release
- name: Verify build output
run: |
set -uo pipefail
OS_ID=osx
ARCH="${{ matrix.arch }}"
CORECLR_LIB="libcoreclr.dylib"
HOST_BIN="corerun"
CORECLR_DIR="artifacts/bin/coreclr/${OS_ID}.${ARCH}.Release"
LIBS_DIR="$(ls -d artifacts/bin/runtime/*-${OS_ID}-Release-${ARCH} 2>/dev/null | head -n 1)"
# 宿主 muxer 的安装目录,按 TargetRid 命名(osx-arm64.Release/corehost)。
HOST_DIR="artifacts/bin/${OS_ID}-${ARCH}.Release/corehost"
if [ ! -f "${CORECLR_DIR}/${CORECLR_LIB}" ] || [ ! -f "${CORECLR_DIR}/${HOST_BIN}" ]; then
echo "::error::CoreCLR output is incomplete: expected ${CORECLR_DIR}/{${CORECLR_LIB},${HOST_BIN}}"
echo "--- artifacts/bin/coreclr ---"
ls -la artifacts/bin/coreclr 2>/dev/null || echo " (missing)"
echo "--- ${CORECLR_DIR} ---"
ls -la "${CORECLR_DIR}" 2>/dev/null || echo " (missing)"
exit 1
fi
# 运行时包必须自带宿主入口:muxer(codenet/dotnet)+ hostfxr/hostpolicy。
# 这些由 install_with_stripped_symbols 装进 corehost 目录,缺任一项包内就没有
# 任何可启动的宿主(此前正是如此,包只有 CoreCLR 与托管库)。
for host_file in codenet dotnet libhostfxr.dylib libhostpolicy.dylib; do
if [ ! -f "${HOST_DIR}/${host_file}" ]; then
echo "::error::Host file is missing: expected ${HOST_DIR}/${host_file}"
ls -la "${HOST_DIR}" 2>/dev/null || echo " (missing)"
exit 1
fi
done
echo "CoreCLR output : ${CORECLR_DIR}"
echo "Managed libraries : ${LIBS_DIR:-<not found>}"
echo "Host files : ${HOST_DIR}/{codenet,dotnet,libhostfxr.dylib,libhostpolicy.dylib}"
if [ -n "${LIBS_DIR}" ]; then
DLL_COUNT="$(find "${LIBS_DIR}" -maxdepth 1 -name '*.dll' | wc -l | tr -d ' ')"
echo "Managed assemblies: ${DLL_COUNT}"
if [ "${DLL_COUNT}" -lt 50 ]; then
echo "::warning::Only ${DLL_COUNT} assemblies in ${LIBS_DIR}; expected the full shared framework."
fi
else
echo "::warning::Managed libraries directory not found; artifact will contain CoreCLR only."
fi
{
echo "CORECLR_DIR=${CORECLR_DIR}"
echo "LIBS_DIR=${LIBS_DIR}"
echo "HOST_DIR=${HOST_DIR}"
echo "PACKAGE_DIR=artifacts/package/runtime"
} >> "$GITHUB_ENV"
- name: Package Runtime
run: |
set -euo pipefail
rm -rf "${PACKAGE_DIR}"
mkdir -p "${PACKAGE_DIR}"
cp -R "${CORECLR_DIR}/." "${PACKAGE_DIR}/"
if [ -n "${LIBS_DIR}" ] && [ -d "${LIBS_DIR}" ]; then
cp -R "${LIBS_DIR}/." "${PACKAGE_DIR}/"
fi
# 宿主 muxer 与 hostfxr/hostpolicy 不在 CORECLR_DIR/LIBS_DIR 内,必须单独收集,
# 否则包里有运行时却没有任何可启动宿主。
# 逐个点名复制(而非整目录):同目录还有 install_with_stripped_symbols 产出的
# .dwarf 调试符号、.a 静态库和头文件,都不该进运行时包。cp -fp 保留可执行权限。
for host_file in codenet dotnet libhostfxr.dylib libhostpolicy.dylib; do
if [ -f "${HOST_DIR}/${host_file}" ]; then
cp -fp "${HOST_DIR}/${host_file}" "${PACKAGE_DIR}/"
else
echo "::warning::${host_file} not found in ${HOST_DIR}"
fi
done
echo "Packaged $(find "${PACKAGE_DIR}" -type f | wc -l | tr -d ' ') files"
tar czf "artifacts/package/dotnet-runtime-osx-${{ matrix.arch }}.tar.gz" -C "${PACKAGE_DIR}" .
ls -lh artifacts/package/
- name: Build macOS .pkg Installer
if: runner.os == 'macOS'
run: |
set -euo pipefail
PKG_ROOT="artifacts/pkgroot"
PKG_ID="hub.code.codenet"
PKG_VERSION="10.0.11"
PKG_DIR="artifacts/package"
INSTALL_DIR="/usr/local/share/dotnet"
rm -rf "${PKG_ROOT}"
mkdir -p "${PKG_ROOT}/${INSTALL_DIR}"
cp -R "${PACKAGE_DIR}/." "${PKG_ROOT}/${INSTALL_DIR}/"
mkdir -p "${PKG_ROOT}/etc/paths.d"
echo "${INSTALL_DIR}" > "${PKG_ROOT}/etc/paths.d/codenet"
pkgbuild \
--root "${PKG_ROOT}" \
--identifier "${PKG_ID}" \
--version "${PKG_VERSION}" \
--install-location "/" \
"${PKG_DIR}/dotnet-runtime-osx-${{ matrix.arch }}.pkg"
ls -lh "${PKG_DIR}/dotnet-runtime-osx-${{ matrix.arch }}.pkg"
- uses: actions/upload-artifact@v4
with:
name: dotnet-runtime-osx-${{ matrix.arch }}
path: artifacts/package/dotnet-runtime-osx-${{ matrix.arch }}.tar.gz
- uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
with:
name: dotnet-runtime-osx-${{ matrix.arch }}-installer
path: artifacts/package/dotnet-runtime-osx-${{ matrix.arch }}.pkg
- name: Publish to Release
if: github.ref == 'refs/heads/main'
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG=runtime-v10.0.400
# 新仓库或首次运行时 Release 可能尚不存在,必须先确保它存在:
# 否则 gh release upload 会以 "release not found" 失败,让构建成功却整个 job 判红。
# 多个 job 会并发执行这一步,因此创建失败(例如已被其它 job 抢先创建)时忽略错误。
if ! gh release view "$TAG" >/dev/null 2>&1; then
gh release create "$TAG" \
--title "CodeNet Runtime v10.0.400" \
--notes "CodeNet 运行时构建产物(CoreCLR + 共享框架 + 宿主),平铺布局,需并入既有 SDK 使用。可用的完整 SDK 见 Release sdk-v10.0.400。" \
>/dev/null 2>&1 || true
fi
cd artifacts/package
shopt -s nullglob
for f in dotnet-runtime-*; do
new="dotnet-codenet-${f#dotnet-runtime-}"
cp -f "$f" "$new"
echo "uploading $new"
gh release upload "$TAG" "$new" --clobber
done
build-linux:
name: Build Linux (${{ matrix.arch }})
if: ${{ github.event_name == 'workflow_dispatch' && inputs.target_os == 'linux' || github.event_name != 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runs-on: ubuntu-latest
- arch: arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build clang liblttng-ust-dev libkrb5-dev libssl-dev libicu-dev libcurl4-openssl-dev zlib1g-dev libnuma-dev
- name: Build .NET Runtime for Linux ${{ matrix.arch }}
run: |
./build.sh -arch ${{ matrix.arch }} -os linux -c Release \
--subset clr+libs \
--ninja \
/p:TargetOS=linux \
/p:TargetArchitecture=${{ matrix.arch }} \
/p:Configuration=Release
- name: Verify build output
run: |
set -uo pipefail
OS_ID=linux
ARCH="${{ matrix.arch }}"
CORECLR_LIB="libcoreclr.so"
HOST_BIN="corerun"
CORECLR_DIR="artifacts/bin/coreclr/${OS_ID}.${ARCH}.Release"
LIBS_DIR="$(ls -d artifacts/bin/runtime/*-${OS_ID}-Release-${ARCH} 2>/dev/null | head -n 1)"
# 宿主 muxer 的安装目录,按 TargetRid 命名(linux-x64.Release/corehost)。
HOST_DIR="artifacts/bin/${OS_ID}-${ARCH}.Release/corehost"
if [ ! -f "${CORECLR_DIR}/${CORECLR_LIB}" ] || [ ! -f "${CORECLR_DIR}/${HOST_BIN}" ]; then
echo "::error::CoreCLR output is incomplete: expected ${CORECLR_DIR}/{${CORECLR_LIB},${HOST_BIN}}"
echo "--- artifacts/bin/coreclr ---"
ls -la artifacts/bin/coreclr 2>/dev/null || echo " (missing)"
echo "--- ${CORECLR_DIR} ---"
ls -la "${CORECLR_DIR}" 2>/dev/null || echo " (missing)"
exit 1
fi
# 运行时包必须自带宿主入口:muxer(codenet/dotnet)+ hostfxr/hostpolicy。
# 这些由 install_with_stripped_symbols 装进 corehost 目录,缺任一项包内就没有
# 任何可启动的宿主(此前正是如此,包只有 CoreCLR 与托管库)。
for host_file in codenet dotnet libhostfxr.so libhostpolicy.so; do
if [ ! -f "${HOST_DIR}/${host_file}" ]; then
echo "::error::Host file is missing: expected ${HOST_DIR}/${host_file}"
ls -la "${HOST_DIR}" 2>/dev/null || echo " (missing)"
exit 1
fi
done
echo "CoreCLR output : ${CORECLR_DIR}"
echo "Managed libraries : ${LIBS_DIR:-<not found>}"
echo "Host files : ${HOST_DIR}/{codenet,dotnet,libhostfxr.so,libhostpolicy.so}"
if [ -n "${LIBS_DIR}" ]; then
DLL_COUNT="$(find "${LIBS_DIR}" -maxdepth 1 -name '*.dll' | wc -l | tr -d ' ')"
echo "Managed assemblies: ${DLL_COUNT}"
if [ "${DLL_COUNT}" -lt 50 ]; then
echo "::warning::Only ${DLL_COUNT} assemblies in ${LIBS_DIR}; expected the full shared framework."
fi
else
echo "::warning::Managed libraries directory not found; artifact will contain CoreCLR only."
fi
{
echo "CORECLR_DIR=${CORECLR_DIR}"
echo "LIBS_DIR=${LIBS_DIR}"
echo "HOST_DIR=${HOST_DIR}"
echo "PACKAGE_DIR=artifacts/package/runtime"
} >> "$GITHUB_ENV"
- name: Package Runtime
run: |
set -euo pipefail
rm -rf "${PACKAGE_DIR}"
mkdir -p "${PACKAGE_DIR}"
cp -R "${CORECLR_DIR}/." "${PACKAGE_DIR}/"
if [ -n "${LIBS_DIR}" ] && [ -d "${LIBS_DIR}" ]; then
cp -R "${LIBS_DIR}/." "${PACKAGE_DIR}/"
fi
# 宿主 muxer 与 hostfxr/hostpolicy 不在 CORECLR_DIR/LIBS_DIR 内,必须单独收集,
# 否则包里有运行时却没有任何可启动宿主。
# 逐个点名复制(而非整目录):同目录还有 install_with_stripped_symbols 产出的
# .dbg 调试符号、.a 静态库和头文件,都不该进运行时包。cp -fp 保留可执行权限。
for host_file in codenet dotnet libhostfxr.so libhostpolicy.so; do
if [ -f "${HOST_DIR}/${host_file}" ]; then
cp -fp "${HOST_DIR}/${host_file}" "${PACKAGE_DIR}/"
else
echo "::warning::${host_file} not found in ${HOST_DIR}"
fi
done
echo "Packaged $(find "${PACKAGE_DIR}" -type f | wc -l | tr -d ' ') files"
tar czf "artifacts/package/dotnet-runtime-linux-${{ matrix.arch }}.tar.gz" -C "${PACKAGE_DIR}" .
ls -lh artifacts/package/
- uses: actions/upload-artifact@v4
with:
name: dotnet-runtime-linux-${{ matrix.arch }}
path: artifacts/package/dotnet-runtime-linux-${{ matrix.arch }}.tar.gz
- name: Publish to Release
if: github.ref == 'refs/heads/main'
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG=runtime-v10.0.400
# 新仓库或首次运行时 Release 可能尚不存在,必须先确保它存在:
# 否则 gh release upload 会以 "release not found" 失败,让构建成功却整个 job 判红。
# 多个 job 会并发执行这一步,因此创建失败(例如已被其它 job 抢先创建)时忽略错误。
if ! gh release view "$TAG" >/dev/null 2>&1; then
gh release create "$TAG" \
--title "CodeNet Runtime v10.0.400" \
--notes "CodeNet 运行时构建产物(CoreCLR + 共享框架 + 宿主),平铺布局,需并入既有 SDK 使用。可用的完整 SDK 见 Release sdk-v10.0.400。" \
>/dev/null 2>&1 || true
fi
cd artifacts/package
shopt -s nullglob
for f in dotnet-runtime-*; do
new="dotnet-codenet-${f#dotnet-runtime-}"
cp -f "$f" "$new"
echo "uploading $new"
gh release upload "$TAG" "$new" --clobber
done
build-windows:
name: Build Windows (${{ matrix.arch }})
if: ${{ github.event_name == 'workflow_dispatch' && inputs.target_os == 'win' || github.event_name != 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runs-on: windows-latest
- arch: arm64
runs-on: windows-11-arm
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Build .NET Runtime for Windows ${{ matrix.arch }}
run: |
.\build.cmd -arch ${{ matrix.arch }} -os windows -c Release -subset clr+libs /p:TargetOS=windows /p:TargetArchitecture=${{ matrix.arch }} /p:Configuration=Release
- name: Verify build output
shell: pwsh
run: |
# 目录名取自 TargetOS(windows/osx/linux),Windows 上是 `windows.<arch>.Release`,
# 不是 `win.`;libraries 目录同理为 `<tfm>-windows-Release-<arch>`。
$coreclrDir = "artifacts\bin\coreclr\windows.${{ matrix.arch }}.Release"
$libsDir = Get-ChildItem -Path "artifacts\bin\runtime" -Directory `
-Filter "*-windows-Release-${{ matrix.arch }}" -ErrorAction SilentlyContinue |
Select-Object -First 1
# 宿主 muxer 的安装目录,按 TargetRid 命名(win-x64.Release\corehost);
# 注意不是上面的 `windows.` 前缀。
$hostDir = "artifacts\bin\win-${{ matrix.arch }}.Release\corehost"
if (-not (Test-Path (Join-Path $coreclrDir "coreclr.dll")) -or
-not (Test-Path (Join-Path $coreclrDir "corerun.exe"))) {
Write-Host "::error::CoreCLR output is incomplete: expected $coreclrDir\{coreclr.dll,corerun.exe}"
if (Test-Path "artifacts\bin\coreclr") { Get-ChildItem "artifacts\bin\coreclr" }
if (Test-Path $coreclrDir) { Get-ChildItem $coreclrDir }
exit 1
}
Write-Host "CoreCLR output : $coreclrDir"
if ($libsDir) {
$dllCount = (Get-ChildItem -Path $libsDir.FullName -Filter "*.dll").Count
Write-Host "Managed libraries : $($libsDir.FullName)"
Write-Host "Managed assemblies: $dllCount"
if ($dllCount -lt 50) {
Write-Host "::warning::Only $dllCount assemblies in $($libsDir.FullName); expected the full shared framework."
}
} else {
Write-Host "::warning::Managed libraries directory not found; artifact will contain CoreCLR only."
}
# 运行时包必须自带宿主入口:muxer(codenet/dotnet)+ hostfxr/hostpolicy。
# 这些由 install_with_stripped_symbols 装进 corehost 目录,缺任一项包内就没有
# 任何可启动的宿主(此前正是如此,包只有 CoreCLR 与托管库)。
foreach ($hostFile in @("codenet.exe", "dotnet.exe", "hostfxr.dll", "hostpolicy.dll")) {
if (-not (Test-Path (Join-Path $hostDir $hostFile))) {
Write-Host "::error::Host file is missing: expected $hostDir\$hostFile"
if (Test-Path $hostDir) { Get-ChildItem $hostDir }
exit 1
}
}
Write-Host "Host files : $hostDir\{codenet.exe,dotnet.exe,hostfxr.dll,hostpolicy.dll}"
@(
"CORECLR_DIR=$coreclrDir"
"LIBS_DIR=$($libsDir.FullName)"
"HOST_DIR=$hostDir"
"PACKAGE_DIR=artifacts\package\runtime"
) | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Package Runtime
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path $env:PACKAGE_DIR | Out-Null
Copy-Item -Path (Join-Path $env:CORECLR_DIR "*") -Destination $env:PACKAGE_DIR -Recurse -Force
if ($env:LIBS_DIR -and (Test-Path $env:LIBS_DIR)) {
Copy-Item -Path (Join-Path $env:LIBS_DIR "*") -Destination $env:PACKAGE_DIR -Recurse -Force
}
# 宿主 muxer 与 hostfxr/hostpolicy 不在 CORECLR_DIR/LIBS_DIR 内,必须单独收集,
# 否则包里有运行时却没有任何可启动宿主。
# 逐个点名复制(而非整目录):同目录还有 hostfxr.lib/hostpolicy.lib 等导入库
# 和头文件,都不该进运行时包。
foreach ($hostFile in @("codenet.exe", "dotnet.exe", "hostfxr.dll", "hostpolicy.dll")) {
$hostSrc = Join-Path $env:HOST_DIR $hostFile
if (Test-Path $hostSrc) {
Copy-Item -Path $hostSrc -Destination $env:PACKAGE_DIR -Force
} else {
Write-Host "::warning::$hostFile not found in $env:HOST_DIR"
}
}
$count = (Get-ChildItem -Path $env:PACKAGE_DIR -Recurse -File).Count
Write-Host "Packaged $count files"
New-Item -ItemType Directory -Force -Path "artifacts\package" | Out-Null
Compress-Archive -Path (Join-Path $env:PACKAGE_DIR "*") `
-DestinationPath "artifacts\package\dotnet-runtime-win-${{ matrix.arch }}.zip"
- uses: actions/upload-artifact@v4
with:
name: dotnet-runtime-win-${{ matrix.arch }}
path: artifacts\package\dotnet-runtime-win-${{ matrix.arch }}.zip
- name: Publish to Release
if: github.ref == 'refs/heads/main'
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG=runtime-v10.0.400
# 新仓库或首次运行时 Release 可能尚不存在,必须先确保它存在:
# 否则 gh release upload 会以 "release not found" 失败,让构建成功却整个 job 判红。
# 多个 job 会并发执行这一步,因此创建失败(例如已被其它 job 抢先创建)时忽略错误。
if ! gh release view "$TAG" >/dev/null 2>&1; then
gh release create "$TAG" \
--title "CodeNet Runtime v10.0.400" \
--notes "CodeNet 运行时构建产物(CoreCLR + 共享框架 + 宿主),平铺布局,需并入既有 SDK 使用。可用的完整 SDK 见 Release sdk-v10.0.400。" \
>/dev/null 2>&1 || true
fi
cd artifacts/package
shopt -s nullglob
for f in dotnet-runtime-*; do
new="dotnet-codenet-${f#dotnet-runtime-}"
cp -f "$f" "$new"
echo "uploading $new"
gh release upload "$TAG" "$new" --clobber
done
# 运行时包发布完毕后再组装 CodeNetSDK(官方 SDK 骨架 + 刚发出去的运行时)。
# 组装逻辑与产物校验都在 build-codenet-sdk.yml + scripts/codenet-sdk/assemble-codenet-sdk.sh。
# 只在 main 上跑:SDK 工作流是从 Release 取运行时包的,PR 上没有资产可取。
# 需显式判 build-macos 的结果:workflow_dispatch 指定 linux/win 时该 job 会被 skip,
# 而 needs 里有 skipped 的 job 时默认会把本 job 也 skip 掉。
build-sdk:
needs: [build-macos, build-linux, build-windows]
if: ${{ always() && github.ref == 'refs/heads/main' && needs.build-macos.result == 'success' }}
uses: ./.github/workflows/build-codenet-sdk.yml
# 被调工作流要用 GITHUB_TOKEN 下载运行时包、上传 SDK 资产。
secrets: inherit