ci(build-bot): 支持 version= 参数指定版本;mac 大小写不敏感;加速 macOS 构建
PR 审核 / 后端编译 (pull_request) Waiting to run
PR 审核 / 前端检查(Flutter) (pull_request) Waiting to run
PR 审核 / 安全扫描 (pull_request) Waiting to run

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 两个工作流同步优化
This commit is contained in:
远影科技 committed 2026-11-22 08:09:23 +08:00
1 parent 40d9da1c3d
commit 8b4cabba28
2 files changed
+57 -11

No files matched your search

+40 -10
View File
@@ -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:.*<Version>\(.*\)</Version>.*:\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:.*<Version>\(.*\)</Version>.*:\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 <<EOF
手动触发构建(\`@build-bot build ${TARGET}\`)。
手动触发构建(\`@build-bot build ${TARGET} version=${VERSION}\`)。
触发人:@${ACTOR}
来源:#${ISSUE}