From 8b4cabba28a4d2c105dca1650670d6afb93b3283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9C=E5=BD=B1=E7=A7=91=E6=8A=80?= Date: Sun, 22 Nov 2026 08:09:23 +0800 Subject: [PATCH] =?UTF-8?q?ci(build-bot):=20=E6=94=AF=E6=8C=81=20version?= =?UTF-8?q?=3D=20=E5=8F=82=E6=95=B0=E6=8C=87=E5=AE=9A=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=9Bmac=20=E5=A4=A7=E5=B0=8F=E5=86=99=E4=B8=8D=E6=95=8F?= =?UTF-8?q?=E6=84=9F=EF=BC=9B=E5=8A=A0=E9=80=9F=20macOS=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. @build-bot build mac version=1.1.3 可指定版本(缺省仍读 Directory.Build.props) - 评论里 version=x.y.z 优先,大小写不敏感 - mac / Mac / MAC 都能匹配(grep -oiE 已忽略大小写) - 版本透传给 build.sh / build.ps1,回帖与 Release notes 都显示版本 2. macOS 构建提速 - 缓存 NuGet 包(~/.nuget/packages)与 CocoaPods(Pods/ + Caches) - runner 固定 macos-14(原生 arm64,避开 Rosetta 模拟) - build-bot 与 build-release 两个工作流同步优化 --- .github/workflows/build-bot.yml | 50 +++++++++++++++++++++++------ .github/workflows/build-release.yml | 18 ++++++++++- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-bot.yml b/.github/workflows/build-bot.yml index 4699389..2a58b3a 100644 --- a/.github/workflows/build-bot.yml +++ b/.github/workflows/build-bot.yml @@ -1,10 +1,11 @@ name: build-bot # 在 Issue / PR 里评论触发编译: -# @build-bot build mac 编译 macOS -# @build-bot build win-amd 编译 Windows amd64 -# @build-bot build win-arm 编译 Windows arm64 -# @build-bot build all 三个平台全编 +# @build-bot build mac 编译 macOS(大小写均可:Mac / MAC) +# @build-bot build mac version=1.1.3 编译 macOS 1.1.3(不写 version= 则用仓库当前版本) +# @build-bot build win-amd 编译 Windows amd64 +# @build-bot build win-arm 编译 Windows arm64 +# @build-bot build all 三个平台全编 # 产物发布到 ip-prerelease 预发布(同一 tag 滚动更新,不删别的平台资产)。 on: @@ -69,8 +70,18 @@ jobs: echo "ok=true" >> "$GITHUB_OUTPUT" echo "target=$TARGET" >> "$GITHUB_OUTPUT" - VERSION=$(sed -n 's:.*\(.*\).*:\1:p' Directory.Build.props | head -1) - [ -n "$VERSION" ] || VERSION=1.0.0 + # 版本号:评论里的 version=x.y.z 优先(大小写不敏感),没有则用仓库当前版本。 + CLI_VERSION=$(printf '%s' "$BODY" \ + | grep -oiE 'version[[:space:]]*=[[:space:]]*[0-9]+\.[0-9]+\.[0-9]+' \ + | head -1 \ + | sed -E 's/.*=[[:space:]]*//' || true) + if [ -n "$CLI_VERSION" ]; then + VERSION="$CLI_VERSION" + echo "使用评论指定版本:$VERSION" + else + VERSION=$(sed -n 's:.*\(.*\).*:\1:p' Directory.Build.props | head -1) + [ -n "$VERSION" ] || VERSION=1.0.0 + fi echo "version=$VERSION" >> "$GITHUB_OUTPUT" # Issue 评论挂在 PR 上时,用 PR 的 head 提交;否则用默认分支最新 @@ -101,6 +112,7 @@ jobs: ISSUE: ${{ github.event.issue.number }} TARGET: ${{ steps.parse.outputs.target }} REF: ${{ steps.parse.outputs.ref }} + VERSION: ${{ steps.parse.outputs.version }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | set -e @@ -116,6 +128,7 @@ jobs: - 来源提交:\`${REF:0:7}\` - 目标:\`${TARGET}\` + - 版本:\`${VERSION}\` - 实时日志:${RUN_URL} 编译完成后会在这里回复结果。 @@ -126,7 +139,7 @@ jobs: build-mac: needs: prepare if: needs.prepare.outputs.ok == 'true' && (needs.prepare.outputs.target == 'mac' || needs.prepare.outputs.target == 'all') - runs-on: macos-latest + runs-on: macos-14 steps: - uses: actions/checkout@v4 with: @@ -136,16 +149,33 @@ jobs: with: dotnet-version: ${{ env.DOTNET_VERSION }} + # NuGet 包缓存:Avalonia / CommunityToolkit 等依赖每次冷下载要几分钟, + # 依赖没变时直接命中缓存。key 基于所有 csproj + .props。 + - uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/packages.lock.json') }} + restore-keys: ${{ runner.os }}-nuget- + - uses: subosito/flutter-action@v2 with: flutter-version: ${{ env.FLUTTER_VERSION }} channel: stable cache: true + # CocoaPods:Pods/ 被 gitignore,Podfile.lock 没变时复用,省掉每次 pod install + - uses: actions/cache@v4 + with: + path: | + GC-UI/frontend/macos/Pods + ~/Library/Caches/CocoaPods + key: ${{ runner.os }}-pods-${{ hashFiles('GC-UI/frontend/macos/Podfile.lock') }} + restore-keys: ${{ runner.os }}-pods- + - name: 编译 macOS env: GC_NO_PROGRESS: '1' - run: ./build.sh build --targets=mac + run: ./build.sh build --targets=mac -version=${{ needs.prepare.outputs.version }} - uses: actions/upload-artifact@v4 with: @@ -177,7 +207,7 @@ jobs: cache: true - name: 编译 Windows - run: ./build.ps1 build + run: ./build.ps1 build -Version ${{ needs.prepare.outputs.version }} - uses: actions/upload-artifact@v4 with: @@ -236,7 +266,7 @@ jobs: run: | set -e cat > notes.md <