Repository navigation
184 lines (162 loc) · 8.02 KB
/
Copy pathcli-aot.yml
File metadata and controls
184 lines (162 loc) · 8.02 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
# SuperSQLInjectionV2.Cmd 命令行三平台 Native AOT 编译打包
# 手动触发:Actions → cli-aot → Run workflow;CMD/主库/Skill 相关 main 推送也自动触发
# 也被 release.yml 以 workflow_call 复用(打 tag 发布时自动构建)
# 注:Native AOT 不支持跨 OS 交叉编译,三平台分别用对应 runner 本机编译;
# 清理规则与本地 publish-cli-aot.cmd / publish-cli-aot-linux.sh / publish-cli-aot-osx.sh 一致
name: cli-aot
on:
workflow_dispatch:
workflow_call:
push:
branches: [main]
paths:
- 'SuperSQLInjectionV2.Cmd/**'
- 'SuperSQLInjectionV2/**'
- 'SuperSQLInjectionV2.Desktop/SuperSQLInjectionV2.Desktop.csproj'
- 'skills/supersqlinjectionv2-cmd/**'
- '.github/scripts/package-skill-cli.py'
- '.github/workflows/cli-aot.yml'
env:
# 发版时由 tag 名自动取版本(refs/tags/v2.0.3 → v2.0.3);手动触发时为 0.0.0-dev
APP_VERSION: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '0.0.0-dev' }}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: windows-latest, rid: win-x64 }
- { os: ubuntu-latest, rid: linux-x64 }
- { os: macos-14, rid: osx-arm64 } # Apple Silicon;Intel Mac 需 macos-13 + osx-x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: 安装 Linux Native AOT 编译依赖
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
# macOS 默认 Xcode 太旧会缺 swift_Builtin_float 等新版 Swift 运行时库,
# 导致 Native AOT 链接报 Undefined symbols __swift_FORCE_LOAD_$_swift_*,这里切到 runner 上最新 Xcode
- name: 切换到最新 Xcode(仅 macOS)
if: runner.os == 'macOS'
run: |
XCODE=$(ls -d /Applications/Xcode_*.app 2>/dev/null | tail -1)
[ -z "$XCODE" ] && XCODE="/Applications/Xcode.app"
echo "Using $XCODE"
sudo xcode-select -s "$XCODE/Contents/Developer"
xcodebuild -version
- name: 编译命令行 Native AOT(${{ matrix.rid }})
run: dotnet publish SuperSQLInjectionV2.Cmd/SuperSQLInjectionV2.Cmd.csproj -c Release -r ${{ matrix.rid }} -p:PublishAot=true -p:PublishTrimmed=true --self-contained
- name: 精简产物(去调试符号/图形库/跨平台 quickjs,与本地发布脚本一致)
shell: bash
run: |
PUBDIR="SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish"
rm -f "$PUBDIR"/*.pdb "$PUBDIR"/*.dbg "$PUBDIR"/*.dwarf 2>/dev/null || true
# CLI 不渲染,剔除 Avalonia 图形原生库与非本平台的 quickjs 库
case "${{ matrix.rid }}" in
win-x64) rm -f "$PUBDIR/libSkiaSharp.dll" "$PUBDIR/libHarfBuzzSharp.dll" "$PUBDIR/libquickjs.so" "$PUBDIR/libquickjs.dylib";;
linux-x64) rm -f "$PUBDIR/libSkiaSharp.so" "$PUBDIR/libHarfBuzzSharp.so" "$PUBDIR/libquickjs.dll" "$PUBDIR/libquickjs.dylib";;
osx-arm64) rm -f "$PUBDIR/libSkiaSharp.dylib" "$PUBDIR/libHarfBuzzSharp.dylib" "$PUBDIR/libquickjs.dll" "$PUBDIR/libquickjs.so";;
esac
rm -rf "$PUBDIR/output"
ls -la "$PUBDIR"
- name: 冒烟验证(--version + QuickJS 自检)
if: runner.os == 'Windows'
shell: pwsh
run: |
& "SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish/SuperSQLInjectionV2.Cmd.exe" --version
& "SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish/SuperSQLInjectionV2.Cmd.exe" --selftest
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: 冒烟验证(--version + QuickJS 自检)
if: runner.os != 'Windows'
shell: bash
run: |
PUBDIR="SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish"
chmod +x "$PUBDIR/SuperSQLInjectionV2.Cmd"
"$PUBDIR/SuperSQLInjectionV2.Cmd" --version
"$PUBDIR/SuperSQLInjectionV2.Cmd" --selftest
- name: 打包 zip(Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
$pub = "SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish"
# 随包附带文档(使用手册/更新说明/界面截图)与README
Copy-Item -Recurse doc "$pub/doc"
Copy-Item README.md "$pub/README.md"
Compress-Archive -Path "$pub/*" -DestinationPath "dist/SuperSQLInjectionV2.Cmd-$($env:APP_VERSION -replace '^v','')-${{ matrix.rid }}.zip" -Force
- name: 打包 tar.gz(Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
mkdir -p dist
PUBDIR="SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish"
# 随包附带文档(使用手册/更新说明/界面截图)与README
cp -R doc "$PUBDIR/doc"
cp README.md "$PUBDIR/README.md"
tar -czf "dist/SuperSQLInjectionV2.Cmd-${APP_VERSION#v}-${{ matrix.rid }}.tar.gz" -C "$PUBDIR" .
- name: 上传产物
uses: actions/upload-artifact@v4
with:
name: cli-${{ matrix.rid }}
path: dist/
retention-days: 30
- name: 上传 Skill 打包用原始产物(仅 Windows/Linux)
if: matrix.rid != 'osx-arm64'
uses: actions/upload-artifact@v4
with:
name: skill-input-${{ matrix.rid }}
path: SuperSQLInjectionV2.Cmd/bin/Release/net10.0/${{ matrix.rid }}/publish/
retention-days: 1
if-no-files-found: error
package-skill:
name: 构建双平台 Skill 包
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: 下载 Windows Native AOT 原始产物
uses: actions/download-artifact@v4
with:
name: skill-input-win-x64
path: SuperSQLInjectionV2.Cmd/bin/Release/net10.0/win-x64/publish
- name: 下载 Linux Native AOT 原始产物
uses: actions/download-artifact@v4
with:
name: skill-input-linux-x64
path: SuperSQLInjectionV2.Cmd/bin/Release/net10.0/linux-x64/publish
- name: 合并双平台产物并校验三端版本
run: |
set -euo pipefail
chmod +x SuperSQLInjectionV2.Cmd/bin/Release/net10.0/linux-x64/publish/SuperSQLInjectionV2.Cmd
# 不传 --reuse-existing:任一平台缺少当前构建产物时直接失败。
python3 .github/scripts/package-skill-cli.py
- name: 独立校验 Skill 包与双平台构建来源
run: |
python3 - <<'PY'
import json
from zipfile import ZipFile
path = 'dist/supersqlinjectionv2-cmd.skill'
with ZipFile(path) as archive:
assert archive.testzip() is None, 'Skill 包 CRC 校验失败'
root = 'supersqlinjectionv2-cmd/'
info = json.loads(archive.read(root + 'assets/bin/BUILDINFO.json'))
assert all(item['currentBuildVerified'] for item in info['platforms'].values()), '包含旧平台二进制'
for rid, executable in [('win-x64', 'SuperSQLInjectionV2.Cmd.exe'), ('linux-x64', 'SuperSQLInjectionV2.Cmd')]:
assert root + f'assets/bin/{rid}/{executable}' in archive.namelist(), f'缺少 {rid} 可执行文件'
linux = archive.getinfo(root + 'assets/bin/linux-x64/SuperSQLInjectionV2.Cmd')
assert (linux.external_attr >> 16) & 0o111, 'Linux 可执行权限丢失'
print('Skill 包校验通过:双平台均为当前 Native AOT 构建')
PY
- name: 上传双平台 Skill 包
uses: actions/upload-artifact@v4
with:
name: skill-cli
path: dist/supersqlinjectionv2-cmd.skill
retention-days: 30
if-no-files-found: error