From 936ef8333e9ac57aca364eefa52299f115e26b7d Mon Sep 17 00:00:00 2001 From: chenmoyuan1214 Date: Sat, 21 Nov 2026 19:47:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20macOS=20=E6=9E=84=E5=BB=BA=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=20--no-codesign=EF=BC=9Bbuild-bot=20=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=B9=9F=E5=9B=9E=E5=B8=96=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flutter build macos 不支持 --no-codesign(那是 iOS 的选项), 传了会直接报 'Could not find an option named no-codesign' 导致编译失败。 macOS 模板本身用 ad-hoc 签名,CI 无证书也能构建。 - 删除 workflow 里的 GC_NO_CODESIGN 环境变量 - build-bot 新增独立 report job(always): 编译/发布任何一步失败都会回帖,列出各平台结果与日志链接, 不再因为 publish 被跳过而静默 --- .github/CI.md | 2 +- .github/workflows/build-bot.yml | 55 +++++++++++++++++++----- .github/workflows/nightly-prerelease.yml | 1 - buildsh/lib/flutter.sh | 13 +++--- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/.github/CI.md b/.github/CI.md index 40e14cd..c714f9f 100644 --- a/.github/CI.md +++ b/.github/CI.md @@ -59,5 +59,5 @@ - `Settings → Actions → General → Workflow permissions` 给 **Read and write**, 否则 `gh release` / 评论接口会 403(工作流里已声明 `permissions:`,但组织策略可能覆盖)。 - Secrets 不需要额外配置,统一用内置的 `GITHUB_TOKEN`。 -- macOS 产物是 **未签名** 的(`GC_NO_CODESIGN=1`)。下载后首次打开需右键 →「打开」, +- macOS 产物是 **ad-hoc 签名**(无开发者证书)。下载后首次打开需右键 →「打开」, 或在「系统设置 → 隐私与安全性」里放行。 diff --git a/.github/workflows/build-bot.yml b/.github/workflows/build-bot.yml index 6283e5a..e35800c 100644 --- a/.github/workflows/build-bot.yml +++ b/.github/workflows/build-bot.yml @@ -136,7 +136,6 @@ jobs: - name: 编译 macOS env: - GC_NO_CODESIGN: '1' GC_NO_PROGRESS: '1' run: ./build.sh build --targets=mac @@ -252,18 +251,52 @@ jobs: echo "https://github.com/${{ github.repository }}/releases/tag/$TAG" >> "$GITHUB_STEP_SUMMARY" - - name: 回帖 - if: always() + # 结果回帖独立成一个 job:编译失败 / 发布失败也要有回音, + # 不能因为 publish 被跳过就静默。 + report: + needs: [prepare, build-mac, build-win, publish] + if: always() && needs.prepare.outputs.ok == 'true' + runs-on: ubuntu-latest + steps: + - name: 回帖结果 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TARGET: ${{ needs.prepare.outputs.target }} ISSUE: ${{ github.event.issue.number }} - STATE: ${{ steps.publish_step.outcome }} + TARGET: ${{ needs.prepare.outputs.target }} + REF: ${{ needs.prepare.outputs.ref }} + MAC: ${{ needs.build-mac.result }} + WIN: ${{ needs.build-win.result }} + PUB: ${{ needs.publish.result }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | - if [ "$STATE" = "success" ]; then - MSG="已编译 **${TARGET}** 并发布到预发布:https://github.com/${{ github.repository }}/releases/tag/ip-prerelease" - else - MSG="编译 **${TARGET}** 失败,见日志:${RUN_URL}" - fi - gh issue comment "$ISSUE" --body "$MSG" + set -e + REPO="${{ github.repository }}" + + line() { + case "$2" in + success) echo "- $1:✅ 成功" ;; + skipped) echo "- $1:⏭ 未请求(跳过)" ;; + cancelled) echo "- $1:⛔ 已取消" ;; + *) echo "- $1:❌ 失败" ;; + esac + } + + { + if [ "$PUB" = "success" ]; then + echo "✅ **编译完成**:\`${TARGET}\`" + else + echo "❌ **编译未完成**:\`${TARGET}\`" + fi + echo + line "macOS" "$MAC" + line "Windows" "$WIN" + echo + echo "- 来源提交:\`${REF:0:7}\`" + if [ "$PUB" = "success" ]; then + echo "- 产物:https://github.com/${REPO}/releases/tag/ip-prerelease" + else + echo "- 日志:${RUN_URL}" + fi + } > result.md + + gh issue comment "$ISSUE" --body-file result.md diff --git a/.github/workflows/nightly-prerelease.yml b/.github/workflows/nightly-prerelease.yml index aed42d9..157ce3f 100644 --- a/.github/workflows/nightly-prerelease.yml +++ b/.github/workflows/nightly-prerelease.yml @@ -59,7 +59,6 @@ jobs: - name: 编译 macOS env: GC_TARGETS: mac - GC_NO_CODESIGN: '1' GC_NO_PROGRESS: '1' run: ./build.sh build --targets=mac diff --git a/buildsh/lib/flutter.sh b/buildsh/lib/flutter.sh index ce732f6..7c02347 100644 --- a/buildsh/lib/flutter.sh +++ b/buildsh/lib/flutter.sh @@ -37,15 +37,12 @@ flutter_build() { _flutter pub get || return 1 fi - # CI 上没有签名证书:GC_NO_CODESIGN=1 时给 macOS 加 --no-codesign, - # 直接产出未签名的 .app(用户首次打开需右键「打开」或在系统设置里放行)。 - _flags="--release" - if [ "${GC_NO_CODESIGN:-0}" = 1 ] && [ "$_plat" = macos ]; then - _flags="$_flags --no-codesign" - fi - + # 注意:macOS 的 `flutter build macos` 没有 --no-codesign 选项(那是 iOS 的), + # 传了会直接报 "Could not find an option named no-codesign"。 + # macOS 模板默认用 ad-hoc 签名(CODE_SIGN_IDENTITY = "-"),无证书的 CI 也能构建出 .app, + # 只是首次打开需要右键「打开」。 run_logged "$GC_ROOT/build/logs/flutter-$_plat.log" "Flutter $_plat 构建 " \ - _flutter build "$_plat" $_flags || return 1 + _flutter build "$_plat" --release || return 1 step_ok "Flutter ${_plat}" }