Skip to content

Commit 093fceb

Browse files
committed
ci: optimize the build and test experience for fork PRs
1 parent f15e0e9 commit 093fceb

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
rust_target: x86_64-pc-windows-msvc
2323
- os: windows-latest
2424
rust_target: aarch64-pc-windows-msvc
25-
environment: TAURI_KEY # 指定使用这个环境
25+
# 主仓库可以访问 TAURI_KEY environment,fork PR 访问不到但不会失败
26+
environment: ${{ (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') && 'TAURI_KEY' || '' }}
2627
permissions:
2728
contents: read
2829

@@ -127,6 +128,34 @@ jobs:
127128
linker = "lld-link"
128129
EOF
129130
fi
131+
132+
# Fork PR:完全禁用 updater 以支持无签名构建
133+
- name: Disable updater for fork PR
134+
if: github.event.pull_request.head.repo.full_name != github.repository
135+
shell: bash
136+
run: |
137+
echo "🔍 Detected fork PR, disabling updater for unsigned build..."
138+
node -e "
139+
const fs = require('fs');
140+
const path = './src-tauri/tauri.conf.json';
141+
const config = JSON.parse(fs.readFileSync(path, 'utf8'));
142+
143+
// 完全移除 updater 插件配置
144+
if (config.plugins && config.plugins.updater) {
145+
delete config.plugins.updater;
146+
console.log('✅ Removed updater plugin configuration');
147+
}
148+
149+
// 禁用 updater artifacts 生成
150+
if (config.bundle) {
151+
config.bundle.createUpdaterArtifacts = false;
152+
console.log('✅ Disabled updater artifacts generation');
153+
}
154+
155+
fs.writeFileSync(path, JSON.stringify(config, null, '\t'));
156+
console.log('✅ Fork build will work normally but without auto-update support');
157+
"
158+
130159
- name: Build with Tauri Action
131160
uses: tauri-apps/tauri-action@v0
132161
env:
@@ -145,6 +174,17 @@ jobs:
145174
includeRelease: true
146175
tauriScript: pnpm tauri
147176

177+
# 显示构建状态
178+
- name: Build status
179+
shell: bash
180+
run: |
181+
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ] && [ "${{ github.event_name }}" == "pull_request" ]; then
182+
echo "⚠️ Fork PR: Build completed WITHOUT signing"
183+
echo " The application will work but won't support auto-updates"
184+
else
185+
echo "✅ Build completed with signing enabled"
186+
fi
187+
148188
# Upload build artifacts for testings
149189
- name: Upload Executable (Artifact)
150190
if: matrix.os == 'windows-latest'

0 commit comments

Comments
 (0)