WeChatFerry/.github/workflows/build-ci.yml
2025-04-30 01:40:54 +08:00

87 lines
2.5 KiB
YAML

name: Build CI
on:
workflow_call:
jobs:
build:
name: 编译校验
runs-on: windows-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Visual Studio 2019
uses: microsoft/setup-msbuild@v2
with:
vs-version: "16.0"
- name: 设置 Python 3
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: 安装 Python 依赖项
run: |
python -m pip install --upgrade pip
pip install grpcio-tools==1.48.2
shell: pwsh
- name: 设置 vcpkg 缓存
id: cache-vcpkg
uses: actions/cache@v4
with:
path: |
C:/Tools/vcpkg
${{ github.workspace }}/WeChatFerry/vcpkg_installed
key: vcpkg-${{ hashFiles('WeChatFerry/vcpkg.json') }}
restore-keys: |
vcpkg-
- name: Clone & bootstrap vcpkg (首次或缓存失效时)
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: pwsh
run: |
if (!(Test-Path 'C:/Tools')) { New-Item -ItemType Directory -Force -Path 'C:/Tools' | Out-Null }
cd C:/Tools
git clone --depth 1 https://github.com/microsoft/vcpkg vcpkg
# 加一次简单重试,防网络抖动
$retry = 0
while ($retry -lt 3) {
try {
.\vcpkg\bootstrap-vcpkg.bat
break
} catch {
$retry++
if ($retry -ge 3) { throw }
Write-Host "bootstrap 失败,重试第 $retry 次..."
Start-Sleep -Seconds 15
}
}
- name: 设置 VCPKG_ROOT
shell: pwsh
run: |
"VCPKG_ROOT=C:/Tools/vcpkg" | Out-File $Env:GITHUB_ENV -Encoding utf8 -Append
- name: 安装/更新第三方依赖
shell: pwsh
run: |
cd ${{ github.workspace }}/WeChatFerry
C:/Tools/vcpkg/vcpkg install --triplet x64-windows-static
C:/Tools/vcpkg/vcpkg integrate install
- name: 解析并构建 Release/Debug
run: |
$configs = "Release","Debug"
foreach ($cfg in $configs) {
Write-Host "Building $cfg"
msbuild WeChatFerry/WeChatFerry.sln `
/p:Configuration=$cfg `
/p:Platform="x64" `
/p:VcpkgTriplet="x64-windows-static" `
/p:VcpkgEnableManifest=true `
/verbosity:minimal
}
shell: pwsh