|
| 1 | +name: Build CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + name: 编译校验 |
| 9 | + runs-on: windows-latest |
| 10 | + steps: |
| 11 | + - name: 检出代码 |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: 获取版本号和微信版本号 |
| 15 | + if: ${{ github.event_name == 'push' }} |
| 16 | + run: | |
| 17 | + $version_full = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "FileVersion", "(.*)"').Matches.Groups[1].Value.Trim() |
| 18 | + $wechat_version = (Select-String -Path "WeChatFerry/spy/spy.rc" -Pattern 'VALUE "ProductVersion", "(.*)"').Matches.Groups[1].Value.Trim() |
| 19 | + $version = $version_full -replace '(\d+\.\d+\.\d+)\.\d+', '$1' |
| 20 | + echo "version=$version" >> $env:GITHUB_ENV |
| 21 | + echo "wechat_version=$wechat_version" >> $env:GITHUB_ENV |
| 22 | + shell: pwsh |
| 23 | + |
| 24 | + - name: 设置 Visual Studio 2019 |
| 25 | + uses: microsoft/setup-msbuild@v2 |
| 26 | + with: |
| 27 | + vs-version: "16.0" |
| 28 | + |
| 29 | + - name: 设置 Python 3 |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: "3.9" |
| 33 | + |
| 34 | + - name: 安装 Python 依赖项 |
| 35 | + run: | |
| 36 | + python -m pip install --upgrade pip |
| 37 | + pip install grpcio-tools==1.48.2 |
| 38 | + shell: pwsh |
| 39 | + |
| 40 | + - name: 设置 vcpkg 缓存 |
| 41 | + id: cache-vcpkg |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: | |
| 45 | + C:/Tools/vcpkg |
| 46 | + ${{ github.workspace }}/WeChatFerry/vcpkg_installed |
| 47 | + key: vcpkg-${{ hashFiles('WeChatFerry/vcpkg.json') }} |
| 48 | + restore-keys: | |
| 49 | + vcpkg- |
| 50 | +
|
| 51 | + - name: 安装 vcpkg 并初始化 |
| 52 | + run: | |
| 53 | + if (!(Test-Path 'C:/Tools')) { New-Item -ItemType Directory -Force -Path 'C:/Tools' } |
| 54 | + cd C:/Tools |
| 55 | + if (!(Test-Path 'C:/Tools/vcpkg')) { git clone https://github.com/microsoft/vcpkg } |
| 56 | + .\vcpkg\bootstrap-vcpkg.bat |
| 57 | + echo "VCPKG_ROOT=C:/Tools/vcpkg" >> $GITHUB_ENV |
| 58 | + cd ${{ github.workspace }}/WeChatFerry |
| 59 | + C:/Tools/vcpkg/vcpkg install --triplet x64-windows-static |
| 60 | + C:/Tools/vcpkg/vcpkg integrate install |
| 61 | + shell: pwsh |
| 62 | + |
| 63 | + - name: 解析并构建 Release/Debug |
| 64 | + run: | |
| 65 | + $configs = "Release","Debug" |
| 66 | + foreach ($cfg in $configs) { |
| 67 | + Write-Host "Building $cfg" |
| 68 | + msbuild WeChatFerry/WeChatFerry.sln ` |
| 69 | + /p:Configuration=$cfg ` |
| 70 | + /p:Platform="x64" ` |
| 71 | + /p:VcpkgTriplet="x64-windows-static" ` |
| 72 | + /p:VcpkgEnableManifest=true ` |
| 73 | + /verbosity:minimal |
| 74 | + } |
| 75 | + shell: pwsh |
0 commit comments