Skip to content

Commit 261d17c

Browse files
7418claude
andcommitted
fix: CI 解码 base64 证书为 .p12 文件后传给 CSC_LINK
electron-builder 把 base64 字符串当文件路径解析导致构建失败。 改为先 base64 --decode 写入 /tmp/cert.p12,CSC_LINK 指向文件路径。 同时加 HAS_CERT 环境变量控制签名/验证步骤的条件执行。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0e38e44 commit 261d17c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
build-macos:
5555
if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'macos' }}
5656
runs-on: macos-latest
57+
env:
58+
HAS_CERT: ${{ secrets.MAC_CERT_P12_BASE64 != '' && 'true' || 'false' }}
5759
steps:
5860
- uses: actions/checkout@v4
5961

@@ -68,16 +70,23 @@ jobs:
6870
- name: Build Electron app
6971
run: npm run electron:build
7072

73+
- name: Decode signing certificate
74+
if: ${{ env.HAS_CERT == 'true' }}
75+
env:
76+
MAC_CERT_P12_BASE64: ${{ secrets.MAC_CERT_P12_BASE64 }}
77+
run: echo "$MAC_CERT_P12_BASE64" | base64 --decode > /tmp/cert.p12
78+
7179
- name: Package for macOS (x64 + arm64)
7280
env:
73-
CSC_LINK: ${{ secrets.MAC_CERT_P12_BASE64 }}
81+
CSC_LINK: ${{ env.HAS_CERT == 'true' && '/tmp/cert.p12' || '' }}
7482
CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_PASSWORD }}
7583
APPLE_ID: ${{ secrets.APPLE_ID }}
7684
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
7785
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
7886
run: npx electron-builder --mac --config electron-builder.yml --publish never
7987

8088
- name: Verify code signature
89+
if: ${{ env.HAS_CERT == 'true' }}
8190
run: |
8291
# Verify every .app bundle produced (arm64 + x64)
8392
APPS=$(find release -name "CodePilot.app" -maxdepth 3)

0 commit comments

Comments
 (0)